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.
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?
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!
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.
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:
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:
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 @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?
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.
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.
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 :
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).
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.
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?