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

Added light-blinking on success & failure

parent a9fa220c
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import sys import sys
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
import RPi.GPIO as GPIO
import ConfigParser import ConfigParser
import time import time
import inspect import inspect
...@@ -25,6 +26,8 @@ sensorConfig.read('sensors.cfg') ...@@ -25,6 +26,8 @@ sensorConfig.read('sensors.cfg')
sensorNames = sensorConfig.sections() sensorNames = sensorConfig.sections()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) #Use BCM GPIO numbers.
sensorPlugins = [] sensorPlugins = []
for i in sensorNames: for i in sensorNames:
...@@ -165,7 +168,10 @@ mainConfig.read("settings.cfg") ...@@ -165,7 +168,10 @@ mainConfig.read("settings.cfg")
lastUpdated = 0 lastUpdated = 0
delayTime = mainConfig.getfloat("Main","uploadDelay") 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: while True:
curTime = time.time() curTime = time.time()
if (curTime-lastUpdated)>delayTime: if (curTime-lastUpdated)>delayTime:
...@@ -188,7 +194,10 @@ while True: ...@@ -188,7 +194,10 @@ while True:
working = working and i.outputData(data) working = working and i.outputData(data)
if working: if working:
print "Uploaded successfully" print "Uploaded successfully"
#Blink Green GPIO.output(greenPin,GPIO.HIGH)
else: else:
print "Failed to upload" 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): ...@@ -30,13 +30,13 @@ class DHT22(sensor.Sensor):
if (time.time()-tm)<2: if (time.time()-tm)<2:
t, h = dhtreader.lastData t, h = dhtreader.lastData
else: else:
t = time.time() tim = time.time()
try: try:
t, h = dhtreader.read(22,self.pinNum) t, h = dhtreader.read(22,self.pinNum)
except Exception: except Exception:
t, h = dhtreader.lastData t, h = dhtreader.lastData
dhtreader.lastData = (t,h) dhtreader.lastData = (t,h)
dhtreader.lastDataTime=t dhtreader.lastDataTime=tim
if self.valName == "Temperature": if self.valName == "Temperature":
temp = t temp = t
if self.valUnit == "Fahrenheit": if self.valUnit == "Fahrenheit":
......
[Main] [Main]
uploadDelay = 5 ;how long to wait before uploading again 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