sps30
sps30 copied to clipboard
I'm using your code for the SPS30 which is really cool but I have a problem.
I'm hoping you can help me with an error running example.py. I get this error:
Serial number: CCC69E8DCEAD8B5F
Status register: {'speed_status': 'ok', 'laser_status': 'ok', 'fan_status': 'ok'}
Traceback (most recent call last):
File "/home/pi/Source/SPS30/example.py", line 13, in
If I remove/comment the line print(f"Auto cleaning interval: {pm_sensor.read_auto_cleaning_interval()}s")line I get readings as expected:
Do you have any thoughts on what might be happening?
Here is the code I'm using which is the example.py file included in the download:
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") 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()
Thanks advance, Walt