Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

16×2 I2C LCD with Arduino Nano — wiring, address and a 5 V rail meter

Connect a 16×2 LCD with a PCF8574 backpack to an Arduino Nano on A4/A5, print text, and show the Nano’s own 5 V supply voltage on line two.

Arduino C++Verified — core avr 1.8.8, LiquidCrystal I2C 1.1.2, 3 Nov 2026Compile-only

Community draft — report a mistake

A 16×2 LCD with an I2C backpack needs just four wires from a Nano: 5V, GND, A4 (SDA) and A5 (SCL). It’s readable in sunlight, which an OLED isn’t, and costs about ₹180.

To make the second line useful, the sketch measures the Nano’s own supply voltage without any extra parts. That’s a quick way to find a bad USB cable or a power bank that sags — a common cause of “random resets” on battery builds.

Wiring

Arduino NanoOnly the pins used are shown · 5 V logic16×2 LCD + I2C backpackA4A55VGNDGNDVCCSDASCL
Every connection
Arduino Nano16×2 LCD + I2C backpackWireNotes
GNDGNDblack
5VVCCredBacklight draws 20–30 mA — fine from the Nano’s 5V pin.
A4SDAblue
A5SCLyellow

5 V (3.3 V versions exist) part, 5 V board. Most of these LCDs need 5 V for good contrast, and the backpack pulls SDA/SCL up to its own VCC. On ESP32 or Pico, put a BSS138 level shifter between the board and the backpack instead of wiring SDA/SCL directly.

Board quirks

  • The LCD and the Nano are both 5 V, so SDA/SCL connect directly — no level shifter, unlike on an ESP32.
  • The line-two voltage is measured by the ATmega328P against its internal 1.1 V reference. On USB it often reads 4.6–4.9 V because of the protection diode on the Nano; below about 4.5 V the LCD contrast fades.
  • Address is 0x27 on PCF8574T backpacks and 0x3F on PCF8574AT. If unsure, run an I2C scanner first.
  • Mount the LCD off the breadboard: the backpack’s pins hang below the display and won’t sit flat beside a Nano.

Code

lcd-16x2-nano.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 16x2 LCD with a PCF8574 I2C backpack on an Arduino Nano.
// GND → GND, VCC → 5V, SDA → A4, SCL → A5. Address 0x27 (some backpacks: 0x3F).
// Line 2 shows the 5 V rail the Nano measures on itself (against its internal 1.1 V bandgap),
// handy for spotting a weak USB cable or a sagging power bank.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

long readVccMillivolts() {
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);  // AVcc reference, measure 1.1 V bandgap
  delay(2);
  ADCSRA |= _BV(ADSC);
  while (bit_is_set(ADCSRA, ADSC)) {}
  long raw = ADC;
  return 1125300L / raw;  // 1.1 V * 1023 * 1000
}

void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print(F("Hello from Nano"));
  Serial.println(F("LCD ready - blank? turn the blue contrast trimmer"));
}

void loop() {
  long mv = readVccMillivolts();
  lcd.setCursor(0, 1);
  lcd.print(F("5V rail: "));
  lcd.print(mv / 1000.0, 2);
  lcd.print(F(" V "));
  Serial.print(F("5V rail: "));
  Serial.print(mv);
  Serial.println(F(" mV"));
  delay(1000);
}

Library: LiquidCrystal I2C (Frank de Brabander) — compiled with LiquidCrystal I2C 1.1.2.

Expected serial output

Serial Monitor · 115200Output
LCD ready - blank? turn the blue contrast trimmer
5V rail: 4742 mV
5V rail: 4738 mV

Common errors

Backlight on, only blocks or nothing

Turn the contrast trimmer, then try address 0x3F. Full fix.

Only the first character shows

Library mismatch — use LiquidCrystal I2C by Frank de Brabander. Full fix.

no matching function for call to LiquidCrystal_I2C::begin()

This library uses lcd.init(). Full fix.

↑↓ to move · Enter to open