Moved the webapp to a webpack with some typescript, updated server wtih new endpoints
This commit is contained in:
28
climate-pinger.py
Normal file
28
climate-pinger.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/local/bin/python3
|
||||
|
||||
import adafruit_dht
|
||||
import mh_z19
|
||||
from sys import stderr
|
||||
from board import D4
|
||||
from datetime import datetime
|
||||
|
||||
try:
|
||||
dhtDevice = adafruit_dht.DHT22(D4)
|
||||
temp = dhtDevice.temperature
|
||||
humidity = dhtDevice.humidity
|
||||
co2 = mh_z19.read()
|
||||
if co2 is not None:
|
||||
co2 = co2['co2']
|
||||
else:
|
||||
raise RuntimeError()
|
||||
print(
|
||||
'Time:', str(datetime.now()),
|
||||
'Temp:', temp,
|
||||
'Humidity:', humidity,
|
||||
'CO2:', co2,
|
||||
sep='\n',
|
||||
)
|
||||
except Exception as error:
|
||||
print('err:', error, file=sys.stderr)
|
||||
|
||||
dhtDevice.exit()
|
||||
Reference in New Issue
Block a user