EnviroPlusWeb won't rerun after few days without mains power

I have had my Enviro+ with PMS5003 working perfectly for a week or so until a major failure that I don’t understand.

I use EnviroPlusWeb running sudo python3 app.py.

It is outside the house (in the style from Sandy Macdonald’s Pimoroni document with white downpipe pieces from his excellent document). Mine uses a mains power cable connected to an in house socket via a cat flap as we have no outside power sockets.

That mains cable was removed several times because of rain overnight and then I use a waterproof container with a small solar panel providing power and a Li(ion) battery also providing power took over. When power totally went, say overnight several times, I would plug in mains again next day and it would boot up and it would start it again. No issues and it still displayed online the whole days of data. Until…

A major problem has now occurred all the time even after reboots: I have had to photograph the PUTTY screen to capture the commands as it is very long to type in exactly so I have posted that easily readable photo here:


I have no idea what that error code is about; even though I have looked at the files it complained about.

The EnviroPlus PMS5003 is running and its LCD display is lit up.

NB: I have not yet configured and registered to use Luftdaten but I intend to do so once I have bought and fitted a conventional outside power socket on the house and I can get the Enviro+ PMS5003 working again…

I immediately tried the alternative below after the error above keeps appearing all the time even after retrying reboots.
This alternatives below runs perfectly and clearly without needing to reboot:

I ran enviroplus-python/examples/particulates.py using
sudo python3 particulates and it works OK. As do others in that group such as
all-in-one.py .

I hope guidance can be given to get the standard version with the display and ability to link to Luftdaten to work.


Geoff Harmer

I have no idea what that error means but I’ll take a best guess at what “might” be going on.
If it’s losing power while running that’s the equivalent of not shutting down properly. which could be corrupting data on your SD Card.
Something else that may be messing things up is if the time and date are incorrect. If you don’t have a Real Time Clock installed, on boot up it starts with the time stamp saved on shut down. That’s only updated if and when the Pi goes online and syncs with an online time server.
I have two of what I call weather clocks. A Pi A+ Sense Hat RTC and other sensors. One is portable and doesn’t have Internet access. The DS3231 RTC keeps it accurate Date and Time wise.

Thanks for a prompt reply.

Corruption of data could well be the reason. I probably will rebuild it from scratch unless somebody does know what that strange set of errors using very complicated blocks of code are doing.

The time when my Raspberry Pi Zero is rebooted is always spot on date and time and I have checked that many times using my Putty. So it is probably getting time from the Internet as it has an IP address, of course, that automatically connects to my BT Home Hub when it boots.


Most of my Pi’s update the time pretty quickly. Every once in a while though I get this weird error when I run apt update right after the Pi boots up. Then I notice my Date and Time are way off. If I wait till it syncs and then do the apt update no error.

I waited a week and on 9 May 2020 I totally rebuilt from scratch as you suggested, using a newly purchased 32 GB microSDHC…

I followed all the steps again from the Magpi 92 article on pp 66-69.that I used before.
I also ensured after internet installation of the full version of Raspian Buster. that I also then ran sudo apt update to ensure all up to date.

I also enabled SSH and i2c on my just built microSDHC card.

Everything went as planned before and I had to modify the app.py file as reported by the fact that an error appeared stating that i2C wasn’t working when running:
cd EnviroPlusWeb
sudo python3 app.py

I found that Python needed I2c to be installed on the Raspberry Pi.
I used this article on the web for guidance::

It stated do this, which I did:

Once the system is up-to-date, start the installation with the tools to communicate with i2c devices in Python (python-smbus) and diagnostic tools (i2c-tools).
sudo apt-get install -y python-smbus i2c-tools

On starting to run app.py an error appeared saying libffi not present.

I found this in a column, alphanumeric, wrote

sudo apt-get install libffi-dev

Everything then worked when running.

Good initially when running the key command:
cd EnviroPlusWeb
sudo python3 app.py

The graph display on a laptop when connecting to the IP address of Enviro+ system was perfect.

I then set up crontab using:
crontab -e
adding just
@reboot sudo python3 /home/pi/EnviroPlusWeb/app.py &

It worked perfectly and that meant I could connect to the Enviro+ system whenever I wanted to using putty and then cause a reboot of Enviro+ system if wanted… Now, my laptop was not needed to be connected to the Enviro+.to keep the Enviro+ running as always was the case before.

Now without having to use putty I could just use a laptop to connect to the Enviro+ system using its IP address and that displayed the real-time graphical diagram. Perfect.

I was impressed.

Then a serious problem happened.

A chronic feature after shutting down properly and rebooting the Enviro+.

Problem below continues after every multiple reboots tested today.:
Without crontab in place, it starts up correctly using putty from a laptop.
However ,the Enviro+ graphic diagram doesn’t get displayed at all from any laptop. It just shows the top LH corner only showing:

Graph 5 minutes
Fan 100

No graphics whatsoever are displayed.

I removed the crontab that was being used and still using putty in the laptop to reboot the Enviro+ which it did but the Enviro+ graphics diagram still won’t display.

In all cases the LCD display on Enviro+ is working perfectly as normal, but the display on a laptop screen is just basic Enviro+

Any ideas from anyone about what might cause that display not to be shown?


There is a “wait for network” option in Raspberry Pi Configuration. You could try enabling that in case its a network not ready issue. Just a guess on my part.
I have an Internet radio setup with a Pi Zero that would sometimes not stream automatically on boot up. WIFI was slow to connect and wasn’t ready when VLC Radio went looking for it. Once I ticked that option all was fine again. It starts up on my preferred station and plays my tunes without issue.

I set up your suggestion just 30 mins ago to conduct the “wait for network” option in Raspberry Pi Configuration and I rebooted the Raspberry Pi.

Absolutely no problem in doing Putty from my laptop to the Pi Zero almost 30 secs or so - exactly as it was before I installed “the wait for network”.

Clearly the link from my laptop is hitting the app.py on the Raspberry Pi since if app.py is not running that simple bit of the Enviro+ display doesn’t get shown as I discovered before and now… If app.py is not running the Internet Explorer connection from my laptop to the Raspberry Pi internet address gets the message:
Hmmm…can’t reach this page

Thanks, alphanumeric, for offering things to check all the time.

Not sure if this will help you but…
I have being running my modified version of app.py for several weeks and never need cron.
I haven’t read all the thread but if you cloned EnviroPlusWeb from GitHub it would have come with install-service.sh so you should be able to run

sudo systemctl start enviroplus_web

And it will run in background, no laptop ‘connection’ required.
Replace start with status or stop to provide the other actions.

Interesting to see what you have done. I certainly will keep a record of it but I don’t want to use now since after completely rebuilding EnviroPlus Web from scratch everything works and that standard crontab given in Magpi 92, page 69 also works and I have tested sudo reboot of it and it always works.

If you want to see everything about my full explanation that I wrote last Friday in: EnviroPlus Assistance

Many thanks