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…