How to wire an I2C LCD to an Arduino Nano
To wire an I2C LCD to an Arduino Nano, connect VCC to 5V, GND to GND, SDA to pin A4 and SCL to pin A5. The Arduino Nano 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
I2C LCD to Arduino Nano 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 pin | Arduino Nano pin | Wire color | Why |
|---|---|---|---|
| VCC | 5V | red | The display and its backlight run from 5 V. |
| GND | GND | blue | Common ground. |
| SDA | pin A4 | violet | I2C data. |
| SCL | pin A5 | cyan | I2C clock. |
Power and logic levels for I2C LCD and Arduino Nano
Logic level
The Arduino Nano’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 Nano’s 5 V rail, so the part shares the current the board can supply.
This pair
The Nano has the Uno’s chip, so I2C is A4 (SDA) and A5 (SCL), on the analog side of the board next to A6 and A7. The backpack’s own pull-ups hold both lines at 5 V, which is the Arduino Nano’s own logic level, so nothing else is needed.
Pins to leave alone
A6 and A7 are analog only: pinMode(A6, OUTPUT) does nothing and digitalRead(A7) is not there to call. D0 and D1 are the USB serial port.
The working code for the Arduino Nano
Library: LiquidCrystal_I2C (LiquidCrystal_I2C.h). This is the sketch the circuit above runs.
#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 Nano");
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);
}
What you should see
The first line of the display reads Arduino Nano 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 readyCommon mistakes wiring an I2C LCD to an Arduino Nano
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.