Unit D - Sensors & Buses

17. I2C, Address Scanning & I2C LCD

Share a two-wire bus and simplify display wiring.

Estimated time 4 hours

Learning outcomes

  • Explain SDA, SCL, addresses and pull-ups
  • Scan an I2C bus
  • Wire Uno I2C pins
  • Use a common I2C LCD backpack

Parts and preparation

Uno, I2C LCD backpack/display and jumper wires. Install LiquidCrystal I2C by Frank de Brabander (see Libraries box).

Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.

Libraries for this lesson

In Arduino IDE 2 open Tools → Manage Libraries…. Search by the Library Manager name and install the package by the exact author below. Similar names from other authors can use different APIs and will break the example.

IncludeLibrary Manager nameAuthorInstall note
Wire.hWireArduinoBuilt into the Arduino core. No Library Manager install required.
LiquidCrystal_I2C.hLiquidCrystal I2CFrank de BrabanderInstall via Library Manager. Other LiquidCrystal_I2C packages use different APIs (init vs begin).
I2C, Address Scanning & I2C LCD instructional connection diagram
Open the diagram for a larger view. Trace every connection before building.

I2C bus

SDA carries data and SCL carries a shared clock. Devices use addresses, so several can share the wires. Uno SDA is A4 and SCL is A5.

Pull-ups

SDA and SCL are open-drain signals and need pull-up resistors; modules commonly include them. Too many modules can make the combined pull-up resistance too low.

Addresses

Common LCD backpack addresses are 0x27 and 0x3F, but scanning is more reliable than guessing.

Library variation

Several Library Manager packages share similar names. This course uses LiquidCrystal I2C by Frank de Brabander, which provides lcd.init() and lcd.backlight().

Wiring and safe build sequence

Breadboard wiring for lesson 17: I2C, Address Scanning & I2C LCD
Breadboard layout for this lesson. Match colours and pins before powering the circuit. Click the image for a larger view.
  1. LCD VCC -> 5 V
  2. LCD GND -> GND
  3. LCD SDA -> A4
  4. LCD SCL -> A5
Power rule: switch off before moving wires. Arduino I/O pins are control signals; high-current loads require a driver and suitable external supply.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Wire.begin();
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("I2C connected");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("ADC ");
  lcd.print(analogRead(A0));
  lcd.print("    ");
  delay(250);
}

How the code works

  1. Change 0x27 only if a scanner reports another address.
  2. All devices on the bus share SDA, SCL and GND.

Test and record evidence

Expected result: The LCD shows a heading and live A0 reading using only two signal wires.

Practical evidence checklist

Common faults and checks
  • Run an I2C scanner if the display is blank.
  • Adjust the backpack contrast potentiometer.
  • Confirm the installed librarys initialization API.
Extension challenge: Connect an RTC on the same bus and explain why no extra SDA/SCL pins are required.

Check your understanding

Q1. Why can devices share SDA and SCL?

Show answer

Each device responds to its own I2C address.

Q2. Which Uno pins are SDA and SCL?

Show answer

A4 is SDA and A5 is SCL.