forked from adafruit/Adafruit_CircuitPython_CLUE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclue_temperature_humidity_monitor.py
executable file
·51 lines (40 loc) · 1.33 KB
/
clue_temperature_humidity_monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Monitor customisable temperature and humidity ranges, with an optional audible alarm tone."""
from adafruit_clue import clue
# Set desired temperature range in degrees Celsius.
min_temperature = 24
max_temperature = 30
# Set desired humidity range in percent.
min_humidity = 20
max_humidity = 65
# Set to true to enable audible alarm tone.
alarm_enable = False
clue_display = clue.simple_text_display(text_scale=3, colors=(clue.WHITE,))
clue_display[0].text = "Temperature &"
clue_display[1].text = "Humidity"
while True:
alarm = False
temperature = clue.temperature
humidity = clue.humidity
clue_display[3].text = "Temp: {:.1f} C".format(temperature)
clue_display[5].text = "Humi: {:.1f} %".format(humidity)
if temperature < min_temperature:
clue_display[3].color = clue.BLUE
alarm = True
elif temperature > max_temperature:
clue_display[3].color = clue.RED
alarm = True
else:
clue_display[3].color = clue.WHITE
if humidity < min_humidity:
clue_display[5].color = clue.BLUE
alarm = True
elif humidity > max_humidity:
clue_display[5].color = clue.RED
alarm = True
else:
clue_display[5].color = clue.WHITE
clue_display.show()
if alarm and alarm_enable:
clue.start_tone(2000)
else:
clue.stop_tone()