I2C may at first sound like the name of a newly discovered star. But, I2C is actually the name of a very simple, yet powerful, communications protocol.
I2C, or “i-squared c,” enables serial transmission, a form of data transmission where data is sent sequentially. For example, the word “cereal” will be sent over I2C as “c”, “e”, “r”, “e”, “a”, and “l.”
More importantly, I2C only needs two wires to function. These lines, SDA and SCL, allow for data transfer and clock synchronization, respectively.
I2C has a pretty deep electronics background, which I definitely cannot do justice to in this article. Instead, I simply hope to provide a general overview of the protocol.
If you desire a very detailed explanation of I2C, the following videos may interest you: What is I2C, Basics for Beginners — YouTube , How I2C Communication Works and How To Use It with Arduino — YouTube .
Normally I divide articles up into sections, but this one is on the shorter side, so I will jump right into the explanation.
As previously mentioned, I2C uses two wires for transmission: SDA and SCL. The SDA line is where data is transmitted, while the SCL line uses clock pulses to synchronize data transfer.
Think of the clock pulses like the beats of a drum. This rhythm lets the devices on I2C know when to send and receive data. If clock synchronization was not present, devices would send data in arbitrary time intervals, which could become problematic very quickly.
An I2C transmission on the SDA contains addresses, acknowledges, read or write bits, and data.
Addresses can further be split into device addresses and internal register addresses. If device A wants to transmit to device B, it first needs to specify the address of device B. Many I2C devices use a 7 bit scheme (0–127) with hexadecimal notation (0–0x7f). Additionally, device A may want to access the internal registers of device B to read or write data. In this case, device A must specify the address of the register in question.
Read or write bits specify whether a device wants to read data from or write data to another device. Continuing with devices A and B, if A wants to receive data from B, it would set the read or write bit to the “read” option. If A wants to send data to B, it would set the bit to the “write” option. “Read” and “write” correspond to 0 and 1.
Acknowledges are “gaps” in transmissions which give devices space to confirm the reception of data. After device A sends some data to device B, it waits for B to “acknowledge” the transmission with a signal. If acknowledgement occurs, then transmission may continue; if not, then transmission is ended.
Finally, we have the data. For every clock pulse, one bit of data can be transmitted. Also, for a byte, or 8 bits, of data, an acknowledge must occur to proceed with transmission. Data can comprise of addresses, sensor readings, and requests, among other things.
I2C also uses master-slave architecture. The master essentially controls data transmission, while the slave follows the master’s commands. Truthfully, this name is outdated and should be changed, but it does describe the relationship between I2C devices well.
For example, let us say that an Arduino microcontroller and an infrared sensor are connected through I2C. The Arduino, based on its needs, commands the infrared sensor to send data. The infrared sensor’s only jobs are to record readings and serve the Arduino, while the Arduino actually controls communication between the two. The Arduino is the master, and the infrared sensor is the slave. I2C supports multiple slaves, but it also supports multiple masters, making it more powerful.
So, to recap: I2C is a serial transmission protocol which uses two wires and allows devices to communicate with each other. It is a powerful protocol which is easy to implement. I2C and its derivatives are commonly used in embedded systems, which shape our world today.
If you are still here, thank you for reading! Electronics is a bit (no pun intended) out of my comfort zone, but I have always been fascinated with how people around me build very cool things with electricity and components. I may write more about this field in the future, so stay tuned!