Commit 19095b0e authored by Tom Hartley's avatar Tom Hartley

Added light-blinking on success & failure

parent a9fa220c
......@@ -2,6 +2,7 @@
import sys
sys.dont_write_bytecode = True
import RPi.GPIO as GPIO
import ConfigParser
import time
import inspect
......@@ -25,6 +26,8 @@ sensorConfig.read('sensors.cfg')
sensorNames = sensorConfig.sections()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) #Use BCM GPIO numbers.
sensorPlugins = []
for i in sensorNames:
......@@ -165,7 +168,10 @@ mainConfig.read("settings.cfg")
lastUpdated = 0
delayTime = mainConfig.getfloat("Main","uploadDelay")
redPin = mainConfig.getint("Main","redPin")
greenPin = mainConfig.getint("Main","greenPin")
GPIO.setup(redPin,GPIO.OUT,initial=GPIO.LOW)
GPIO.setup(greenPin,GPIO.OUT,initial=GPIO.LOW)
while True:
curTime = time.time()
if (curTime-lastUpdated)>delayTime:
......@@ -188,7 +194,10 @@ while True:
working = working and i.outputData(data)
if working:
print "Uploaded successfully"
#Blink Green
GPIO.output(greenPin,GPIO.HIGH)
else:
print "Failed to upload"
#Blink Red
GPIO.output(redPin,GPIO.HIGH)
time.sleep(1)
GPIO.output(greenPin,GPIO.LOW)
GPIO.output(redPin,GPIO.LOW)
......@@ -30,13 +30,13 @@ class DHT22(sensor.Sensor):
if (time.time()-tm)<2:
t, h = dhtreader.lastData
else:
t = time.time()
tim = time.time()
try:
t, h = dhtreader.read(22,self.pinNum)
except Exception:
t, h = dhtreader.lastData
dhtreader.lastData = (t,h)
dhtreader.lastDataTime=t
dhtreader.lastDataTime=tim
if self.valName == "Temperature":
temp = t
if self.valUnit == "Fahrenheit":
......
[Main]
uploadDelay = 5 ;how long to wait before uploading again
redPin=10
greenPin=22
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment