Skip to content

I'm using your code for the SPS30 which is really cool but I have a problem. #1

@jbasemvd

Description

@jbasemvd

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
print(f"Auto cleaning interval: {pm_sensor.read_auto_cleaning_interval()}s")
File "/home/pi/Source/SPS30/sps30.py", line 167, in read_auto_cleaning_interval
data = self.i2c.read(NBYTES_AUTO_CLEANING_INTERVAL)
File "/home/pi/Source/SPS30/i2c/i2c.py", line 21, in read
return list(self.fr.read(nbytes))
OSError: [Errno 121] Remote I/O error

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions