pimoroni / pms5003-python

Python library for the PMS5003 particulate sensor
MIT License
51 stars 19 forks source link

SerialTimeoutError in example particulates code #18

Open davetisyan95 opened 1 year ago

davetisyan95 commented 1 year ago

Hello,

I am encountering an error when running the particulates.py example.

Traceback (most recent call last):
  File "particulates.py", line 26, in <module>
    readings = pms5003.read()
  File "/usr/local/lib/python3.7/dist-packages/pms5003/__init__.py", line 127, in read
    raise SerialTimeoutError("PMS5003 Read Timeout: Failed to read start of frame byte")
pms5003.SerialTimeoutError: PMS5003 Read Timeout: Failed to read start of frame byte

Things I have tried:

All other scripts work fine, it is just when trying to use the PM sensor in particulates.py.

Context: I have successfully run this before maybe around 2021? I have since lost that version of the code and recently tried re-using it. Initially i was using the latest OS (Bullseye), now am on Buster and still no luck.

hstaab commented 1 year ago

I can confirm that a fresh setup with the sensor on a new Raspberry Pi Zero with Enviro+, will not work as instructed. I also had this setup working in 2021.

prutsky commented 1 year ago

Me too. Pick-up my EnviroPlus board with a RPI Zero.

I get this error:

python3 particulates.py 
2023-11-27 14:41:35.527 INFO     particulates.py - Print readings from the PMS5003 particulate sensor.

Press Ctrl+C to exit!

Traceback (most recent call last):
  File "/home/pi/enviroplus-python/examples/particulates.py", line 18, in <module>
    pms5003 = PMS5003()
              ^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pms5003/__init__.py", line 109, in __init__
    self._pin_enable, self._pin_reset = gpiodevice.get_pins_for_platform(PLATFORMS)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)
JollyJokr commented 12 months ago

Sadly I can +1 the problem with a fresh setup and the PMS5003 sensor. Everything else is working fine.

Traceback (most recent call last):
  File "/home/pi/Pimoroni/enviroplus/examples/mqtt-all.py", line 278, in <module>
    main()
  File "/home/pi/Pimoroni/enviroplus/examples/mqtt-all.py", line 243, in main
    pms5003 = PMS5003()
  File "/usr/local/lib/python3.9/dist-packages/pms5003/__init__.py", line 109, in __init__
    self._pin_enable, self._pin_reset = gpiodevice.get_pins_for_platform(PLATFORMS)
ValueError: not enough values to unpack (expected 2, got 0)
Gadgetoid commented 11 months ago

Recent errors - eg: ValueError: not enough values to unpack (expected 2, got 0) - appear to be related to the migration to gpiod/Bookworm OS. Some more details and tips for how to debug what's happening are available here: https://github.com/pimoroni/enviroplus-python/pull/126

Black616Angel commented 7 months ago

A workaround would be installing the last working version via pip install pms5003==0.0.5 this worked for me. In the mean time pimoroni should try not setting the version to 1.0 if things break so regularly on the examples.