40pin IO Development
Experiment 06 - IIC Experiment
Software operation: (RDK X5 enables I2C5 by default on 40PIN (physical pins 3 and 5) and I2C0 (physical pins 27 and 28), IO voltage 3.3V.)
Enter the user home directory and run:
cd usersudo python3 ./test_i2c.py
Terminal output as follows:

#!/usr/bin/env python3
import sys
import signal
import os
import time
# Import i2cdev
from i2cdev import I2C
def signal_handler(signal, frame):
sys.exit(0)
def i2cdevTest():
# device, bus = 0x51, 0
bus = input("Please input I2C BUS num:")
os.system('i2cdetect -y -r ' + bus)
device = input("Please input I2C device num(Hex):")
print("Read data from device %s on I2C bus %s" % (device, bus))
i2c = I2C(eval("0x" + device), int(bus))
value = i2c.read(1)
i2c.write(value)
print("read value=", value)
i2c.close()
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler)
print("Starting demo now! Press CTRL+C to exit")
print("List of enabled I2C controllers:")
os.system('ls /dev/i2c*')
while True:
i2cdevTest()