How to test GPIO with Jetson GPIO Library
|
Introduction
The following document will show an example to test a GPIO using the Jetson GPIO Library from NVIDIA:
Jetson GPIO Library
This is Python library that allows to control GPIOs on Jetson development board containing a 40 pin header. You can find it here with the instructions to install and test.
Example
Here is a simple application which set the GPIO output to HIGH for 10 seconds, then set the output to LOW for another 10 seconds. It was tested on Jetson ORIN
The GPIO used in this case was the pin 40, you can follow this guide to review the 40 header pinout from Jetson ORIN board. As you can see pin 40 is used by I2S_SDOUT signal.
import Jetson.GPIO as GPIO import time # Test pin 40: I2S_SDOUT output_pin = 40 def main(): GPIO.setmode(GPIO.BOARD) GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.LOW) print("--> GPIO set to High") GPIO.output(output_pin, GPIO.HIGH) time.sleep(10) print("--> GPIO set to Low") GPIO.output(output_pin, GPIO.LOW) time.sleep(10) GPIO.cleanup() if __name__ == '__main__': main()
- Run the application:
python3 basic_output_test.py
- When you see the message about the GPIO was set to HIGH, you can review GPIO debug to make sure that GPIO state is HIGH:
nvidia@orin:~$ sudo cat /sys/kernel/debug/gpio | grep -i sysfs gpio-399 (PI.00 |sysfs ) out hi
- Here you can also measure the voltage on pin 40, it should be 3.3 V
- Then, when the message shows that the GPIO is set to LOW, check the GPIO debug again:
nvidia@orin:~$ sudo cat /sys/kernel/debug/gpio | grep -i sysfs gpio-399 (PI.00 |sysfs ) out lo
- In case you case you would like to review more information about the GPIO definitions for your target Jetson, you can open the gpio_pin_data.py file where shows the signal name, the GPIO controller, etc.
For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.
Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.