I2C stands for “Inter-Integrated Circuit/Controller”. It is a serial communication protocol that is used to connect low-speed devices for serial communication.
The I2C protocol was designed in 1980 by Philips Semiconductor. It is a master-slave communication in which we can connect and control multiple slaves from a single master in which each slave device has a particular address.
The I2C protocol supports various data rates according to versions ranging from 100 Kbps, 400 Kbps, 1 Mbps to 3.4 Mbps. It is a widely used protocol in recent times for short-distance communication. It is also known as the Two Wired Interface(TWI).
It was designed for overcoming the issues of transmitting data with the help of UART or Universal asynchronous Receiver Transmitter and Serial Peripheral Interface or SPI. The UART is an asynchronous transmission protocol while the I2C is a synchronous protocol.
Working of I2C Protocol
The I2C protocol uses two cables for communication in which one cable is used for the clock (SCL) and another cable is used for data (SDA). These two cables are required to pull up with a resistor for + Vdd. It can be used to link two I2C buses with different voltages. Practical use in this arduino based projects.
I2C protocol operates in 2 modes:-
- Master Mode
- Slave Mode
Each data bit is transferred on the SDA line and is synchronized by a high to the low pulse of each clock on the SCL line.
According to I2C protocols, the data line can change only when the clock line is low; it can not change when the clock line is high. The data transmitted is in the form of packets of 9 bits in which:-
- Slave Address – 8 bit
- Start Condition – 1 bit
- Acknowledge – 1 bit
Various Conditions Of I2C Protocol
Start and Stop Conditions:-
Start and Stop conditions are generated by changing the level of SDA and keeping the SCL line high.
For generating the STOP condition SDA is changed from low to high while keeping the SCL high and for generating the START condition the SDA is changed from high to low while keeping the SCL high.
Repeated Start Condition:-
During Start and Stop conditions the control bus is considered to be busy and it can not be controlled by another master. If another master tries to initiate a new transfer and does not want to release the bus before starting the new transfer, it is considered a new START condition, and this new START condition is known as a “Repeated Start Condition”.
Read Write Bit:-
The Read/Write bit is used to determine whether the master is sending the data or receiving the data.
If the Read/Write bit is high then it is considered as the master sending the data to the slave and if the Read/Write bit is low it is considered as receiving the data from the slave.
The bit ACK is generally known as the “Acknowledgement bit” and the NACK is known as the “Negative Acknowledgement bit”. These bits are raised to inform about successful transmission to one another.
The ACK bit is sent to the sender by the receiver If the data frame is received successfully.
This bit is used to determine the slave with which the master wants to communicate.
The address of the slave with which the master wants to communicate is sent by the master to every slave connected with it, then the slave compares its own address with this address and sends ACK accordingly.
Features of I2C Communication Protocol
- Synchronous Communication:-
The data is transferred in the form of frames or blocks in the I2C communication protocol.
It can be configured in a multi-master communication environment.
- Clock Stretching:-
It is possible to stretch the clock when the slave device is not ready to accept more data. This can be accomplished by holding the SCL line low, hence disabling the master to raise the clock line. Now the master will not be able to raise the clock line because the wires are AND wired and it will wait until the slave releases the SCL line to determine that it is ready to transfer the next bit.
- Half Duplex Communication Protocol:-
It is possible to carry out Bi-Directional communication in the I2C communication protocol.
The I2C protocol supports the multi-master bus system but no more than one bus can be used simultaneously.
The SDA and SCL pins are monitored by the masters. If the SDA pin is found high when it was supposed to be low then it will be noted as another master is active and using the bus. Hence it stops the transfer of data.
- Serial Transmission of data:-
The I2C communication Protocol uses serial transmission for the transmission of data. The data bits are transmitted bit by bit and hence It is used for low-speed communication.
Difference Between I2C and SPI Communication Protocols
|I2C stands for Inter-integrated controller.
|SPI stands for Serial Peripheral Interface.
|It was developed by Philips semiconductor in 1980.
|It was developed by Motorola in the mid-1980.
|It is a half-duplex protocol.
|It is a full-duplex protocol.
|It supports multiple master configurations.
|It does not support the multiple master configuration.
|It has more overhead.
|It has less overhead.
|I2C protocol mainly uses two cables for communication which are CCL and SDA.
|SPI protocol uses four cables for communication which are MISO, MOSI, CS, and CLK.
|I2C Protocol’s data transfer speed ranges from 100kHz to 400kHz.
|SPI Protocol has data transfer speed of up to 25 MHz.
|I2C Protocol is a multi-master protocol.
|SPI Protocol is a single master protocol.
Advantage, Disadvantage & Application of I2C Communication Protocol
The I2C communication protocol is ideal for those applications which require less costly and easy implementation rather than high-speed transmission.
Some of the applications of the I2C communication protocol are as follows:-
- Accessing DACs and ADCs
- Communicating with multiple micro-controller
- Transmitting and controlling user-directed actions
- Reading hardware sensors
- Reading certain memory ICS
Advantage of I2C Communication Protocol:-
- It Can be configured in multi-master mode.
- It supports flexible data transmission rates.
- It provides long-distance communication than SPI.
- It increases the complexity of firmware or low-level hardware.
- Each device on the bus is controlled separately.
- It is Cost-efficient.
- It uses the ACK/NACK feature which it has improved error-handling capabilities.
Disadvantage of I2C Communication Protocol:-
- It has a Slower transmission speed.
- It supports a half-duplex mode of communication.
- It is managed by the stack.
- Many devices have multiple addresses saved, which can cause conflicts.
- The complexity of hardware increases when no. of master/slave devices is high in the circuit.
Frequently Asked Questions:-
- How many devices can be connected to I2C?
We can connect up to 128 devices to the I2C bus as the 7-bit can be from 0 to 127.
- Which bit is transmitted first by I2C?
The most Significant Bit (MSB) is transferred first. It can be a device address, register address, or data written to or read from a slave. for more
- What is the maximum speed of I2C?
The I2C communication protocol can be sped up to 3.4Mbps, though 400kHz is usually sufficient.
- What voltage is I2C?
Voltages used are +5 V or +3.3 V, but systems with other voltages are also permitted.