Wiring guide

How to wire an I2C LCD to an Arduino Uno R4

To wire an I2C LCD to an Arduino Uno R4, connect VCC to 5V, GND to GND, SDA to pin A4 and SCL to pin A5. The Arduino Uno R4 is a 5 V board and the backpack runs from 5 V, so its pull-ups hold SDA and SCL at the board’s own level and nothing else is needed. The sketch below uses the LiquidCrystal_I2C (LiquidCrystal_I2C.h) library. It writes the board name on the first line and counts the seconds on the second.

  • 5 V logic
  • Library: LiquidCrystal_I2C.h
  • 4 wires
Arduino Uno R4 · I2C LCDlive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running on the simulator with the sketch below. Press what can be pressed; click anything else to open it in the editor.
Pin to pin

I2C LCD to Arduino Uno R4 wiring table

Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.

I2C LCD pinArduino Uno R4 pinWire colorWhy
VCC5VredThe display and its backlight run from 5 V.
GNDGNDblueCommon ground.
SDApin A4violetI2C data.
SCLpin A5cyanI2C clock.
Voltage

Power and logic levels for I2C LCD and Arduino Uno R4

Logic level

The Arduino Uno R4’s pins are 5 V logic. A 5 V part can drive them directly; a part whose signal pins are limited to 3.3 V needs a level shifter.

Supply

The I2C LCD takes 5 V from 5V. That is the Arduino Uno R4’s 5 V rail, so the part shares the current the board can supply.

This pair

The Uno R4 keeps the Uno’s layout: I2C is A4 (SDA) and A5 (SCL), also brought out as SDA and SCL beside AREF. The backpack’s own pull-ups hold both lines at 5 V, which is the Arduino Uno R4’s own logic level, so nothing else is needed.

Pins to leave alone

An Uno sketch’s source builds for the R4, but a compiled Uno program will not run on it: different chip. The R4’s pins source less current than an Uno’s, about 8 mA each, so do not drive a relay coil or a motor straight from one.

The sketch

The working code for the Arduino Uno R4

Library: LiquidCrystal_I2C (LiquidCrystal_I2C.h). This is the sketch the circuit above runs.

I2C LCD on Arduino Uno R4
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// A 16 x 2 display behind a PCF8574 backpack at 0x27.
// SDA pin A4, SCL pin A5.
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Arduino Uno R4");
  Serial.println("LCD ready");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("Seconds: ");
  lcd.print(millis() / 1000);
  lcd.print("   ");      // clears the tail of a shorter number
  delay(250);
}
Output

What you should see

The first line of the display reads Arduino Uno R4 and the second line reads Seconds: followed by a number that goes up once a second. The serial monitor, at 9600 baud, prints LCD ready once, after the display has been set up.

A blank screen with the backlight on means the contrast is too low or the address is wrong. This circuit answers at 0x27, the address most backpacks ship with.

The serial monitor prints this, recorded from the circuit above running:

LCD ready
Pitfalls

Common mistakes wiring an I2C LCD to an Arduino Uno R4

The wrong address

Backpacks with the PCF8574T chip answer at 0x27; those with the PCF8574AT answer at 0x3F. The screen lights but shows nothing when the address is wrong. Run an I2C scanner, or set the part’s address property in the editor to match yours.

Contrast turned all the way down

A row of solid blocks, or nothing at all with the backlight on, is usually the blue trimmer on the backpack. Turn it until the text appears. In the simulator the part has a contrast property for the same thing.

Clearing the screen in every loop

lcd.clear() takes about 2 milliseconds and blanks the panel, so calling it every pass makes the text flicker. Overwrite the line and pad it with spaces, as the sketch does.

Build your own I2C LCD project

Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.