Problem with PMS5003 particulate matter sensor

I have successfully run the one line python library script and attached the particulate sensor to the enviroplus. I then tried running the various python examples. However, particulates.py hangs and doesn’t print any readings. I then ran all-in-one.py, which runs correctly up to the point it tries to read the particulate sensor. It then prints out the warning ‘failed to read PMS5003’. The script recognizes that the sensor is connected and I can hear the small fan running inside, but am unable to read any values.
I am running Raspbian Buster on a Pi 3 model B.

Any help would be appreciated.

Just a stab in the dark but does it have to warm up first? My BME680 has a heater for the air sensor that needs to run for a while before I can use that sensor.

I have left it for running for 10 minutes with no values printed. I could try leaving much longer.

I would think 10 minutes would be more than long enough? I don’t own one, just so you know.
You could try the requirements part from here,

Running the one-line setup script for the enviro+ loads the necessary libraries and other configurations given in the PMS5003 link. I have also manually checked that they have been implemented correctly and everything looks okay.

I “think” you have to run
curl -sSL https://get.pimoroni.com/enviroplus | bash
and
sudo pip install pms5003
And I think it actually needs to be
sudo pip3 install pms5003
If its Buster and you want to use Python 3.

Thanks for the reply. I had already run this one-line curl script. I did just try the pip/pip3 installs, but I get a message confirming that these requirements have been satisfied.
I have tried running the few lines of code for this sensor given in the tutorial, but get a ReadTimeoutError. It suggests this may happen and to try again, but it continues to give the timeout error under python and python3. I an going to try it with another SD card with Raspbian stretch to see if that makes any difference.

Ok, good luck, I don’t have any other ideas.

The particulates.py code runs successfully under Raspbian stretch using python3… There must be something in Buster that it doesn’t like. All the other examples are okay as well.

I’m not making excuses for Pimoroni, but Buster caught a lot of people / retailers out.
The Debian Buster release wasn’t even officially released when the Pi 4B was released. And only Buster will run on a Pi 4B. So they did an unofficial Raspbian Buster release so you could actually use your Pi 4B. I “think” the way it went down was retailers had the Pi 4B, but didn’t have an OS to run on it. Now they are playing catch up with what has changed in Buster. Especially the Lite version. Its missing pip and smbus to name a few. And as far as I know, there is no Python 2 support in Buster.
You can get any older Raspbian build here, I’ve ben posting this link quit a bit lately.
http://downloads.raspberrypi.org/raspbian/images/

Works fine on Buster with python3 for me.

Thanks for that, nice to know it works in Buster. I have several Pi setups still running Stretch, maybe even Jessie. Headless setups that work so if it ain’t broke don’t fix it comes into play. I am slowly working my way to Buster on some of my setups. I have 24 or so Pi’s kicking around so when I get board I redo one of them to see how it goes with what’s attached to it.

I’m running Buster on a Pi Zero W with the Enviro+ and PMS5003. I’m having the same issue on cold startup and reboot as well.
I’ve created a systemd service which starts on boot. It fails to read the PMS5003 every time while it does display the other sensors on the Enviro+ phat using the combined.py. Of course, when you cycle through the various displays it hangs when it comes to the first PMS5003 display.

● enviro.service - Enviro combined metrics readout
Loaded: loaded (/lib/systemd/system/enviro.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-12-01 11:29:43 CET; 2min 21s ago
Process: 478 ExecStartPre=/bin/sleep 20 (code=exited, status=0/SUCCESS)
Main PID: 481 (python)
Memory: 26.0M
CGroup: /system.slice/enviro.service
└─481 /usr/bin/python /home/pi/enviroplus-python/examples/airmetrics.py /var/log/enviroplus.log 2>&1

Dec 01 11:31:57 raspberrypi python[481]: 2019-12-01 11:31:57.493 INFO redu: 448.9 ppm
Dec 01 11:31:57 raspberrypi python[481]: 2019-12-01 11:31:57.496 INFO nh3: 695.2 ppm
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.092 WARNING Failed to read PMS5003
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.160 INFO temp: 19.4 C
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.268 INFO pres: 1021.5 hPa
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.375 INFO humi: 29.4 %
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.389 INFO ligh: 51.1 Lux
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.547 INFO oxid: 14.6 ppm
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.550 INFO redu: 444.8 ppm
Dec 01 11:32:03 raspberrypi python[481]: 2019-12-01 11:32:03.553 INFO nh3: 686.2 ppm

I think the PMS5003 needs some time. When I run the particulates.py it sometimes gives the following message:

root@raspberrypi:/home/pi/enviroplus-python/examples# python particulates.py
2019-12-01 11:39:38.688 INFO particulates.py - Print readings from the PMS5003 particulate sensor.

Press Ctrl+C to exit!

Traceback (most recent call last):
File “particulates.py”, line 24, in
readings = pms5003.read()
File “/usr/local/lib/python2.7/dist-packages/pms5003-0.0.4-py2.7.egg/pms5003/init.py”, line 141, in read
raise ChecksumMismatchError(“PMS5003 Checksum Mismatch {} != {}”.format(checksum, data.checksum))
pms5003.ChecksumMismatchError: PMS5003 Checksum Mismatch 373 != 29762

and sometimes it starts spitting out the values for PM for the first half of the metrics, the second half of the metrics stays on 0 until about 8 or 9 ‘runs’ or ‘metrics screen refresh’

PM1.0 ug/m3 (ultrafine particles): 4
PM2.5 ug/m3 (combustion particles, organic compounds, metals): 7
PM10 ug/m3 (dust, pollen, mould spores): 7
PM1.0 ug/m3 (atmos env): 4
PM2.5 ug/m3 (atmos env): 7
PM10 ug/m3 (atmos env): 7

0.3um in 0.1L air: 0
0.5um in 0.1L air: 0
1.0um in 0.1L air: 0
2.5um in 0.1L air: 0
5.0um in 0.1L air: 0
10um in 0.1L air: 0

after 8 or 9 ‘runs’ it also counts the bottom half of the metrics.

PM1.0 ug/m3 (ultrafine particles): 3
PM2.5 ug/m3 (combustion particles, organic compounds, metals): 4
PM10 ug/m3 (dust, pollen, mould spores): 5
PM1.0 ug/m3 (atmos env): 3
PM2.5 ug/m3 (atmos env): 4
PM10 ug/m3 (atmos env): 5

0.3um in 0.1L air: 684
0.5um in 0.1L air: 186
1.0um in 0.1L air: 12
2.5um in 0.1L air: 4
5.0um in 0.1L air: 0
10um in 0.1L air: 0

So, when the Pi boots it runs the combined.py. The PMS5003 values fail. but when I login using SSH and run the particulates.py. After about 8 ‘runs’ or ‘screen refreshes’ the PMS5003 values are displayed on the OLED.

I’m now looking at a workaround where the systemd service starts and then a second service starts the particulates.py for about 20 secs to ‘initialize’ the PMS5003 and then quit.

Hopefully someone has a much better idea than this quick/dirty way…

Does the PMS5003 require a warm up period maybe?
You may be able to start that with a delay from crontab?
Or out some error handling into your python file?

I remember an earlier discussion about how the PMS5003 is running at 5v instead of the 3v3 it is spec’d to. So maybe some (maybe a lot of) settling time is needed. When I saw that the new Enviro product has no PMS (or the A/D chip it uses) I thought that maybe Pim has given up on fixing it.