0

I just started learning how to use the raspberry pi. One of the first issues I encountered with the raspberry pi was that the most common library (the one that all tutorials use) RPi.GPIO does not work with the raspberry pi 5 due to hardware changes. This means I have to use a library that supports the new hardware like the gpiod or GPIOZERO. I was told to use GPIOZERO as it is more begginer friendly and has more features like pwm and built in pull up resistors.

Upon trying to turn on a led with the GPIOZERO library, I encountered an issue where my code wasn’t making the gpio pin output any voltage (I tested this with a multimeter). Here is my python code:

from gpiozero import LED
led = LED(17)
led.on()

When I try to use the gpiod library it works perfectly fine: Here is the code:

import gpiod
LED_PIN = 17
chip = gpiod.Chip('gpiochip4')
led_line = chip.get_line(LED_PIN)
led_line.request(consumer="LED", type=gpiod.LINE_REQ_DIR_OUT)
led_line.set_value(1)

The reason why I don't want to use the gpiod library in the long term is that I'm pretty sure it doesn't support internal pull up resistors or pwm.

I wonder if it is an issue with the new chip system on the raspberry pi 5. Does anyone know how I can fix this?

I tried switching around the gpio pin from 17 to 11, nothing changed, I've tried researching if it might be something to do with the new chip system, but I found that this exact code and wiring worked for other Pi 5 users.

asked Aug 2, 2024 at 22:20

1 Answer 1

0

You provide insufficient detail, BUT if the gpiozero code listed is the complete program it is probably doing EXACTLY what you told it to do.

The code will run, turn your LED ON, and immediately exit, restoring the pins to the initial state and exiting. The LED will light for less than a microsecond.

Include a sleep at the end or a pause.

Note gpiozero uses lgpio as its underlying library. This is reasonably documented and behaves more like the older libraries.

NONE of the existing libraries support hardware PWM, only software PWM (at least I am unaware of any). libgpiod ONLY supports GPIO functionality it was never intended to support other functions.

answered Aug 2, 2024 at 23:02
1
  • Thank you for your response. I appreciate the assistance with my question. My code is now working perfectly, and I am very grateful for your help. Commented Aug 3, 2024 at 2:07

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.