modified: temp-humid-read-single.py
This commit is contained in:
@@ -4,12 +4,13 @@
|
|||||||
import sys
|
import sys
|
||||||
import dhtreader
|
import dhtreader
|
||||||
import updateMysql
|
import updateMysql
|
||||||
|
import readMysql
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
#import time
|
|
||||||
#from threading import Timer,Thread,Event
|
|
||||||
import logging
|
import logging
|
||||||
#from datetime import datetime
|
import time
|
||||||
#from datetime import timedelta
|
from time import strftime
|
||||||
|
from datetime import datetime
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
oldtemp = "NULL"
|
oldtemp = "NULL"
|
||||||
oldhumid = "NULL"
|
oldhumid = "NULL"
|
||||||
@@ -17,6 +18,8 @@ oldhumid = "NULL"
|
|||||||
def sensorRead(hwtype, pin, retries, timeout, maxtemp, mintemp, tempdiff, maxhumid, minhumid, humiddiff):
|
def sensorRead(hwtype, pin, retries, timeout, maxtemp, mintemp, tempdiff, maxhumid, minhumid, humiddiff):
|
||||||
global oldtemp
|
global oldtemp
|
||||||
global oldhumid
|
global oldhumid
|
||||||
|
oldtemp, oldhumid = readMysql.main(host, db, username, password, logging, sql_retries, sql_timeout)
|
||||||
|
logging.debug('We have returned the following previous temperature {0} and humidity {1} values.'.format(oldtemp, oldhumid))
|
||||||
for num in range(retries):
|
for num in range(retries):
|
||||||
try:
|
try:
|
||||||
t, h = dhtreader.read(dev_type, dhtpin)
|
t, h = dhtreader.read(dev_type, dhtpin)
|
||||||
@@ -49,7 +52,7 @@ DHT22 = 22
|
|||||||
AM2302 = 22
|
AM2302 = 22
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read('temphumid.conf')
|
config.read('/etc/thMonitor.conf')
|
||||||
hwtype=config.get('hardware', 'DHT')
|
hwtype=config.get('hardware', 'DHT')
|
||||||
pin=config.get('hardware', 'PIN')
|
pin=config.get('hardware', 'PIN')
|
||||||
retries=int(config.get('software', 'retries'))
|
retries=int(config.get('software', 'retries'))
|
||||||
|
|||||||
Reference in New Issue
Block a user