Embedded System  - I2C                                                                         Home : www.sharetechnote.com







I2C or I2C came from the term Inter Integrated Circuit. You see two 'I's and one 'C' here. That's how 'I2' or 'I2' came from. Then, what does it mean ? What does it do ?

Since I2C is implemented by only Two Wires (SDA, SCL), it is also called TWI (Two Wire Interface).



Connections in I2C network


It is a kind of serial communication technology which is originally designed for exchanging data between multiple IC chips. This is very simple communication mechanism and I think very smartly designed. It requires only two lines as shown below. One of the line is used for sending Clock signal and the other line is to send/receive data. Also, these two lines can be shared by multiple devices. This communication works as Master-Slave mode. One Master can control / communicate multiple Slaves.



Another good (may be confusing sometimes) there can be multiple Master on the line as shown below.



Even though I said you need only two lines in I2C, in real application you would need a couple of more lines because we need to supply Power to each of the connected chipset and common ground as shown below. Because of this, you would see 4 wires attached to a device (small I2C modules) that use I2C.




How a Master can send data to a specific Slave ?


Then your question is how a Master can send to /control data to a specific Slave. I think you can easily guess how. Each of the Slave device should have a unique address and Master specifies a unique slave address when it sends data or command as shown below.


<I2C Specification - Rev .6 - Fig 11. A master-transmitter addressing a slave receiver with a 7-bit address >



Simplest form of communication between Master and Slave







Master -> Slave




Master -> Slave

Slave Address



Master <- Slave




Master -> Slave




Master <- Slave




Master -> Slave





What is the data rate of I2C ?


You may easily guess that I2C data rate may vary since it has its own clock line. Theoretically, you can achieve different data rate by changing clock rate. However, I2C is also a kind of hardware that is limited by various physical factors. So the data rate of I2C would be within a certain range.

Typical clock rate of I2C is a few hundred KHz. Since I2C data line works only two level (0 or 1), the data rate would also be a few hundred Kbps (should be a little bit lower than Clock cycle).



How far they can communicate over I2C ?


I haven't found any specific answer from I2C specification, but I have read through many pages on the web stating various numbers based on experience.

As it's name Inter Integrated Circuit, it was originally designed for communication between multiple ICs being placed not far away from each other. So I think it would be safe to say 'less than 1 m' as communication distance, but you would see many people states that they made it work over several meters or several tens of meters.



Which one to choose : I2C or SPI ?


In most of the Embedded Board, you would find both I2C and SPI pins and then you would ask yourself which one to use.

The answer would be given partly by personal preference and partly by the nature of the application you want to implement. I think most important criteria you may think of would be as follows

  • Data Rate : If you need a communication system supporting in Mhz range clock (similar data rate), you would go with SPI
  • Complexity : If you don't need very high data rate (well under a Mhz) and want to get very simple technique (or less wiring), you would go with I2C.
  • Number of Slaves : Even though it is doable to control multiple Slaves with SPI, it would not be doable as easy as I2C



Reference :


[1] I2C Specification

[2] How I2C Communication Works and How To Use It with Arduino

[3] Using the I2C Bus

[4] Maximum I2C Bus Length?  

[5] I2C Basics. How to assign address to I2C slave devices.

[6] Tradeoffs when considering SPI or I2C?