Hardware Library Configuration

Jetson.GPIO - Linux for Tegra

1. Introduction

The Jetson Orin NX, Jetson Orin Nano, and Jetson Nano development boards contain a 40-pin GPIO header similar to the 40-pin header in the Raspberry Pi. The digital inputs and outputs of these GPIOs can be controlled using the Python library provided in the Jetson GPIO Library package. This library has the same API as the Raspberry Pi's RPi.GPIO library in order to provide an easy way to move applications running on the Raspberry Pi to the Jetson board.

In addition to this document, the Jetson GPIO Library package also contains the following:

  1. The lib/python/ subdirectory contains the Python modules that implement all of the library functionality. The gpio.py module is the main component that will be imported into the application and provides the required APIs. The gpio_event.py and gpio_pin_data.py modules are used by the gpio.py module and cannot be imported directly into the application.
  2. The samples/ subdirectory contains sample applications to help you get familiar with the library API and get started using applications. The simple_input.py and simple_output.py applications show how to perform read and write operations on GPIO pins, respectively, while button_led.py, button_event.py, and button_interrupt.py show how to use a button press to blink an LED using busy wait, blocking wait, and interrupt callbacks, respectively.

This document will describe what is included in the Jetson GPIO library package, how to configure your system, and run the provided sample applications and library API. Here we briefly introduce how to use this library about Jetson.GPIO, here are detailed instructions: https://pypi.org/project/Jetson.GPIO/ or https://github.com/NVIDIA/jetson-gpio

2. Pin diagram

GPIO and BCM comparison table image-2023040400001.png

3. Environment configuration

Environment configuration

  1. Download jetson-gpio: git clone https://github.com/NVIDIA/jetson-gpio image-2023040400002.png
  2. Move the downloaded file to the directory: /opt/nvidia If this library exists in your directory, we need to back up the original directory as follows: image-2023040400003.png

Then put the downloaded file in the opt/nvidia/ directory. Because the author puts the folder in the path ~/ and is currently in opt/nvidia/, you can execute the following command to move the folder sudo mv ~/jetson-gpio ./ image-2023040400004.png

  1. Install the pip3 tool: sudo apt-get install python3-pip
  2. Enter the jetson-gpio library folder and install the library. cd /opt/nvidia/jetson-gpio sudo python3 setup.py install image-2023040400005.png
  3. Before use, you also need to create a gpio group, add your current account to this group, and grant usage permissions sudo groupadd -f -r gpio sudo usermod -a -G gpio user_name image-2023040400006.png

sudo cp /opt/nvidia/jetson-gpio/lib/python/Jetson/GPIO/99-gpio.rules /etc/udev/rules.d/ In order for the new rules to take effect, you need to reboot or reload the udev rules by running the following command sudo udevadm control --reload-rules && sudo udevadm trigger Note: user_name is your username, for example jetson

image-2023040400007.png