What is I2C?

I2C is a bidirectional bus technology, used to interface any electronic devices easily. It can be also said as a protocol, which transfers the data directly between the devices. It uses only two lines for data transfer and so reduces the circuit complexity.

How does it work?

The technology can be explained with the following figure:

The Master device can be a Microprocessor, Microcontroller or a PC. It should be a device able to generate clock signals. The I2C protocol is loaded in the master device. The master can be connected with any number of devices -- called as slaves. Examples of some slaves are - LCD driver, sensors, ADC etc. The slaves are given individual addresses to them. The Master can give and take datas from the slaves. The interfacing from, master to slave - is done easily with only two bidirectional lines – SDA- Serial Data Line and SCL – Serial Clock Line.  The slaves are connected by just Clipping or unclipping without affecting the next device.
When a data is to be transferred to a particular slave, the following functions happen:
1. Starting Condition: The Master generates the clock and sets the SCL line high (SCL=1). At the same time, it also changes the SDA line from a High to Low transition. After start, both the buses will become busy.
2. Address Transfer: After this clock signal, it loads the address of the particular slave and sends to all slaves.
3. Acknowledgement from Slave: Each and every slave checks the address from the Master, and the slave with the same address acknowledges.
4. Data Transfer: After receiving the acknowledgement, the Master sends the data in bytes. Any number of bytes may be transferred to a slave.
5. Stop condition: After data transmission, the Master sends the stop condition to inform the slave that the data transfer has completed.
Interconnecting Multiple Masters:
We can also connect Multiple Masters to multiple slaves. i.e., two or three controlling devices may be connected to control the I2C bus and it might control some other devices also. While connecting multiple masters, some below said problems should be carefully avoided.

1.    The transferred data should not be corrupted because of multiple controls from multiple masters. This problem is avoided, by using a correct procedure of transferring data - is called as Arbitration.
2.    The clock signals of two or more controlling devices should be carefully synchronized. This is also handled in a correct procedure called as Synchronization.