The I2C (Inter-Integrated Circuit) protocol is a widely used communication protocol for data transmission between microcontrollers and other integrated circuits. It is preferred in applications requiring low-speed data transmission, especially for communication with sensors, memory modules, and other peripheral devices. The Gemstone development board has one I2C (I2C1) output on its 40-pin header. External I2C devices can be connected via these pins. Additionally, the Gemstone includes an ICM-20948 9-axis MEMS sensor and an HDC2010 temperature and humidity sensor, both communicating via I2C.

Using I2C

After connecting to the Gemstone operating system, install the i2c-tools package to write and read data from I2C addresses.
sudo apt install i2c-tools
To view the available I2C buses, run the ls /dev/i2c-* command. To view the addresses of devices connected to the i2c-2 bus, run the following command:
gemstone@t3-gem-o1:~$ sudo i2cdetect -y -r 2
#      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
# 00:                         -- -- -- -- -- -- -- -- 
# 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
# 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
# 30: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
# 40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
# 50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
# 60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
# 70: -- -- -- -- -- -- -- -- 
In the output above, UU indicates that an I2C device is present at that address and is being used by the system. 40 indicates that a device is present at that address. For example, while reading and writing operations cannot be performed at address 0x30, they can be performed at address 0x40.
To read data from address 0x00 of the device connected to address 0x40 on the i2c-2 bus, run the following command:
sudo i2cget -y 2 0x40 0x00
To write the value 0x80 to address 0x07 of the device connected to address 0x40 on the i2c-2 bus, run the following command:
sudo i2cset -y 2 0x40 0x07 0x80
The I2C addresses used in the examples (such as 0x40, 0x00, and 0x07) are for demonstration purposes only. The addresses of I2C devices in your applications may vary. It is important to consult the documentation of the devices you are using to determine the correct addresses.