

I2C (Inter-Integrated Circuit) is a serial communication protocol developed by Inter Integrated Circuit. It is designed for short-distance communication between devices on a single bus. I2C supports multiple masters and multiple slaves, making it highly versatile for embedded systems. The protocol uses only two wires: a data line (SDA) and a clock line (SCL), which simplifies circuit design and reduces pin usage.








The I2C protocol does not have a specific physical pinout since it is implemented in microcontrollers and devices. However, the two key lines are:
| Pin Name | Description | 
|---|---|
| SDA | Serial Data Line: Used for bidirectional data transfer between devices. | 
| SCL | Serial Clock Line: Provides the clock signal for synchronizing data transfer. | 
Connect the SDA and SCL Lines:
Pull-Up Resistors:
Power Supply:
Addressing:
Master-Slave Communication:
Below is an example of interfacing an I2C temperature sensor with an Arduino UNO:
#include <Wire.h> // Include the Wire library for I2C communication
#define SENSOR_ADDRESS 0x48 // Replace with your sensor's I2C address
void setup() {
  Wire.begin(); // Initialize I2C communication
  Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
  Wire.beginTransmission(SENSOR_ADDRESS); // Start communication with the sensor
  Wire.write(0x00); // Send a command to read temperature (check sensor datasheet)
  Wire.endTransmission(); // End transmission
  Wire.requestFrom(SENSOR_ADDRESS, 2); // Request 2 bytes of data from the sensor
  if (Wire.available() == 2) { // Check if 2 bytes are available
    int temp = Wire.read() << 8 | Wire.read(); // Combine the two bytes
    Serial.print("Temperature: ");
    Serial.println(temp / 256.0); // Convert and print the temperature
  }
  delay(1000); // Wait 1 second before the next reading
}
No Communication on the Bus:
Data Corruption or Noise:
Clock Stretching Issues:
Multiple Devices Not Responding:
Q: Can I connect devices with different voltage levels on the same I2C bus?
A: Yes, but you will need level shifters to safely interface devices operating at different voltage levels.  
Q: How many devices can I connect to an I2C bus?
A: The number of devices is limited by the bus capacitance (typically up to 127 devices with 7-bit addressing).  
Q: What happens if two masters try to communicate at the same time?
A: I2C includes an arbitration mechanism to prevent data collisions. The master with the higher priority (lower address) will take control of the bus.  
Q: Do I always need pull-up resistors?
A: Yes, pull-up resistors are essential for proper operation of the I2C bus. Without them, the lines may not return to a high state.