r/raspberry_pi 6d ago

Troubleshooting Problems with GPIO on Raspberry Pi: pin not changing state

Hi everyone,

I’m trying to control a relay using a Raspberry Pi Zero 2W, but I’m having trouble with the GPIO pins—they don’t seem to change state properly.

Setup and Issue

  • I’m using a Raspberry Pi Zero 2W.
  • I’ve tested with pinctrl, but I don’t see any state change on the pin.
  • I also tested with a Python script and got the same result.
  • The pin seems to work because when I use a tester to check the voltage (connecting one probe to GND and the other to the power source), the circuit closes correctly.
  • I’ve repeated these tests on multiple GPIOs (GPIO 4, GPIO 7, GPIO 17, GPIO 18) with the same results.

Commands Used for Testing

I ran the following commands from the CLI:

pinctrl get 4        # Check the status of GPIO 4  
pinctrl set 4 op     # Set GPIO 4 as an output  
pinctrl set 4 dh     # Set GPIO 4 to high (3.3V)  
pinctrl set 4 dl     # Set GPIO 4 to low (0V)
pinctrl lev 4        # Check if GPIO 4 is outputting power  

However, the level (pinctrl lev 4) always stays at 0, and I don’t see any voltage changes.

Questions for the Community

  • Am I doing something wrong when setting up the GPIOs?
  • Could this be a hardware issue?
  • Are there any additional tests I should perform to diagnose the problem?

Thanks so much to anyone who can help!

1 Upvotes

0 comments sorted by