Skip to content

I2C Arduino Communication Projects

Learn to use the I2C protocol with Arduino to connect multiple devices with just two wires for sensors, displays, and more.

  • Arduino
  • Intermediate
  • 60 minutes
  • 5 steps

Shop this project

Cart

Prices from vilros.com. Tax and shipping at checkout.

Before you start, you'll need

  • Arduino Uno (or compatible)
  • 2-3 I2C devices (sensors, LCD, etc.)
  • Jumper wires

Learn I2C basics

About 10 minutes

Understand how I2C works.

  1. I2C uses 2 wires: SDA (data) and SCL (clock).
  2. Multiple devices can share the same bus.
  3. Each device has a unique address.
  4. On Arduino Uno: SDA=A4, SCL=A5.
  5. Devices can be sensors, displays, EEPROMs, and more.

You should see

You understand I2C pin connections.

Connect first I2C device

About 15 minutes

Wire a sensor or display to I2C bus.

  1. Example: LCD display with I2C backpack.
  2. Connect device SDA to Arduino A4.
  3. Connect device SCL to Arduino A5.
  4. Connect device VCC to Arduino 5V.
  5. Connect device GND to Arduino GND.
  6. Repeat for additional I2C devices (they share the same 4 wires).

You should see

I2C device is wired and powered.

Find I2C device addresses

About 10 minutes

Identify addresses of connected devices.

  1. Upload I2C scanner sketch.
  2. Open Serial Monitor.
  3. Sketch scans all possible addresses (0x00-0x7F).
  4. Note the addresses found (e.g., 0x27 for LCD, 0x68 for RTC).
cpp
#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("I2C Scanner");
}

void loop() {
  byte count = 0;
  
  Serial.println("Scanning...");
  
  for (byte addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    
    if (Wire.endTransmission() == 0) {
      Serial.print("Device found at 0x");
      if (addr < 16) Serial.print("0");
      Serial.println(addr, HEX);
      count++;
    }
  }
  
  Serial.print("Found ");
  Serial.print(count);
  Serial.println(" device(s)\n");
  
  delay(5000);
}

Scan helps you find device addresses for your code.

You should see

All connected I2C devices are detected with their addresses.

Control an I2C LCD display

About 15 minutes

Display text on I2C LCD.

  1. Install LiquidCrystal_I2C library in Arduino IDE.
  2. Write sketch to display text.
  3. Use the address found in previous step.
cpp
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.begin();
  lcd.backlight();
  
  lcd.setCursor(0, 0);
  lcd.print("Hello, I2C!");
  
  lcd.setCursor(0, 1);
  lcd.print("Arduino Project");
}

void loop() {
}

Change 0x27 to your LCD's actual address.

You should see

Text displays on LCD.

Use multiple I2C devices

About 10 minutes

Connect LCD + sensor on same bus.

  1. Keep LCD connected.
  2. Add another I2C device (e.g., temperature sensor).
  3. Wire to same SDA/SCL pins.
  4. Read sensor data and display on LCD.
  5. Both devices work simultaneously!

You should see

Multiple I2C devices communicate on shared bus.

It didn't work
  • I2C devices not detected.

    Check wiring carefully. Try adding pull-up resistors (4.7kΩ) from SDA and SCL to 5V. Verify power supply is stable. Check device addresses don't conflict.

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.