Table of contents
No headings in the article.
I2C (Inter-Integrated Circuit) is a serial communication protocol used to communicate with low-speed peripherals such as microcontrollers, sensors, and EEPROMs. It allows multiple devices to be connected to a single bus, using only two wires (SDA and SCL) to transfer data and control signals. The I2C protocol supports multi-master communication and 7-bit addressing, allowing up to 128 devices to be connected to a single bus.
It is a two-wire, bi-directional serial communication protocol that allows multiple devices to be connected to a single bus. The I2C bus consists of two lines: a data line (SDA) and a clock line (SCL). The devices connected to the I2C bus are assigned a unique 7-bit address, which allows multiple devices to be addressed and communicated with on the same bus.
In I2C, one device acts as a master, controlling the clock signal and initiating communication, while the other devices act as slaves, responding to the master's commands. The master device can initiate communication with any slave device by first sending its address and then sending or requesting data.
The I2C protocol supports multi-master communication, allowing multiple master devices to share the same bus. However, to prevent data collision, a master device must wait for the bus to be free before initiating communication.
In addition to its simplicity and low pin count, I2C is also known for its flexibility, allowing for communication speeds of up to 3.4 Mbps, and for its low power consumption, making it an ideal choice for battery-powered devices. I2C is widely used in a variety of applications, including embedded systems, consumer electronics, and industrial control systems.
Here is a basic wiring diagram of an I2C bus:
+-----+ +-----+
| | | |
| Master SDA------------>| Slave SDA
| |------------------>| |
| |<------------------| |
| SCL |------------------>| SCL |
| |<------------------| |
+-----+ +-----+
In this diagram, the master device is connected to the SDA and SCL lines of the I2C bus, while the slave device is also connected to the same lines. The master device controls the clock signal (SCL) and initiates communication by sending the slave device's address. The slave device then responds to the master's commands and sends or receives data over the SDA line.
It's important to note that the I2C bus requires pull-up resistors to be connected to the SDA and SCL lines. These resistors ensure that the bus lines are pulled to a high logic level when not in use, and prevent the bus from floating. The value of the pull-up resistors depends on the bus length and bus speed but typically ranges from 4.7kΩ to 10kΩ.
A timing diagram of the I2C protocol shows the timing relationship between the SDA and SCL signals during communication between a master and a slave device.
Here is a simplified timing diagram of a single-byte transfer in I2C:
Start: SDA falling edge while SCL is high
Address: The master sends the 7-bit slave address
SDA: [Slave Address + R/W bit]
SCL: Stretched low while the address is sent
Acknowledge: The slave sends an acknowledge signal
SDA: Low level after the address is sent
SCL: Stretched low while the acknowledge is sent
Data: The master sends the data byte
SDA: [Data byte]
SCL: Stretched low while the data is sent
Acknowledge: The slave sends an acknowledge signal
SDA: Low level after the data byte is sent
SCL: Stretched low while the acknowledge is sent
Stop: The master sends a stop signal
SDA: Rising edge while SCL is high
SCL: High level
In this diagram, the SDA line carries the data and the SCL line carries the clock signal. The start and stop conditions are indicated by a falling edge on the SDA line while the SCL line is high. The data and the address are sent bit by bit, with each bit being clocked by a rising edge on the SCL line. The acknowledge signal is sent by the slave device by pulling the SDA line low during the 9th clock cycle after the data or address is sent.
Note that this is just a simplified example and actual I2C communication can be more complex, with multiple bytes being transferred, clock stretching, and repeated start conditions, among other things. However, the basic timing relationships between the SDA and SCL signals remain the same.