GPIO output on RPI5 not working

December 18, 2023, 19:49

josephfourier

I've been trying to connect and control an LED on a new raspberry PI 5 using GPIO and a breadboard. I connected the LED with a 220Ω resistor and I'm quite sure it's not burnt, connecting it to a 5V or 3.3V pin lights it up properly. When I try to connect it to a GPIO pin, it's either preset to either high or low and stuck there, no matter what. I tried using the gpiod package on python3, some libraries in rust, and the gpioset command on the command line, using gpioinfo and gpiofind to find the correct pin numbers. I also checked to make sure I have the correct permissions, and ran those with sudo. The LED stays on or off no matter what. In GPIO18 for example it was consistently off, in GPIO21 it was consistently on. I can't fathom what I'm doing wrong.

k9t33n

try gpiozero, its so much easier to use

k9t33n

then tell me what script your using

josephfourier

I'm pretty positive I tried that library too

k9t33n

do you have remote gpio on? i remember someone else had this problem

josephfourier

I went on raspi-config and I turned it off, but no difference

aq4152

Do you have the code?

josephfourier

attempt 1:
python
import gpiod
import time

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)
try:
        while True:
                led_line.set_value(1)
                time.sleep(1)
                led_line.set_value(0)
                time.sleep(1)
finally:
        led_line.release()
attempt 2:
python
from gpiozero import LED
from time import sleep

led = LED(17)

while True:
    led.on()
    print("change")
    sleep(1)
    led.off()
    print("change")
    sleep(1)

josephfourier

And this is my wiring. The LED stays on for the whole time, even when I run the python files

aq4152

Does the print statement show up?

josephfourier

Yes, it does

aq4152

Hmm... Sorry, I don't have a clue. The code looks correct to me, and the print statement proved the loop is running. I best guess is there is some setting somewhere that needs to be tweaked...

josephfourier

I just bought my first raspberry, if it's faulty I'm in deep shit XD

aq4152

I'm not too familar with python programming. But just want to make sure sleep(1) is one second?

josephfourier

Yes, it is

aq4152

Another possibility is that the GPIO packages don't support pi 5 yet...?

josephfourier

The tutorials online suggest those python packages. I also tried using gpioset. Everything came preinstalled in raspberry pi OS

aq4152

yeah. I was looking at gpiod package. It looks like it supports pi 5

aq4152

here is a tutorial, https://www.tomshardware.com/how-to/control-raspberry-pi-5-gpio-with-python-3 looks like you are following it

josephfourier

Yep, that's exactly the tutorial I'm following

aq4152

I noticed you are using an adapter instead of directly connecting it to pi 5. Maybe the adapter is designed for a different pi version, and the pins may not reflect the new pinouts?

aq4152

Try connect the led directly to the pi, if you can

josephfourier

I tried connecting directly too. It made no difference

josephfourier

I was at a workshop in my university trying all those things. Everybody got an rPI 4 so they kinda left me behind

aq4152

aq4152

Connect directly to GPIO 17 of the pi 5, and see if it works...

aq4152

It's really easy to plug into the wrong pin. I have done this more than a few times and end up wasting a lot of time.

josephfourier

I'm pretty sure I connected correctly as you can see

josephfourier

Ah directly

aq4152

Yup, the adapter could be lying to you

josephfourier

Fucking hell that adaptor was faulty indeed

josephfourier

You sir are an angel thank you

aq4152

Glad I could help 😄

aq4152

The adapter was probably for pi 4 or some older models, and has different pin outs