Skip to content

Commit 0941384

Browse files
committed
In case there is no sensor
Added code that will populate the temperature and humidity variables with random numbers. Good for people that don't have a sensor handy.
1 parent 787151c commit 0941384

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

env_log.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ def log_values(sensor_id, temp, hum):
6363
conn.close()
6464

6565
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 17)
66+
# If you don't have a sensor but still wish to run this program, comment out all the
67+
# sensor related lines, and uncomment the following lines (these will produce random
68+
# numbers for the temperature and humidity variables):
69+
# import random
70+
# humidity = random.randint(1,100)
71+
# temperature = random.randint(10,30)
6672
if humidity is not None and temperature is not None:
6773
log_values("1", temperature, humidity)
6874
else:

0 commit comments

Comments
 (0)