-
Notifications
You must be signed in to change notification settings - Fork 8
/
example.py
26 lines (22 loc) · 870 Bytes
/
example.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
import sys
import json
from time import sleep
from sps30 import SPS30
if __name__ == "__main__":
pm_sensor = SPS30()
print(f"Firmware version: {pm_sensor.firmware_version()}")
print(f"Product type: {pm_sensor.product_type()}")
print(f"Serial number: {pm_sensor.serial_number()}")
print(f"Status register: {pm_sensor.read_status_register()}")
print(
f"Auto cleaning interval: {pm_sensor.read_auto_cleaning_interval()}s")
print(f"Set auto cleaning interval: {pm_sensor.write_auto_cleaning_interval_days(2)}s")
pm_sensor.start_measurement()
while True:
try:
print(json.dumps(pm_sensor.get_measurement(), indent=2))
sleep(2)
except KeyboardInterrupt:
print("Stopping measurement...")
pm_sensor.stop_measurement()
sys.exit()