Wiring guide

How to wire an I2C LCD to a Raspberry Pi Pico

To wire an I2C LCD to a Raspberry Pi Pico, connect VCC to VBUS (5 V from USB), GND to GND, SDA to GP4 (physical pin 6) and SCL to GP5 (physical pin 7). The backpack wants 5 V and its pull-ups then hold SDA and SCL at 5 V, which a Raspberry Pi Pico pin cannot take, so move those pull-ups to 3.3 V or put a level shifter in the bus. 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.

  • 3.3 V logic
  • Library: LiquidCrystal_I2C.h
  • 4 wires
Raspberry Pi Pico · 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 Raspberry Pi Pico 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 pinRaspberry Pi Pico pinWire colorWhy
VCCVBUS (5 V from USB)redThe LCD glass needs 5 V for its contrast; at 3.3 V most modules show nothing.
GNDGNDblueCommon ground.
SDAGP4 (physical pin 6)violetI2C data.
SCLGP5 (physical pin 7)cyanI2C clock.
Voltage

Power and logic levels for I2C LCD and Raspberry Pi Pico

Logic level

The Raspberry Pi Pico’s GPIO pins are 3.3 V logic and are not 5 V tolerant. Nothing wired to a pin may go above 3.3 V.

Supply

The I2C LCD takes 5 V from VBUS (5 V from USB). That is the Raspberry Pi Pico’s 5 V rail, so the part shares the current the board can supply.

This pair

On the Pico, Wire.begin() puts SDA on GP4 and SCL on GP5, physical pins 6 and 7. The backpack runs from 5 V and carries 4.7 k pull-ups on SDA and SCL, so on a real Raspberry Pi Pico those lines idle at 5 V. Either remove the backpack’s two pull-up resistors and add 4.7 k pull-ups to 3V3, or put a two-channel level shifter between them. The simulator does not punish it; a real RP2040 may.

Pins to leave alone

The numbers in the code are GP numbers, not the physical pin numbers printed beside the header: GP15 is pin 20. GP23 to GP25 are used on the board itself, and GP25 is the LED.

The sketch

The working code for the Raspberry Pi Pico

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

I2C LCD on Raspberry Pi Pico
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// A 16 x 2 display behind a PCF8574 backpack at 0x27.
// SDA GP4 (physical pin 6), SCL GP5 (physical pin 7).
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Raspberry Pi Pic");
  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 Raspberry Pi Pic and the second line reads Seconds: followed by a number that goes up once a second. The serial monitor, at 115200 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 a Raspberry Pi Pico

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.

Powering it from 3V3

The backlight comes on, so it looks wired, but the liquid crystal needs about 5 V of drive for contrast and the characters stay invisible. Use VBUS (5 V from USB).

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.