Adding buttons to Jetson Nano

I am struggling with this and am hoping someone can tell me how to make it work. I am trying to set up three buttons on the Jetson Nano and to respond to the GPIO.event_detect GPIO.FALLING event.

I have attached my circuit diagram. I have tried many pins - both those labelled High and Low on https://devtalk.nvidia.com/default/topic/1055269/jetson-nano/gpio-button-seems-to-latch-maybe-wrong-resistor-value-but-unsure-of-cause/post/5355757/#5355757 (including 12,16,18,21,24,26,28,31).

The buttons work for a while but then stop. My code does not break so I can’t figure out how to debug it - it just doesn’t respond to the buttons. All tests with a multimeter suggest that the circuit works. I have tried pullup resistors of 4.7k, 1k and 100 ohm but get very similar results.

I am a novice on the hardware side of things and just don’t know what to do next in order to troubleshoot. This seemed like a very achievable project - so if someone can help, it would be very kind.

Thanks.

Code:

import RPi.GPIO as GPIO
but_pin1=18
but_pin2=31
but_pin3=21

def button1(channel):
print(‘button1’)
#- etc
def button2(channel):
print(‘button2’)
#- etc
def button3(channel):
print(‘button3’)
#- etc

GPIO.setmode(GPIO.BOARD)
GPIO.setup(but_pin1, GPIO.IN)
GPIO.setup(but_pin2, GPIO.IN)
GPIO.setup(but_pin3, GPIO.IN)

GPIO.add_event_detect(but_pin1, GPIO.FALLING, callback=button1, bouncetime=10)
GPIO.add_event_detect(but_pin2, GPIO.FALLING, callback=button2, bouncetime=10)
GPIO.add_event_detect(but_pin3, GPIO.FALLING, callback=button3, bouncetime=10)

message=input(“Press enter to stop”)
GPIO.cleanup()

Hi walterfms2i,

Are you using pin 18/31/21 which are corresponding to gpio15/gpio200/gpio17?

If so, could you firstly check if the pinmux is correct that all these 3 pins are set to GPIO?

Please go to /proc/device-tree/pinmux@700008d4/common/

and use command -> xxd nvidia,function to see if the value is rsvd.

If all these 3 are set to gpio, please try the method(“Software” section) in first link and see if multimeter can see the output.

links:
https://www.jetsonhacks.com/2019/06/07/jetson-nano-gpio/
https://www.jetsonhacks.com/nvidia-jetson-nano-j41-header-pinout/ -> pin refernce

Thank you for your help. I’m out of town for a few days but will get back to you at the weekend. Thank you again.

Hi Wayne, thanks for your help - the pins are set to either rsvd1 or rsvd2:

Board#   sysfs pin#    dev-tree-name     nvidia,function
pin18    gpio15        spi2_cs0_pb7      rsvd2.
pin31    gpio200       pz0               rsvd1.
pin21    gpio17        spi1_miso_pc1     rsvd1.

I followed the software section in the recommended Jetson Hacks page (link above) with the led circuit on pins 18, 31, and 21 and all leds lit as they were supposed to.

I checked my button circuit with the multimeter and it showed 3.3V between ground and the output to the pin going to zero when the button was pressed and then back to 3.3V on release. The script responded to the GPIO.FALLING events for a while (10-30 seconds) and then stopped detecting the event. The script did not crash. The circuit continued to show the same voltage drop.

How long the circuit works seems to be more a function of time than of how often the buttons are pressed but it is not consistent. Because there is no error, I don’t know how to debug the issue. Any further help will wonderful.

Thanks

button circuit with the multimeter and it showed 3.3V between ground and the output to the pin going to zero when the button was pressed and then back to 3.3V on release.

It is the expected behavior, right?

The script responded to the GPIO.FALLING events for a while (10-30 seconds) and then stopped detecting the event. The script did not crash. The circuit continued to show the same voltage drop.

Do you mean the script suddenly cannot detect anything but the gpio still has activity(if pressing button) or even the gpio activity is gone?