pms5003-python
pms5003-python copied to clipboard
SerialTimeoutError in example particulates code
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:
- ran
install.shand verified/boot/config.txt - validated that
check-install.pylooks ok - new enviro+ and PMS5003 sensor
- verified connection is good (I hear the fan in the sensor speed up when I start the script)
- Tried both bullseye and buster
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.
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.
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)
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)
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
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.
In the mean time pimoroni should try not setting the version to 1.0 if things break so regularly on the examples.
The major version bump is reflected across all libraries and is a mnemonic to tell stuff that's been migrated to Pi5-and-bookworm-broke-everything-(again) from everything else.
Python packages have classifiers to denote the development status: https://github.com/pimoroni/pms5003-python/blob/8996374046fcf8dd343f300daf4a6bc9bac9425e/pyproject.toml#L22
This issue is/was probably fixed with 1.0.1, but UART on Pi's is a mixed bag.