waveform80 / rpi-lgpio

A compatibility shim for lgpio emulating the RPi.GPIO API
https://rpi-lgpio.readthedocs.io/
Other
13 stars 8 forks source link

For which Raspi versions can the rpi-lgpio module be used? #6

Closed ullix closed 7 months ago

ullix commented 8 months ago

I am using rpi-lgpio on a Raspi 5 and all works well. But I don't find a way to use it on a Raspi 3. It fails with message "No module named 'RPi'".

Does rpi-lgpio support any older versions of Raspi? Which ones from the Raspi 1,2,3,4, and Zeros?

waveform80 commented 7 months ago

rpi-lgpio should work on any model of the Pi that supports "new-style revision codes", and that's only because I was too lazy to implement support for the old-style ones. Specifically that means it should work out of the box on anything beyond the original model 1's (the 2, 3, 4, 5, and Zeros should all be fine).

You can also force rpi-lgpio to use a specific revision code via the RPI_LGPIO_REVISION env-var so technically it can be made to work on any board that has a compatible GPIO configuration to the revision code you specify.

On your Pi 3 what OS are you running, and how have you attempted to install rpi-lgpio?

ullix commented 7 months ago

How would I know whether my Pi that supports "new-style revision codes"?

I made a work-around by checking the Raspi version and loading either the old one or the new one. Not a nice solution, but at least working.

waveform80 commented 7 months ago

How would I know whether my Pi that supports "new-style revision codes"?

$ grep "^Revision" /proc/cpuinfo
Revision        : c04170

If the revision code is four characters, e.g. 0004 then it's old-style. This really only applies to the original model 1's (including the B+, A+, and CM1); everything since then uses the new-style which is six characters as shown above. Even then, as noted, you can use rpi-lgpio on old-style boards, you just need to "fake" the revision code with RPI_LGPIO_REVISION.

The only case in which you should be seeing "No module named 'RPi'" is if the module is not available in the environment you're trying to import it from (whether that's the system environment or a venv).