-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_data.py
41 lines (22 loc) · 814 Bytes
/
log_data.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
from devices.ocpn3 import OPCN3
import time
def main():
item = OPCN3(settings_file="./settings.yaml")
item.wake()
starttime = time.time()
print(item.read_last(item.gadget_id))
done = False
print("Logging started. Press Ctrl-C to stop.")
while not done:
try:
reading = item.get_particulates()
item.write_reading(item.gadget_id, **reading)
print(f"logging {item.gadget_id} t:{reading['temp']}, rh: {reading['rh']}, pms: {reading['pm_01']}, {reading['pm_25']}, {reading['pm_10']}")
except KeyboardInterrupt:
done = True
item.sleep()
except Exception as e:
print(f"Error {e}")
time.sleep(item.settings['LOGGING_INTERVAL_SECS'])
if __name__ == '__main__':
main()