Raspberry Pi Pico · I2C LCD

Raspberry Pi Pico I2C LCD Simulator: Wiring, Code and a Live Circuit

This is a 16 by 2 character LCD with a PCF8574 I2C backpack, wired to a Raspberry Pi Pico and running live: the first line names the board and the second counts the seconds since reset. It uses the LiquidCrystal_I2C library, so four wires replace the sixteen of a bare LCD.

SDA goes to GP4 (physical pin 6) and SCL to GP5 (physical pin 7). The display needs 5 V, so on the 3.3 V Raspberry Pi Pico it is powered from VBUS (5 V from USB), and the I2C lines need care on a real bench, as the wiring notes explain.

  • 3.3 V logic
  • Library: LiquidCrystal_I2C.h
  • I2C address 0x27
  • Powered from VBUS (5 V from USB)
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.

Wiring the I2C LCD to the Raspberry Pi Pico

Every connection in the circuit above, with the board’s own pin names.

I2C LCD pinRaspberry Pi Pico pinWhy
VCCVBUS (5 V from USB)The LCD glass needs 5 V for its contrast; at 3.3 V most modules show nothing.
GNDGNDCommon ground.
SDAGP4 (physical pin 6)I2C data.
SCLGP5 (physical pin 7)I2C clock.

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 on the Raspberry Pi Pico

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.

On a real bench

Solder headers on the Pico and press it into the breadboard across the center channel; the I2C LCD goes in beside it. GND pins sit every fifth pin down both sides (pins 3, 8, 13, 18 and so on), so there is always one close. The first upload needs BOOTSEL held while plugging in.

The code

The sketch the circuit above runs. Open it in the editor, change a line and press Run: it compiles in your browser.

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);
}

LiquidCrystal_I2C lcd(0x27, 16, 2) names the backpack’s address and the size of the display. init() wakes the HD44780 controller behind the backpack in four-bit mode, and backlight() turns the LED on, which is a bit in the backpack, not in the display.

setCursor(column, row) counts from zero, so (0, 1) is the start of the second line. print() writes text there and moves the cursor along, the way Serial.print() does.

The three spaces after the number overwrite whatever a longer number left behind. Calling clear() every time would do the same and make the display flicker, because clear() takes about 2 ms and blanks the whole panel. Serial.begin(115200) opens the serial monitor. Serial is the USB port at 115200 baud in this sketch; on a real Pico it appears once the board has enumerated.

Common mistakes with the I2C LCD on the 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).

Questions and answers

Can I simulate a 16x2 I2C LCD with a Raspberry Pi Pico?

Yes. The circuit at the top of this page is a Raspberry Pi Pico with a 16x2 I2C LCD, running in your browser on a simulated RP2040. The characters the sketch prints appear on the simulated panel, backlight and contrast included. Press Run it in the editor to change the wiring or the code; it is free and needs no account.

Where do SDA and SCL go on the Raspberry Pi Pico?

On the Pico, Wire.begin() puts SDA on GP4 and SCL on GP5, physical pins 6 and 7.

Is a 5 V I2C LCD safe on the Raspberry Pi Pico?

Power is fine from VBUS (5 V from USB). The I2C lines are the risk: the backpack pulls them up to 5 V. On a real board use a level shifter, or move the pull-ups to 3.3 V.

How do I find the LCD’s I2C address?

Upload an I2C scanner sketch: it calls Wire.beginTransmission() on every address and prints the ones that answer. The two you will almost always see are 0x27 and 0x3F.

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.