In the world of embedded systems and electronics, seamless communication between components is vital. One of the most popular and efficient protocols enabling this is I2C (Inter-Integrated Circuit). Developed by Philips (now NXP Semiconductors) in 1982, I2C has become a cornerstone of sensor, memory, and peripheral communication in everything from simple Arduino projects to complex industrial devices.
What is I2C?
I2C (pronounced “I-squared-C” or “I-two-C”) is a synchronous, multi-master, multi-slave, packet-switched, single-ended, serial communication bus. It uses only two wires for communication:
- SDA (Serial Data Line) – for data transfer
- SCL (Serial Clock Line) – for clock signal
This minimalistic approach makes I2C ideal for short-distance communication within a single device or between nearby components on a PCB.
Key Features of I2C
- Two-wire Interface: Just SDA and SCL, reducing wiring complexity.
- Multiple Masters and Slaves: Unlike SPI, I2C supports multiple masters and slaves on the same bus.
- Addressing: Each slave device is identified by a unique address (usually 7-bit or 10-bit).
- Speed Modes:
- Standard Mode – 100 kbps
- Fast Mode – 400 kbps
- Fast Mode Plus – 1 Mbps
- High-Speed Mode – 3.4 Mbps
- Clock Stretching: Slaves can hold the clock line low to pause communication if they’re not ready.
- Acknowledgment: Each byte of data is acknowledged by the receiver, ensuring reliability.
How I2C Works
1. Start and Stop Conditions
Communication begins with a Start condition (SDA pulled low while SCL is high), and ends with a Stop condition (SDA goes high while SCL is high).
2. Address Frame
After the start condition, the master sends the 7-bit slave address followed by a Read/Write bit:
0
for write1
for read
The addressed slave device responds with an ACK (acknowledge) bit.
3. Data Transfer
Data is transferred in 8-bit bytes. After each byte, the receiver sends an ACK bit. Communication continues until the master sends a Stop condition.
Pros and Cons of I2C
✅ Pros:
- Simple and cost-effective
- Low pin count
- Supports multiple devices
- Robust handshaking (via ACK/NACK)
❌ Cons:
- Slower than SPI
- Limited bus length and device count due to capacitance
- More complex than UART in terms of protocol handling
Common Use Cases
- Connecting sensors (e.g., temperature, humidity)
- EEPROM and RTC modules
- Display drivers (e.g., OLED, LCD)
- Audio codecs and DACs
- Microcontroller-to-microcontroller communication
I2C vs SPI vs UART
Feature | I2C | SPI | UART |
---|---|---|---|
Wires | 2 | 4+ | 2 |
Speed | Medium | Fast | Variable |
Complexity | Moderate | Simple to Moderate | Simple |
Device Count | Many (with addressing) | Few (due to CS lines) | 2 |
Full Duplex | No | Yes | Yes |
Final Thoughts
I2C is a go-to protocol when you need a low-pin count, efficient communication method for multiple devices. While it may not be the fastest option, its flexibility and ease of integration make it indispensable for modern embedded systems.
Whether you’re wiring up a few sensors or developing a sophisticated control system, I2C offers a reliable path to getting your devices talking.