pimoroni / pms5003-python

Python library for the PMS5003 particulate sensor
MIT License
51 stars 20 forks source link

switch to gpiod broke setup on rpi (zero 2 w) #22

Open DaveNadeau opened 9 months ago

DaveNadeau commented 9 months ago

I have version .5 of this library working on an rpi 4 but I'm doing some testing on an rpi 2 zero w and after downloading v1.0 I'm getting this error with the new call gpiod instead of RpiGPIO (using gpio numbers not header numbers to connect pins):

Traceback (most recent call last): File "/home/weather/pmsTests/pms5003-test.py", line 25, in pms5003 = PMS5003( File "/root/.local/lib/python3.9/site-packages/pms5003/init.py", line 106, in init self._pin_enable = gpiodevice.get_pin(pin_enable, "PMS5003_en", OUTH) File "/root/.local/lib/python3.9/site-packages/gpiodevice/init.py", line 138, in get_pin chip = find_chip_by_pins(pin) File "/root/.local/lib/python3.9/site-packages/gpiodevice/errors.py", line 45, in wrapper errors.append(next(i)) File "/root/.local/lib/python3.9/site-packages/gpiodevice/init.py", line 108, in find_chip_by_pins for pin_id in pins: TypeError: 'int' object is not iterable

DaveNadeau commented 9 months ago

As a temporary fix, I just copied the contents of version .5's init.py over to the new version 1.0 and it runs fine (using RpiGPIO lib).

Gadgetoid commented 4 months ago

I think this has since been fixed to raise a more suitable error, but the TLDR is that supplying pins as numbers is no longer supported.

They must be named by their label, which can be found with:

sudo apt install gpiod
gpioinfo

IE: 22 becomes "GPIO22" and 27 becomes "GPIO27".

eg:

pms5003 = PMS5003(pin_enable="GPIO22", pin_reset="GPIO27")