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.

asked Mar 29, 2024 at 18:10
10
  • Include simple code examples, not links in your question. Commented Mar 29, 2024 at 18:19
  • A code example is exactly what I'm asking for. Commented Mar 29, 2024 at 18:36
  • Include examples of what is not working, I can't find what your referring to in the links. Commented Mar 29, 2024 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. Commented Mar 29, 2024 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. Commented Mar 29, 2024 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

answered Mar 30, 2024 at 0:11
1
  • 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. =) Commented Apr 1, 2024 at 15:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.