Setting up I2c on the Jetson Orin Nano

Is there any documentation showing how to set up I2C communications on the Jetson Nano Orin so that it can be accessed in a python program? There are many examples I can find for the original Jetson Nano Developpers Kit, but I do not think the instructions that are valid for the Nano can be used on the Orin Nano without some modifications.

My goal is fairly simple - I am trying to set up a Pan-and-Tilt servo mechanism with a PCA9685 board to run on the Jetson Orin Nano Developers Kit. If the setup for doing this in a python program is already documented somewhere, please direct me to the documentation. For reference, I am using a Nvidia carrier board and Jetpack 5.1.1.

Thanks,
stvenmobile

You can reference to below to know the i2c bus # and suppose the python should have parameter to input bus #

In order to access the GPIO pins on the Jetson Nano you are instructed to follow the instructions below. Note the last two steps. I do not see the file that is supposed to be copied anywhere on the Jetson Orin Nano, so I don’t understand how the GPIO access rules are supposed to be set. Are these instructions no longer required on the Orin?

thanks.

1. sudo apt-get update
2. sudo apt-get install python3-pip
3. sudo pip3 install Jetson.GPIO
4. sudo groupadd -f -r gpio
5. sudo usermod -a -G gpio your_user_name
6. sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
7. sudo udevadm control --reload-rules && sudo udevadm trigger

Sorry I don’t have much idea for it.
But it should be the OS lay rule. Since J5.x.x is upgrade to ubuntu 20.4 not sure if it’s different.

I’ll try ignoring the last two steps and see if it works. Will let you know how it goes.

Thanks

I tried a simple test program (python) using pin3 for SDA and pin5 for SCL. It does not generate any errors, but does not initiate any action on the servos (nothing happens for a little while, then the program ends). I suspect I can not make this work unless the rules for GPIO access are properly enabled. Has anyone successfully run the I2C bus on the Orin Nano, if so what steps did they follow? For reference here is the test program I used:

import time
from adafruit_servokit import ServoKit

kit=ServoKit(channels=16)

tilt=40
pan=20
kit.servo[0].angle=pan
kit.servo[1].angle=tilt

for i in range(20,160,2):
kit.servo[0].angle=i
time.sleep(.05)
for i in range(160,20,-2):
kit.servo[0].angle=i
time.sleep(.05)
for i in range(40,160,2):
kit.servo[1].angle=i
time.sleep(.05)
for i in range(160,40,-2):
kit.servo[1].angle=i
time.sleep(.05)

Also, I get the same results whether the program is run as User or Sudo .

Hi stvenmobile,

I suspect that you’re connecting ServoKit to the wrong I2C bus. Can you show me what the following two commands output?

sudo i2cdetect -y -r 0
sudo i2cdetect -y -r 1

It might work if you change how you initialize ServoKit :

import busio
import board

i2c_bus = busio.I2C(board.SCL, board.SDA)
kit = ServoKit(channels=16, i2c=i2c_bus, address=0x40)

If that doesn’t work, try :

i2c_bus = busio.I2C(board.SCL_1, board.SDA_1)
…

Hope that helps,
Cameron Upright

Here’s the output requested:

steve@orin:~$ sudo i2cdetect -y -r 0
[sudo] password for steve:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: 50 – – – – – – 57 – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –
steve@orin:~$ sudo i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – UU – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: UU – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –
steve@orin:~$

I’ll try your suggestions now.

thanks

This version did not generate any errors, but once again, it did not cause anything to happen on the servos.
The other version generated this:

Traceback (most recent call last):
File β€œ/home/steve/python/robot/pantilt1.py”, line 7, in
kit = ServoKit(channels=16, i2c=i2c_bus, address=0x40)
File β€œ/usr/local/lib/python3.8/dist-packages/adafruit_servokit.py”, line 89, in init
self._pca = PCA9685(
File β€œ/usr/local/lib/python3.8/dist-packages/adafruit_pca9685.py”, line 150, in init
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
File β€œ/home/steve/.local/lib/python3.8/site-packages/adafruit_bus_device/i2c_device.py”, line 62, in init
self.__probe_for_device()
File β€œ/home/steve/.local/lib/python3.8/site-packages/adafruit_bus_device/i2c_device.py”, line 184, in __probe_for_device
raise ValueError(β€œNo I2C device at address: 0x%x” % self.device_address)
ValueError: No I2C device at address: 0x40

I’m going to try a different i2c device like an oled display…

I’m starting to make sense of this. The device shows up properly on i2c bus 7. Thanks for the earlier link to the pinout at JetsonHacks website.

teve@orin:~/installPiOLED/pioled$ sudo i2cdetect -y -r 7
[sudo] password for steve:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – 3c – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –
steve@orin:~/installPiOLED/pioled$

I am doing additional testing.

1 Like

i2c is working properly on bus #7.
Makes sense now.

Topic can be closed.
Thanks.

One last comment. The SSD1306 library works fine, but I have not been able to get the PCA9685 board working with any library I have tried: adafruit-pca9685, adafruit-circuitpython-pca9685, adafruit-circuitpython-servokit or adafruit-servokit.

The challenge seems to be how to specify that I want to use bus 7. I haven’t given up, but the jetson nano is looking better around hardware and library compatibility, but I would very much like to take advantage of the more powerful processing capabilities of the Jetson Orin Nano dev kit.

Thanks for your assistance.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.