#Usage of I2C
This chapter is to test the function of I2C.
The i2c-tools tool is an open source tool that specializes in debugging i2c. It can obtain the mounted device and device address, and can also read and write I2C device registers.
sudo i2cdetect -l
(/r1/debianusermanual/i2ctest/5e2ee7dd28e71a9db7f41dd48d6e226.png =800x)
sudo i2cdetect -F 2
(/r1/debianusermanual/i2ctest/1f57562a71efeb1ff48ca78937bfe94.png =800x)
sudo i2cdetect -a -y 2
(/r1/debianusermanual/i2ctest/06d1d4408b21f56c3ab81447e39a7ac.png =800x)
5. 读取 i2c 总线上的设备
sudo i2ctransfer -f -y 2 w0@0x42 r3
(/r1/debianusermanual/i2ctest/3882d3238170acc19a288483cf709a4.png =800x)
6. Write data to the device on the i2c bus
sudo i2ctransfer -f -y 2 w0@0x42 0x01
# After writing the data, enter the command again, read the information, and confirm that the writing is successful.
sudo i2ctransfer -f -y 2 w0@0x42 r3