Reference
HD44780
16x2/20x4 character LCD.
- Connects over
- I²C
- Address
- 0x27 (or 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x3F, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E)
- Made by
- Hitachi
- Datasheet
- sparkfun.com
Use it
hardware {
device hd44780: HD44780
}
every 1s {
hd44780.backlight(1)
}
On its own, the declaration puts the HD44780 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x27. To choose the pins or the address, declare the bus and attach the device: device hd44780: HD44780 on i2c0 at 0x20 with i2c i2c0(sda: 21, scl: 22).
Methods
-
hd44780.backlight(on: uint8_t)
Toggle backlight
-
hd44780.clear()
Clear display
-
hd44780.print(text: const char *)
Print text
-
hd44780.set_cursor(col: uint8_t, row: uint8_t)
Move cursor
-
hd44780.reinit()
Re-initialise the display (recovers garbled characters after noise or a supply dip); redraw afterwards
Wiring
| Pin | Connect to |
|---|---|
VSS | Logic ground |
VDD | 5V logic supply |
V0 | Contrast — wiper of a 10kΩ pot |
RS | Register select (cmd vs data) |
RW | Tie LOW for write-only |
E | Enable pulse |
D4-D7 | Data lines (4-bit mode) |
A/K | Backlight + / − with series resistor |
Specifications
- Characters
- 16×2, 16×4, 20×4 (controller is the same)
- Current
- 1.5 mA logic + LED backlight (~20 mA per LED)
- Interface
- 4-bit or 8-bit parallel, or I²C via PCF8574 backpack
- Voltage
- 5V (logic — 3.3V works on some clones but contrast suffers)
Tips
- Most hobby modules ship with a PCF8574 I²C backpack — much fewer pins. The Volt 'lcd16x2' / 'lcd20x4' drivers wrap this.
- Always include the 10kΩ contrast pot — without it the display looks blank or has black blocks.
- Custom characters: 8 CGRAM slots, 5×8 pixels each.
Alternatives worth knowing:
- SSD1306: 128×64 OLED — much more flexible, sharper, no contrast pot needed.