Interfacing with GPIO/I2C on the NVIDIA Jetson TX1 Development Kit is slightly different than it’s little brother, the Jetson TK1. This is mainly because the GPIO header is physically different on the Jetson TX1, which uses a 2.54mm IDC type of connector, similar to the physical connectors on Arduinos and Raspberry Pis. While the software that is used to interface with an I2C device is the same as on the Jetson TK1, the physical connection is different. As a demonstration, we hook up a LIDAR-Lite v2 to the Jetson TX1. Looky here:
Background
Interfacing with the J21 GPIO Header is straightforward, much like interfacing with some of the more mass market microprocessors/micro-controllers. The same wires and header connectors can be used, as well as ribbon cables and connectors.
In the video, 0.1″ (2.54mm) connector female to male wires were used to connect the Jetson TX1 to the protoboard. These supplies are ubiquitous. There are some may different suppliers and vendors which provide a multitude of configurations. So rather than give links, it’s a better idea for you to look for supplies that suit your needs. The prototyping materials in the video were from Adafruit, if you need a place to start.
Here is the Jetson TX1 J21 header pinout for reference. The GPIO numbers have not been verified by a third party, so use those at your own risk, but the signals should be correct.
LIDAR-Lite
LIDAR-Lite is a laser ranging module from Pulsed Light, Inc. which is a lightweight and cost effective measurement device. LIDAR-Lite can be accessed over I2C or PWM. The JetsonHacks Github repository contains a small library for accessing the LIDAR-Lite v2 over I2C.
The LIDAR-Lite v2 in the demo was purchased from Sparkfun.
Earlier this year, we covered the LIDAR-Lite v1 installation. Refer to that article for a quick background on LIDAR and the device. Recently, a new and improved version was introduced. A summary of the new goodness taken from the Sparkfun website:
Each LIDAR-Lite v2 features an edge emitting, 905nm (75um, 1 watt, 4 mrad, 14mm optic), single stripe laser transmitter and a surface mount PIN, 3° FOV with 14mm optics receiver. The second version of the LIDAR-Lite still operates at 5V DC with a current consumption rate of <100mA at continuous operation. On top of everything else, the LIDAR-Lite has an acquisition time of only 0.02 seconds or less and can be interfaced via I2C or PWM.
The LIDAR-Lite v2 has received a number of upgrades from the previous version. With the implementation of a new signal processing architecture, LIDAR-Lite v2 can operate at measurement speeds of up to 500 readings per second offering greater resolution for scanning applications. Additionally, the LIDAR-Lite v2 has had its I2C communications improved to operate at 100 kbits/s or 400 kbits/s with you, the user, able to assign your own addressing! Just in case you are wondering: yes, the LIDAR-Lite v2 is compatible with its previous version in all primary functions and their compatibility will extend into the next version and beyond.
LIDAR-Lite v2 Installation
Here are the signals for the J21 header: Jetson TX1 J21 Header Pinout Note: There is a small white triangle pointing to Pin 1 of the J21 Header on the Jetson TX1 carrier board.
Follow the wiring diagram:
There are two I2C ports on the expansion header. The first uses J21 pins 3 and 5 (I2C_GP0_DAT and I2C_GP0_CLK respectively) and is on I2C bus 0. The port used in our project, uses J21 pins 27 and 28 (I2C_GP1_DAT and I2C_GP1_CLK respectively) and is on I2C bus 1. Bus one is the bus used in the JetsonHacks LIDAR-Lite library.
The I2C bus is 3.3V. There is a jumper on the TX1 that allows the signal to be set for either 1.8V or 3.3V signals, 3.3V should be chosen. Note that the power supplied to the LIDAR-Lite is 5V, though 3.3V I2C signals are connected.
Software
Note: The LIDAR-Lite V2 software is not backward compatible with the LIDAR-Lite V1.
Once you have the LIDAR-Lite connected, you’re ready to test. There is a small library written for the Jetson to interface with the LIDAR-Lite over I2C available on Github. First, install some prerequisites:
$ sudo apt-get install libi2c-dev i2c-tools
You can then check to see if the Jetson TK1 can detect the LIDAR-Lite v2 address:
$ sudo i2cdetect -y -r 1
You should see ’62’ as one of the entries, which is the address of the LIDAR-Lite.
You can then run the example:
$ git clone https://github.com/jetsonhacks/JHLidarLite_V2.git
$ cd JHLidarLite_V2
$ cd example
$ make
After the example compiles, run:
$ sudo ./example
The sudo is required to access the I2C bus from user space. The example program will show the measured distance, the previous measured distance, and the velocity (rate of change) repeatedly. If the distance is always -1, even after passing your hand over the LIDAR-Lite, this probably means that it is not being recognized by the Jetson.
Also included in the examples folder is a little graphics plotting example as seen in the video. It’s beyond the scope of this article to give step by step instructions on how build the program, but the overview follows.
In order to compile the program, you will need to install Qt Creator as described in an earlier article. Using Qt Creator, compile the program contained in the ‘JHLidarLite_V2/example/LidarPlotSketch’. Once the program is compiled, find the executable in the build folder, and from a Terminal execute the application using ‘sudo’.
Note: This software was demonstrated using L4T 23.1.
Conclusion
Using I2C over the GPIO header of the Jetson TX1 is straightforward, and the LIDAR-Lite v2 is a nice upgrade from the original product. Hopefully this article provided enough information to get started working with the expansion header.
15 Responses
Hi there,
I’m wondering how you were able to install libi2c-dev and i2c-tools through the terminal? Do you know where these packages are located?
When I’m trying to do this, I keep getting the error: “unable to locate package libi2c-dev” and the same for i2c-tools.
Thanks!
Hi Pooja,
After your comment, I ran the command:
$ sudo apt-get install libi2c-dev i2c-tools
they were found, then installed. I did not encounter any issues, the packages were installed as directed.
Thanks for the quick response! Do you remember ever changing your /etc/apt/sources.list to add anything? Or would you mind posting the contents of your sources.list here so I can add whatever I may be missing?
Probably added universe and multiverse at some point.
$ apt-cache policy libi2c-dev
libi2c-dev:
Installed: 3.1.0-2
Candidate: 3.1.0-2
Version Table:
*** 3.1.0-2 0
500 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe armhf Packages
100 /var/lib/dpkg/status
i2c-tools is the same
Thanks kangalow! Once I uncommented all the lines in my sources.list file, I was able to install the libraries!
Although now I do have another question: is there any guide from Jetson or from you on using I2C with a peripheral through the GPIO pins? I have a device for which I will have to write some code to get data on the TX1, and was curious if you had some starting advice.
This is the device guide: https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/overview
And this is the device library for Raspberry Pi: https://github.com/adafruit/Adafruit_Python_BNO055
Thank you!
https://jetsonhacks.com/2016/01/11/imu-and-pwm-driver-over-i2c-for-nvidia-jetson-tx1/
Awesome, thanks kangalow! 🙂 This is perfect.
Hi Kangalow,
congratulations and thank you for everything you post: your professionalism is evident in every single thing you post.
I have a question for you: I just bought a Jetson TX2 (I will receive it next week!), and I would really appreciate it if you could tell me how to access a Lidar Sensor (to get the distance for the sensor to the object in front of it) using Python. It’s an I2C Sensor. Also, in general I don’t know how to access the GPIO on the Jetson TX2, I used Raspberry Pi before and it was a simple import Rpi.GPIO.
Is there an equivalent on the Jetson TX2?
Thank you so very much in advance for your answers. I owe you.
Hi Kangalow,
I connected my Arduino to Jetson TX2 (not TX1) via I2C and found following:
The J21 pins 27 and 28 (I2C_GP1_DAT and I2C_GP1_CLK respectively) and is on I2C bus 0. I2cdetect detects them on bus 0 and not on bus 1. So may be you need to update the J21 header table. This is just to inform you. Thanks.
Thanks for the information, and thanks for reading!
Hi Kangalow,
Great article.
I am trying to connect TX1 to liddar lite v3, but Tx1 bus is not detecting liddar lite address (0X62).
I used $ sudo i2cdetect -y -r 1 as suggested by you.
All the circuit connections are as per your article.
Regards.
Thank you for the kind words.
Did you try checking the other I2C busses? For example:
$ sudo i2cdetect -y -r 0
Thanx for reply.
Yes I have checked all the i2c busses from
$ sudo i2cdetect -y -r 0 to
$ sudo i2cdetect -y -r 5.
Can there be any other thing that I am not doing right.
I can’t think of anything off hand other than it is wired incorrectly.
Thanx for the reply.
I have checked the connections multiple time.
Will see what to do.
Thanx for your support.