0

I am attempting to rewrite a bit of code that used gpiozero for a Raspberry Pi that no longer works on the Raspberry Pi 5 due to the GPIO changes in the Raspi 5. I need it to be backwards compatible to possibly run on our Raspi 2's that we were using, so the gpiod lib seems like the best choice. However, example code here (specifically using the get line value example) and here but the ACTIVE value doesn't appear to change when I push the button. These are the same buttons that worked using gpiozero, so I'm assuming I'm doing something wrong in the api implementation. However, I have no baseline to check from because I cannot find any working example code that uses a modern implementation of this library. Maybe it doesn't exist? That is my question:

Does anyone know of any or could anyone write working example code for a button that works with the modern gpiod library that I could reference? If not, could anyone suggest where else I might look besides the "active" value of a pin? Maybe I'm looking at the wrong value and just don't know it?

Would really appreciate any direction that anyone would be willing to offer in this case.

Thank you in advance!

EDIT: I did get my LED's switched over, so I know at least what I'm doing with LED's is working. Thanks to the example LED code here for pointing the way. Buttons don't seem to work this way, however.

11
  • Include simple code examples, not links in your question.
    – CoderMike
    Commented Mar 29 at 18:19
  • A code example is exactly what I'm asking for.
    – utdream
    Commented Mar 29 at 18:36
  • Include examples of what is not working, I can't find what your referring to in the links.
    – CoderMike
    Commented Mar 29 at 18:52
  • 1
    If you have the latest gpiozero (v2.0.1) and use the default library lgpio it should work. If you have code you claim doesn't work post with diagnostics.
    – Milliways
    Commented Mar 29 at 20:58
  • 1
    This question could be vastly simplified by simply editing the question to add a copy of the code that does not work. After all the comments and discussion it seems that's not going to happen. Consequently, I’m voting to close this question.
    – Seamus
    Commented Mar 29 at 23:35

1 Answer 1

1

I have some code using gpiod.

See https://raspberrypi.stackexchange.com/a/145544/8697

gpiod is poorly documented so it is not easy to use but my test worked but not fully tested on Pi5

2
  • Thank you. Your helpfulness is greatly appreciated. I'll keep hacking away at this and your example code will be very useful in my testing. I will respond with working code if I can figure it out. =)
    – utdream
    Commented Apr 1 at 15:57
  • The libgpiod example code looks easier to read than your example. And the gpiod module functions are all documented - you can readily pull them out with pydoc as noted here. Commented Apr 2 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.