Accessing PMS5003 from concurrent scripts problem

I’ve got an enviro+ and PMS5003 hooked up to a Pi Zero W.

I can successfully publish enviro+ data via MQTT using Sam Birch’s enviroplus-mqtt software ( This runs as a service and sends the data to my Home Assistant.

However, I also want to contribute my data to Luftdaten…

If I run the script whilst the enviroplus service is running then the Luftdaten script generally throws mostly checksum errors everytime it tries to read the PM data. Maybe 1 in 20 attempts to publish the data are successful. This seems to happen regardless as to whether I run in the foreground of a console window or as a forked process (i.e. with an “&”) via rc.local at bootup.

Running the Lufdaten script also seems to corrupt the PM readings that envlogger is picking up from the PMS5003, in that all 3 values for PM1.0, PM2.5 and PM10 become the same (e.g. PM1,2.5 and 10 will all be 6 ugm3 - which is too much of a coincidence)

If I stop the envlogger service then the Luftdaten script runs fine - no checksum errors.

If I stop the Luftdaten script then the envlogger service resumes sending correct (i.e. different values) for each of P1.0, PM2.5 and PM10).

I’ve tried reducing the sampling frequency of the envlogger routine - doesn’t seem to make any difference.

I’ve also tried using the modified published by RemBrand (Basic intro for uploading to Luftdaten / Air quality project) that allows the sampling frequency to be throttled.

So, it looks like it is not possible to have two Python routines independently and concurrently reading the PM data from enviroplus?

Any ideas from anybody?

Could you call one up from the other? Then only one is trying to access the PMS5003 at a time.

Thanks Kerry. Good suggestion - I ought to be able to merge the two scripts.

It’s not all that hard if both are the same programing language like Python. I have a couple of lengthy files for that very reason. One sensor used for two different things.