LCD
Interfacing LCD1602 I2C with STM32 Blue Pill
What is the LCD1602 I2C?
LCD1602 I2C practical reference
The LCD1602 is a 16-column, 2-row character LCD built around the ubiquitous HD44780 controller. On its own it needs a dozen wires and a contrast potentiometer, which is why almost every one sold today comes glued to a small PCF8574 I2C backpack — that backpack absorbs all of it into 4 pins (power, ground, and two I2C lines) and gives you an onboard trimmer for contrast.
It only displays fixed-width text characters (plus up to 8 custom 5x8 glyphs you can define yourself), not arbitrary graphics — for anything pixel-addressable, look at a graphic display like the SSD1306 OLED instead. But for status readouts, menus, sensor value displays, and simple UIs, it's the cheapest and most reliable text display in the hobbyist ecosystem, and the exact same library and code scale straight up to the larger LCD2004 (20x4) — see the variants table below.
Key specifications
- Display: 16 characters × 2 lines, fixed-width text (HD44780 controller)
- Backpack: PCF8574 I2C I/O expander (converts the LCD's 6-wire parallel interface to I2C)
- Operating voltage: 5 V DC (most common); some 3.3V-tolerant backpacks exist but are less common
- I2C address: 0x27 default on most PCF8574 backpacks, 0x3F on some clones — scan to confirm
- Interface: I2C, up to 100 kHz typical
- Backlight: LED backlight, on/off controllable over I2C
- Custom characters: Up to 8 user-defined 5×8 pixel glyphs
Pinout and connection notes
The PCF8574 backpack already includes its own I2C pull-up resistors, tied to whatever you feed VCC — same consideration as any other I2C breakout with onboard pull-ups. Most backpacks are 5V parts and the display itself needs 5V to hit full contrast/brightness, so on 3.3V-only boards (ESP32, Raspberry Pi, STM32) you'll typically power VCC from a 5V rail while still wiring SDA/SCL through a level shifter or accepting that the I2C lines will sit at 5V — check your specific board's I2C pin tolerance before skipping a level shifter. If characters look like solid black blocks or are invisible, adjust the small blue potentiometer on the back of the backpack — that's a contrast issue, not a wiring or code fault. If nothing shows up on the bus at all, run an I2C scanner sketch first to confirm the actual address, since 0x27 vs 0x3F varies by manufacturer.
- GND: Ground
- VCC: Power, 5V DC
- SDA: I2C data line
- SCL: I2C clock line
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up LCD1602 I2C with STM32 Blue Pill
Library
LiquidCrystal I2C by Frank de Brabander
Boards Manager → add the STM32duino package URL → install "STM32 MCU based boards" → then Library Manager → search "LiquidCrystal I2C" by Frank de Brabander
Wiring
| Component pin | STM32 Blue Pill pin | Note |
|---|---|---|
| VCC | 5V | Confirm your specific Blue Pill exposes a real 5V rail (fed from USB/VIN) before relying on it. |
| GND | GND | |
| SDA | PB7 | Default I2C1 data pin on most STM32duino core mappings. |
| SCL | PB6 | Default I2C1 clock pin on most STM32duino core mappings. |
Swipe sideways to see every column →
- Every GPIO on this board is 3.3V-only and NOT 5V-tolerant. The backpack's I2C pull-ups reference its VCC (5V), so wiring this directly is common in practice but technically out of spec for the Blue Pill - add a logic-level shifter on SDA/SCL if you want to be strict.
- Most Blue Pills don't have working USB-CDC serial out of the box; if you're also debugging over Serial, flash over SWD with an ST-Link or use a USB-TTL adapter on PA9/PA10.
Related Components
Related Guides & Projects
STM32 Low-Power Modes: Sleep, Stop, and Standby Explained (With Working Code)
A practical guide to STM32's three-tier low-power system — Sleep, Stop, and Standby — with working STM32duino code, measured current draw on a Blue Pill, and a battery-powered project example.
STM32 Blue Pill Pinout: Every GPIO, ADC, and Alternate Function Explained
A complete STM32F103C8T6 Blue Pill pinout reference: every GPIO port, ADC channel, timer, and communication bus mapped, plus the 5V-tolerance and clone-board considerations that affect wiring decisions.
STM32 Black Pill Pinout: Every GPIO, ADC, and Peripheral Explained
Complete STM32 Black Pill (STM32F411CEU6) pinout reference: GPIO ports, 12-bit ADC, timers/PWM, USART, SPI, I2C, and the 3.3V-only pins to watch out for.
STM32 Nucleo Pinout: Arduino Headers, Morpho Connectors, and GPIO Explained
Complete STM32 Nucleo pinout reference: Arduino-compatible headers vs ST Morpho connectors, the built-in ST-LINK debugger, ADC voltage limits, and every peripheral pin mapped.