4-5 I2C Communication Functions

Learning Objectives

This tutorial will help learners understand how to use I²C (Inter-Integrated Circuit) communication on the NVIDIA Jetson Pandora platform. I²C is a simple communication method that allows your Pandora board to "chat" with devices like sensors and displays. We will teach you step-by-step how to configure, scan for devices, and read/write data.


What is I²C Communication?

I²C (pronounced "I-square-C") is a way for the Pandora to exchange data with other devices (like temperature sensors or OLED displays). It acts like a small postman, requiring only two wires:

 - SDA (Serial Data): The line for transmitting data.

 - SCL (Serial Clock): The line for controlling the transmission rhythm (timing).

I²C is a "Master-Slave" communication protocol:

 - Master: The Pandora board, responsible for giving orders.

 - Slave: Devices like sensors or displays that obey the Pandora's instructions.

Each slave device has a unique "address", similar to a house number. The Pandora uses this address to find the specific device it wants to communicate with.


Preparation: Install I²C Tools

To control I²C devices, we need i2c-tools. If your Pandora doesn't have it installed yet, run the following commands:

sudo apt-get update
sudo apt-get install -y i2c-tools

- sudo: Requires administrator privileges.

- apt-get update: Updates the software list.

- install i2c-tools: Installs the I²C tools.


Pandora I²C Bus Information

The Pandora platform features two I²C buses:

I2C Bus 1

I2C Bus 7

Each bus can connect to different devices, such as sensors or display modules.


Practical Steps

1. Scan for I²C DevicesList all I²C Buses:

Run the following command to see which I²C channels are available on the Pandora.

sudo i2cdetect -l

This will display channel names like i2c-1 and i2c-7.

Scan devices on a specific Bus: Let's assume we are checking I2C Bus 1.

sudo i2cdetect -r -y 1

- r: Scan using SMBus read byte commands.

- y: Automatic confirmation (disables interactive mode).

- 1: Checks I2C Bus 1.

The output will look like this:

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

- 3c, 40, 50 are device addresses (in Hexadecimal, e.g., 0x3C, 0x40, 0x50).

- This indicates that devices with these addresses (possibly sensors or displays) are present on I2C Bus 1.

2. Read Device Data

Suppose you have a device with the address 0x3C (common for OLED displays) and you want to read its register

0x00 (refer to the device datasheet for the specific location):

sudo i2cget -y 1 0x3C 0x00

- y 1: Operate on I2C Bus 1.

- 0x3C: Device address.

- 0x00: The register to read.

3. Write Device Data

Suppose you want to set the value 0x05 to register 0x12 on the device at address 0x3C:

sudo i2cset -y 1 0x3C 0x12 0x05

- y 1: Operate on I2C Bus 1.

- 0x3C: Device address.

- 0x12: The register to write to.

- 0x05: The value to write.

Again, refer to the device datasheet to confirm the meaning of the register and the value


Summary

- I²C communication is a simple way for Pandora to exchange data with devices like sensors and displays using two wires (SDA and SCL).

- You can easily scan, read, and write data using i2c-tools (i2cdetect, i2cget, i2cset).

- Pandora uses I2C Bus 1 and I2C Bus 7; use i2cdetect to check device addresses.

 

Copyright © 2026 YUAN High-Tech Development Co., Ltd.
All rights reserved.