Arduino: I2C communication protocol and Wire library

Introduction

The IIC bus type was designed by Philips Semiconductor in the early 1980s. Using the IIC protocol, a host device can connect up to 128 slave devices through two bidirectional buses (data line SDA and clock line SCL).

Master, Slave and Pins

Bus communication is divided into master and slave, and all devices participating in the communication need to share the same ground. During communication, the host is responsible for starting and terminating data transfer, and also outputs a clock signal; the slave is addressed by the host and responds to the host's communication request.

The slave is determined by the device address in the IIC bus, and the address of each slave device on the bus is unique.

On the Arduino Nano, pin A4 is SDA and pin A5 is SCL.

Wire library

See: Arduino Growth Diary 7 - I2C Communication

communication mode

The first type: the host sends data to the slave.
The host controls SCL and SDA, and the slave reads the SDA line when the SCL line is high.

Second type: The host reads the data from the slave.
The host controls SCL, and the slave controls the SDA line when the SCL line is high.

Guess you like

Origin blog.csdn.net/weixin_43249758/article/details/126422321