

I2C (Inter-Integrated Circuit) is a multi-master, multi-slave, packet-switched, single-ended, serial communication bus. It is widely used in embedded systems to connect low-speed devices such as sensors, EEPROMs, real-time clocks, and microcontrollers. I2C is known for its simplicity and efficiency, requiring only two communication lines: a data line (SDA) and a clock line (SCL). This makes it ideal for applications where minimizing pin usage is critical.








I2C does not have a specific pinout since it is a protocol, but the two key lines are:
| Pin Name | Description | Notes |
|---|---|---|
| SDA | Serial Data Line | Bi-directional data transmission |
| SCL | Serial Clock Line | Synchronizes data transmission |
Below is an example of interfacing an I2C temperature sensor (e.g., TMP102) with an Arduino UNO:
#include <Wire.h> // Include the Wire library for I2C communication
#define TMP102_ADDRESS 0x48 // I2C address of the TMP102 sensor
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
Wire.beginTransmission(TMP102_ADDRESS); // Start communication with TMP102
Wire.write(0x00); // Point to the temperature register
Wire.endTransmission(); // End transmission
Wire.requestFrom(TMP102_ADDRESS, 2); // Request 2 bytes of data from TMP102
if (Wire.available() == 2) { // Check if 2 bytes are available
int msb = Wire.read(); // Read the most significant byte
int lsb = Wire.read(); // Read the least significant byte
float temperature = ((msb << 8) | lsb) >> 4; // Combine bytes and shift
temperature *= 0.0625; // Convert to Celsius
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
}
delay(1000); // Wait 1 second before the next reading
}
No Communication on the Bus:
Address Conflicts:
Data Corruption:
Device Not Responding:
Q: Can I connect multiple masters on the same I2C bus?
Q: What happens if I don’t use pull-up resistors?
Q: How do I determine the correct pull-up resistor value?
R = tr / (Cbus * Vcc).Q: Can I use I2C with 3.3V and 5V devices on the same bus?
This documentation provides a comprehensive guide to understanding and using the I2C protocol effectively in your projects.