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
CartYou'll need
Arduino Uno Rev 3Board Only$32.24
Male-Male Jumper Wires (Set of 65-assorted sized and colors)$6.99
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.
- I2C uses 2 wires: SDA (data) and SCL (clock).
- Multiple devices can share the same bus.
- Each device has a unique address.
- On Arduino Uno: SDA=A4, SCL=A5.
- 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.
- Example: LCD display with I2C backpack.
- Connect device SDA to Arduino A4.
- Connect device SCL to Arduino A5.
- Connect device VCC to Arduino 5V.
- Connect device GND to Arduino GND.
- 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.
- Upload I2C scanner sketch.
- Open Serial Monitor.
- Sketch scans all possible addresses (0x00-0x7F).
- Note the addresses found (e.g., 0x27 for LCD, 0x68 for RTC).
#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.
- Install LiquidCrystal_I2C library in Arduino IDE.
- Write sketch to display text.
- Use the address found in previous step.
#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.
- Keep LCD connected.
- Add another I2C device (e.g., temperature sensor).
- Wire to same SDA/SCL pins.
- Read sensor data and display on LCD.
- 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.