The I2C pin of the Jetson Orin NX is shown in the figure, and the I2C service needs to be enabled before use.
First, install I2Ctool and input the terminal:
sudo apt-get update
sudo apt-get install -y i2c-tools
Check installation status, terminal input:
xxxxxxxxxx
apt-cache policy i2c-tools
The following output indicates successful installation
xxxxxxxxxx
i2c-tools:
was installed:4.0-2
candidate: 4.0-2
Version List:
*** 4.0-2 500
500 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 Packages
100 /var/lib/dpkg/status
Scan all i2c devices on a certain bus and print out the device i2c bus address. For example, if a device with address 0x0f is mounted on the I2C pin, the corresponding device I2C address will be displayed
xxxxxxxxxx
sudo i2cdetect -y -r -a 7
Smbus is a Python library. If smbus is not installed, the terminal input:
xsudo apt-get update
sudo apt-get install -y python3-smbus
The Smbus protocol has many related library functions that can be used for I2C communication
The following is a program case of our store's OLED module. If testing is needed, the corresponding OLED module should be used (you can choose to change the OLED module in our store)
wire:
Jetson Orin NX pin 3(SDA)→oled SDA
Jetson Orin NX pin 5(SCL)→oled SCL
Jetson Orin NX pin 2(5V)→oled VCC
Jetson Orin NX pin 6(GND)→oled GND
Import Adafruit_ SSD1306 library This is the OLED library, and you need to download this library when using your own image
xxxxxxxxxx
pip install Adafruit_SSD1306
init oled:
Afterwards, if you are interested in reading some basic information functions of nano, you can go to this py file to learn more, which includes obtaining local IP, tf card space usage, memory usage, system time, and other information.
Terminal input:
xxxxxxxxxx
cd ~/GPIO_test
sudo python3 test_i2c_oled.py
If it is a self built image, you can find the test in the attachment of the data_ i2c_ Transfer oled.py to Jetson orin nx experimental phenomena: