GPIO input... stuck / not resetting?


I use following setup:
GPIO in is BCM pin 17 / board pin 11
VCC is 3,3v

I made this super basic script that says if it’s 1 or 0 when ran:

#Pin Definitions
input_pin = 17 # BCM pin 17, BOARD pin 11

def main():
GPIO.setup(input_pin, GPIO.IN) # set pin as an input pin
value = GPIO.input(input_pin)

the script seems to work only once, for example:

When the switch is open I get 0
When I then close the switch I get 1
If I then open the switch again it stays at 1 instead of going back to 0

Why wouldn’t it go back to 0?

Am I missing something?

The goal is being able to read if the circuit is open or closed.

Hi allbyoneguy,

How is the result if you read the node through sysfs? Do you also see 1 with open circuit?

Hi Wayne, when I cat the value of gpio50 it behaves in the same way, it gets stuck at 1 after disconnecting the 3.3v
it works again (once) after a reboot

1 Like

Could you share the step you are using now to read this input?
Could you wait for few second and see if the result would become 0?

Hi Wayne,

I do the following steps:
cd /sys/class/gpio
echo 50 > export
cd /sys/class/gpio/gpio50
echo “in” > direction
cat value

Even after a few minutes it’s still at 1

Ok I see. I will check this issue.

BTW, you are at least able to see the toggle from 0 -> 1 when switch is closed, right?

yes, that works once after each reboot. thanks!

Hi, can you tell the physical pin number of the connector? Is it pin 11 of J41 or others?

It’s pin number 11 of j41 indeed

Pin 11 of J41 is UART2_RTS not GPIO pin.

According to the pinout sheet it shows as sysfs gpio50, and I can interface with it that way as well, so why wouldn’t I be able to use it?

Did you set this pin (pin207) to GPIO type in pinmux sheet?

Also, there is a level shift (TXB0108) between pin of J41 and pin of module connector. If pullup or pulldown resistors are connected externally to the data I/Os of level shift, their values must be kept higher than 50 kΩ. You can try another R1 accordingly.

I’m not 100% sure we’re talking about the same thing, where would pin 207 be?

pin 207 of module connector is connected to pin 11 of J41. Please ignore the prior 50 kΩ thing, it is for output load.

1 Like

Did you try other pins of J41, such as pin 31 and 33? Did you measure the voltage on the pin when switch on/off to confirm the real level of pin?

I’ll try the same on pin 31 and measure the voltage and let you know. thanks so far!

Just wanted to add that this may be similar to something I’m experiencing with a rotary encoder. I have a separate thread for my test details as I’ve been trying to debug. (Rotary Encoder - GPIO interrupts failing to fire.)

Two circled areas are signal paths to GPIO inputs. When the encoder is turned, the switches shut in sequence and pull the logic low. On first read (before turning), both show values of 1 (tested both in python with Jetson.GPIO as well as through /sys/class/gpiox/value). After turning, the value is 0. The switch immediately opens, but the value remains 0. Tested on board pins 29/31 and 33/35. Configured with pullups. Also tested with a Raspberry Pi 3 B+ and an Odroid C2 - it works perfectly on the two other SBCs and reports the high and low logic levels and the associated edges without issue.

I tested this on pin31 as GPIO:
gate open: 0v measured and input value= 0
gate closed: ~3.27v measured and input value= 1
gate open again: 0v measured and input value= 1
gate closed again: ~3.27v measured and input value= 1

Hi allbyoneguy,

What is the result of this pin if you read from debug node? Is it correct or not?

sudo -s
cat /sys/kernel/debug/gpio