RPLCD
The 16×2 LCD in the shop is an HD44780 display behind a PCF8574 I²C expander — the blue board with a pot on the back, one of the cheapest ways to put text on a project. RPLCD is the library most Pi projects use, and PyRasp ships the real RPLCD 1.4.0 wheel. The official documentation is at rplcd.readthedocs.io.
The wiring is four wires: 5 V, ground, SDA and SCL (GPIO2/GPIO3). The part's own page is the LCD1602 page; for what I²C is, see the bus primer.
Writing text
from wiring import *
pi = Pi()
lcd = LCD1602()
pi.V5 >> lcd.vcc
lcd.gnd >> pi.GND
lcd.sda >> pi.SDA
lcd.scl >> pi.SCLfrom RPLCD.i2c import CharLCD
from time import sleep
lcd = CharLCD('PCF8574', 0x27, cols=16, rows=2)
lcd.write_string("Hello, PyRasp!")
lcd.cursor_pos = (1, 0)
lcd.write_string("21.5\xdfC 48%")
sleep(2)
lcd.clear()write_string() starts at the current cursor and wraps or scrolls according to auto_linebreaks. Moving the cursor is lcd.cursor_pos = (row, column); clear() and home() also work, plus lcd.cr, lcd.lf and lcd.crlf for line control.
The default constructor size in RPLCD 1.4 is 20×4 — pass cols=16, rows=2 for the shop's display. The expander is 'PCF8574' at address 0x27; clones with a PCF8574A answer at 0x3F.
Custom characters
The HD44780 has room for eight user-defined 5×8 glyphs. RPLCD writes them into CGRAM:
heart = [0b00000, 0b01010, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000, 0b00000]
lcd.create_char(0, heart)
lcd.write_string("I \x00 Pi") # \x00 is the first custom glyph
The simulator models the CGRAM, so the custom character appears on the screen like any other.
Backlight
lcd.backlight_enabled = False
lcd.backlight_enabled = True
The simulator tracks the backlight bit: switching it off dims the part in the board view and shows an unlit screen, as on hardware.
Going deeper
RPLCD can also drive an LCD wired directly to GPIO pins (RPLCD.gpio.CharLCD) — that works through the simulator's RPi.GPIO too — but the I²C backpack is the usual way and the only variant the shop sells. The pigpio backend is not available; there is no pigpio module to import.
RPLCD imports the older smbus module first and falls back to smbus2; both resolve to the simulator's I²C bus, and both are on bus 1 only.
Simulator vs real hardware
- The wire protocol is decoded directly, not through a special library. The LCD1602 part implements the PCF8574 expander and the HD44780 instruction set (4-bit mode, DDRAM, CGRAM, backlight bit). RPLCD sends the same bytes it would send on a real display, and any other library that speaks HD44780 over a PCF8574 works too.
- Full byte-level fidelity, no timing. The enable pulse, nibble order and the whole instruction set (display on/off, entry mode, shift, clear, CGRAM) are decoded from the expander bytes, but there are no setup/hold limits and the busy flag is never busy; writes cannot fail because you were too fast. On hardware some clones need small delays, and the busy flag is genuinely slow.
- The screen is text, not pixels. The board view draws the 16×2 character grid with the built-in font; it does not model the contrast pot, viewing angle or the display's own character ROM variants (RPLCD's chr, A00/A02 codecs still select different glyph tables).
- Address clashes are caught. Two powered devices answering at 0x27 produce a warning and the first one wins; on a real bus you would see garbage or NACKs instead.