Issue with Enviro+ with RPi Zero: Display and particles not working

Hello,

some days ago I got the Enviro+ board with the the air quality sensor PMS5003. Unfortunately I cannot get it to work.

I was able to run some of the examples like compensated_temperature.py and similar which show data and work. But it seems anything related to the LCD on the Enviro+ or the particles sensor fails. The error when trying to run lcd.py is this:

Traceback (most recent call last):
  File "/home/filip/Pimoroni/enviroplus/examples/lcd.py", line 20, in <module>
    disp = st7735.ST7735(
  File "/usr/local/lib/python3.9/dist-packages/st7735/__init__.py", line 175, in __init__
    self._dc = gpiodevice.get_pin(dc, "st7735-dc", OUTL)
  File "/usr/local/lib/python3.9/dist-packages/gpiodevice/__init__.py", line 138, in get_pin
    chip = find_chip_by_pins(pin)
  File "/usr/local/lib/python3.9/dist-packages/gpiodevice/errors.py", line 45, in wrapper
    errors.append(next(i))
  File "/usr/local/lib/python3.9/dist-packages/gpiodevice/__init__.py", line 108, in find_chip_by_pins
    for pin_id in pins:
TypeError: 'int' object is not iterable

So I tried the examples for the st7735 and they end with this error:

Woah there, suitable gpiochip not found!
  ❌  PIN21: not found - /dev/gpiochip0 (pinctrl-bcm2835)!

Which seems like one of the GPIO pins is broken or something?

I haven’t seen the screen light up (not even during the boot) though I am sure that it is supposed to light up when booting.

Since I have Sense Hat also I tried it with my Raspberry Pi Zero (the first gen, integrated WiFi) and haven’t been able to run into any issues using this board. Tried the sensors, the LED matrix…

Is it possible my Enviro+ is defective and I need to have it replaced by the vendor? Or is this just some software glitch?

Unfortunately I don’t have other Pi at hand to try isolating the issue further.

Thanks.

1 Like

I started work on my Enviro+ today and am getting exactly the same error (‘int’ object is not iterable) so it seems unlikely that it’s a hardware fault but more likely a software glitch? Just a guess on my part though. I bought my kit (Pi Zero 2, Enviro+, PM Sensor) back in January 2022 so unless yours have also been sat in a box for 18+ months I guess it’s not a bad batch?

Extra info just in case it helps anyone: I started with an install of Bookworm but found that the github project (GitHub - pimoroni/enviroplus-python: Python library for the Enviro+ environmental monitoring board) hasn’t been upgraded yet so rather than test the branch I started again with Legacy (Bullseye) which has got me this far.

I’ve done a little more digging and whilst I haven’t fixed it yet, I’m pretty sure that the culprit is a change to the st7735 library where they’ve “ported to gpiod/gpiodevice”. If you look at these two changes…

…particularly the second one, you’ll see a whole load of changes to the example code, where numeric pins get swapped out for pin labels, e.g.

backlight=19,

becomes

backlight=“PIN35”,

I think this is what the library is complaining about when it says it can’t iterate over an int, and to get things working again I suspect we’ll need to update the example code (luftdaten.py in my case) to match. I’m probably not going to find some time to try that out until later this week but I’ll report back once I have.

Actually, as a first step, it’s probably worth running some of the examples in the st7735 project, because they’ve already been updated. I’ll let you know how that goes too!

2 Likes

Nice finds! Thanks!

Yea seems like the first step should be fixing the st7735 before attempting to use the screen as part of Envior+.

Will let you know if I discover anything.

I think I found the exact issue we have, it has also fixes by using older versions of st7735 either via commit or pinning the version of the library:

1 Like

Yes! Thank you. I used pip install pms5003==0.0.5 and pip install st7735==0.0.5 and all of the example scripts I’ve tried work! (and the display displays things!).

I feel a bit bad for not trying out the branch and seeing if it fixes things, but it bundles together a whole load of changes by the looks of it, so I’m a bit daunted a the prospect of giving it a go.

Did you do anything else than install these versions? I installed them, pip freeze shows I have these versions and yet the issue remains :(

I didn’t knowingly do anything different! It seems inconceivable that running lcd.py could give you the same error, the code in the st7735 library at that point is completely different

I can only guess that somehow python isn’t picking up the old/overridden dependency. At the risk of sounding daft, have you tried turning it off an on again? fwiw I’m running…

$ python --version
Python 3.9.2

on Legacy Raspberry OS and none of the fancy python venv stuff that I don’t understand anything about.

(It probably doesn’t help in any practical way but fwiw it looks like someone else has also managed to get things working using the pinned versions: PIMORONI ENVIRO indoor monitor not working)

@dantwe mind sharing which package versions are you running?

I thought I’d try to wait for examples to be updated, but still nothing, so I am trying virtual environment and currently have this setup, which fails on a numpy error:

numpy==1.26.2
Pillow==10.1.0
pms5003==0.0.5
pyserial==3.5
spidev==3.6
ST7735==0.0.5

You can list all packages by running pip freeze. Thanks!

This is the numpy problem:

Traceback (most recent call last):
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/core/init.py”, line 24, in
from . import multiarray
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/core/multiarray.py”, line 10, in
from . import overrides
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/core/overrides.py”, line 8, in
from numpy.core._multiarray_umath import (
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/init.py”, line 130, in
from numpy.config import show as show_config
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/config.py”, line 4, in
from numpy.core._multiarray_umath import (
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/core/init.py”, line 50, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.9 from “/home/filip/Pimoroni/st7735/examples/venv/bin/python3”
  • The NumPy version is: “1.26.2”

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libopenblas.so.0: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/filip/Pimoroni/st7735/examples/shapes_mine.py”, line 23, in
import ST7735
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/ST7735/init.py”, line 23, in
import numpy as np
File “/home/filip/Pimoroni/st7735/examples/venv/lib/python3.9/site-packages/numpy/init.py”, line 135, in
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.

hi, no worries, here’s the entire output of my pip freeze

ads1015==1.0.0
arandr==0.1.10
astral==3.2
astroid==2.5.1
asttokens==2.0.4
automationhat==0.2.0
beautifulsoup4==4.9.3
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2020.6.20
cffi==1.14.5
chardet==4.0.0
click==7.1.2
colorama==0.4.4
colorzero==1.1
configparser==6.0.0
cryptography==3.3.2
cupshelpers==1.0
dbus-python==1.2.16
distro==1.5.0
docutils==0.16
drumhat==0.1.0
envirophat==1.0.0
enviroplus==0.0.6
ExplorerHAT==0.4.2
Flask==1.1.2
font-roboto==0.0.1
fonts==0.0.3
fourletterphat==0.1.0
gpiod==2.1.3
gpiodevice==0.0.2
gpiozero==1.6.2
html5lib==1.1
i2cdevice==1.0.0
idna==2.10
isort==5.6.4
itsdangerous==1.1.0
jedi==0.18.0
Jinja2==2.11.3
lazy-object-proxy==0.0.0
logilab-common==1.8.1
ltr559==1.0.0
lxml==4.6.3
MarkupSafe==1.1.1
mccabe==0.6.1
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.3
mypy==0.812
mypy-extensions==0.4.3
numpy==1.19.5
oauthlib==3.1.0
paho-mqtt==1.6.1
pantilthat==0.0.7
parso==0.8.1
pexpect==4.8.0
pgzero==1.2
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
picamera2==0.3.12
pidng==4.0.9
piexif==1.1.3
piglow==1.2.5
pigpio==1.78
Pillow==8.1.2
pimoroni-bme280==1.0.0
ply==3.11
pms5003==0.0.5
psutil==5.8.0
pycairo==1.16.2
pycparser==2.20
pycups==2.0.1
pygame==1.9.6
Pygments==2.7.1
PyGObject==3.38.0
pyinotify==0.9.6
PyJWT==1.7.1
pylint==2.7.2
PyOpenGL==3.1.5
pyOpenSSL==20.0.1
PyQt5==5.15.2
PyQt5-sip==12.8.1
pyserial==3.5b0
pysmbc==1.0.23
python-apt==2.2.1
python-prctl==1.7
pytz==2023.3.post1
rainbowhat==0.1.0
reportlab==3.5.59
requests==2.25.1
requests-oauthlib==1.0.0
responses==0.12.1
roman==2.0.0
RPi.GPIO==0.7.0
RTIMULib==7.2.1
scrollphat==0.0.7
scrollphathd==1.2.1
Send2Trash==1.6.0b1
sense-hat==2.6.0
simplejpeg==1.6.4
simplejson==3.17.2
six==1.16.0
skywriter==0.0.7
smbus2==0.4.3
sn3218==1.2.7
sounddevice==0.4.6
soupsieve==2.2.1
spidev==3.5
ssh-import-id==5.10
ST7735==0.0.5
thonny==4.0.1
toml==0.10.1
touchphat==0.0.1
twython==3.8.2
typed-ast==1.4.2
typing-extensions==3.7.4.3
unicornhathd==0.0.4
urllib3==1.26.5
v4l2-python3==0.3.2
webencodings==0.5.1
Werkzeug==1.0.1
wrapt==1.12.1

Hi @nemecek_f @dantwe – Have you by chance figured out any explanation to these error messages?

The flavor of error message that I’m getting is as follows:

Woah there, suitable gpiochip not found!
⚠️ /dev/gpiochip0: 9 is an int and has been skipped, did you mean “PIN9” or “GPIO9”?

I’m not overly technical, but this is the fourth Envrio+ / Raspberry Pi sensor I’ve built over the last couple of years. I’ve never encountered an error like this before while following the setup tutorial posted here by Pimoroni.

My guess is that something has broken / changed on the Pimoroni side of the code and really hope an update comes through soon. Was curious if you heard anything?

Thanks!

hi @sean_42 , yes those are exactly the same errors, have you tried running pip install pms5003==0.0.5 and pip install st7735==0.0.5 ? The test scripts should work once you’ve set those dependencies to earlier versions.

3 Likes

I am still stuck and honestly pretty tired trying to fix it so I will probably wait for the update.

I currently cannot get over the Numpy error. Tried the code from the pull request, but that fails during installation because of permission issues and when I run it as sudo the script says it shouldn’t be run as sudo and exists early.

Hi @dantwe and @nemecek_f – thank you so much for your replies. I tried the pip commands recommended by @dantwe and was able to get the Luftdaten script up and running. The one wrinkle is that I’m not able to execute the “Luftdaten.py” script by double-clicking “Execute in Terminal” via the File Manager (the terminal window opens for a second, then crashes), but if I manually run it using Terminal (cd enviroplus-python/examples, python luftdaten.py) it opens just fine. So who knows? But end of story, I have my new Enviro+ monitor up and running on the roof.

Thanks again for your help and good luck!

With the latest version of the python code, I think I have a solution for the examples, which is relatively simple to update:
Where the display for st7735 is setup, change :

disp = st7735.ST7735(
    port=0,
    cs=1,
    dc=9,
    backlight=12,
    rotation=270,
    spi_speed_hz=10000000
)

to

disp = st7735.ST7735(
    port=0,
    cs=1,
    dc="9",
    backlight="12",
    rotation=270,
    spi_speed_hz=10000000
)

The change to gpiodevice python library appears to have changed the expected type of argument (string from integer), but the value remains the same. I tried PIN and GPIO values, but neither of those worked, because the gpiod still expects a numeric value and has also been updated: Pypi gpiod (at time of writing V2.1.3).

This impacts any example script that uses st7735 and even the examples there also need to be updated. Reference change in gpiodevice Change to raise error if pin is passed as integer

1 Like

I’m having similar issues, I’ve setup a pi4 with the latest raspbian. For some reason I’ve had to setup the library using a virtual environment as the ./install.sh didn’t seem to work out of the box, it ran but didn’t install the pre-reqs. I’ve half fixed the tips posted in this thread, but a lot of the examples have various errors relating to the libraries e.g. Python pillow/PIL doesn't recognize the attribute "textsize" of the object "imagedraw" - Stack Overflow . I’ll see if I can get it all fixed.

A quick update, everything seems to work as expected using a combination of bullseye, the installer script and the pinned library versions mentioned earlier.

Thanks so much! This actually worked. For example for the gif.py example code.

So that is the LCD working, but not the rest :D

Traceback (most recent call last):
File “/home/filip/Pimoroni/enviroplus/examples/particulates.py”, line 24, in
readings = pms5003.read()
File “/home/filip/.local/lib/python3.9/site-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

Seems there is similar PINs issue with the PMS5003 library dammit.

So I finally got the PMS5003 working on my Zero W.
I did a clean install of RPiOS 11 (bullseye) and installed the enviroplus-python package.
Then I uninstalled the pms5003-0.0.5 package and installed pms5003-1.0.0 instead, along with two changes I had to make:
1.) Set ‘enable_uart=1’ in /boot/config.txt
2.) Modify _ _ init _ _.py in the pms5003 package and add a row for “Raspberry Pi Zero W” in the ‘PLATFORMS’ dict. Just copy the settings that the Pi 4 uses.

Try it out and let me know if you run into any issues.

Anyone from the Pimorino crew which can confirm my findings?

1 Like