rulururu

post OrchidPi

June 18th, 2014

Filed under: Tech — RHH @ 10:51 pm

So here is another project that I’m working on.  This is just going to be a short post because a few people have asked for more information and code (what there is).

What it is:

Two zone temperature/humidity monitor with custom case for my wife’s orchid tank. Orchids have unique environmental requirements. Next feature is to write the values to a database so that I can produce a chart of historical values.  Another desired feature is to control a humidifier as needed to maintain adequate humidity.

 

What it looks like installed:

Installed

What it looks like up close:

upClose

Here is the gnarly wiring diagram:

 

ugly

For this part keep in mind that I am not a programmer by training or any other way.  I used several internet sites to come to this.  Some of those sites provided a significant amount of code.  I will try to cite them at some point.  You will need the LCD library from Adafruit.  I will get that link on here later.  Here is the code:

#!/usr/bin/python

from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime
import subprocess
import re
import sys
import time
#import MySQLdb as mdb # later feature
#import time
#import datetime

lcd = Adafruit_CharLCD()

lcd.begin(16,1)

while 1:
    output1 = subprocess.check_output(["./Adafruit_DHT", "2302", "4"]);
    matches = re.search("Temp =\s+([0-9.]+)", output1)
    if (not matches):
          time.sleep(10)
          continue
    ctemp = float(matches.group(1))
    ftemp = ctemp * 9/5.0 + 32

    # search for humidity printout
    matches = re.search("Hum =\s+([0-9.]+)", output1)
    if (not matches):
          time.sleep(10)
          continue
    humidity = float(matches.group(1))
    #adjust value for accuracy
    humidity = humidity - 9

    output2 = subprocess.check_output(["./Adafruit_DHT", "2302", "18"]);
    matches = re.search("Temp =\s+([0-9.]+)", output2)
    if (not matches):
          time.sleep(10)
          continue
    ctemp2 = float(matches.group(1))
    ftemp2 = ctemp2 * 9/5.0 + 32

    # search for humidity printout
    matches = re.search("Hum =\s+([0-9.]+)", output2)
    if (not matches):
          time.sleep(10)
          continue
    humidity2 = float(matches.group(1))
    #adjust value for accuracy
    humidity2 = humidity2 - 15

    lcd.clear()
    #lcd.message(datetime.now().strftime('%b %d %H:%M:%S\n'))
    lcd.message('1 ' + 'T %s' % ( ftemp ) + ' H %s' % ( humidity ) + '\n' )
    lcd.message('2 ' + 'T %s' % ( ftemp2 ) + ' H %s' % ( humidity2 ) )


 

Note: If I have used some of your code and you would like to be linked or given credit, please just let me know.  I will leave comments on for a short time.  I get so much spam!

ruldrurd


Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)