Skip to content
MCU Atlas
Walkthrough

displayio on LVGL: an ESP32-P4 dashboard in CircuitPython 11

CircuitPython 11.0.0-beta.0 redraws displayio through LVGL on the ESP32-P4. Build a light-sensor dashboard — same displayio API, full code, beta caveats.

By · Published: 11/30/2026 · Updated: 11/30/2026

Flat-vector illustration, late-afternoon desk with a warm two-pane window at the upper left casting a soft beam onto a small green light-sensor module. A dark Metro-class dev board on the bench is wired by six short jumpers to a small TFT display standing landscape, whose screen shows a dark dashboard: two rounded cards — a big blue number 418 and a yellow 31/612 — over a sweeping blue graph, digits only. A white STEMMA QT cable runs from the board to the sensor module. A single coral-lit square (the board's NeoPixel) is the only red accent.

The biggest change in CircuitPython 11 is under the screen, not in your code. On the ESP32-P4 and ESP32-S31, displayio — the display API nearly every CircuitPython screen project already speaks — is now drawn by the LVGL graphics library, with the release notes calling it a "New LVGL-based displayio implementation, currently on ESP32-P4 and ESP32-S31." Your Groups, TileGrids, Bitmaps and labels stay exactly what they were; LVGL does the composing underneath. We built a light-sensor dashboard on the Adafruit Metro ESP32-P4 to show exactly what ports over and what to watch out for.

Read this first: the version pin

This project is pinned to CircuitPython 11.0.0-beta.0, the prerelease published 2026-11-24. It is a beta — the release's own first line says it "has known bugs that will be fixed before the final release of 11.0.0." The current stable CircuitPython is 10.3.2, and it does not contain displayio-on-LVGL. Two more caveats from the release notes themselves: the ESP32-P4 and ESP32-S31 ports "are considered alpha and will have bugs and missing functionality," and displayio.release_displays() is now deprecated in favor of a display's deinit() method. If you want boring and stable today, run the same dashboard on 10.3.2 hardware — the scene-graph code is identical, which is rather the point.

What actually changed under the hood

The Python-facing promise is blunt, in the Adafruit newsletter's words: "Existing code works as is: Groups, TileGrids, Bitmaps, Palettes and vectorio shapes use the same API, with LVGL composing the screen." We checked that claim against the firmware source rather than taking it on faith: the displayio module's export table — Bitmap, ColorConverter, Colorspace, Group, OnDiskBitmap, Palette, TileGrid — is byte-identical between the 10.3.2 and 11.0.0-beta.0 tags (we diffed shared-bindings/displayio/__init__.c from both). For the classes this dashboard uses, the beta's changes are additive: Group scale now accepts fractional values, and vectorio.Rectangle grew a radius keyword for rounded corners. (One real break elsewhere in displayio: OnDiskBitmap now takes only a filename, not an open file — per the release notes' upgrade warnings; it doesn't touch this build.)

What about the chip? The ESP32-P4 integrates a "hardware Pixel Processing Accelerator (PPA) and 2D-DMA, ideal for GUI development," per Espressif — and the newsletter notes the new backend's "internal formats are ready for the graphics accelerators in chips like the ESP32-P4." Read that carefully: today LVGL composes in software on these boards, with buffer formats deliberately chosen so the P4's accelerator hardware can take over later. It is a promise with a silicon path, not a benchmark — which is why this article makes no speed claims.

Before / after: proof the API didn't move

This hello-world compiles and runs unchanged on CircuitPython 10.3.2 (any board with an ILI9341 SPI TFT) and on 11.0.0-beta.0 on the ESP32-P4. The only line you delete when porting older tutorials is displayio.release_displays() — deprecated in 11, slated for removal in 12.0.0:

# hello-displayio.py — the "before / after" proof
# This file compiles and runs UNCHANGED on:
#   - CircuitPython 10.3.2 (stable) on any board with an ILI9341 SPI TFT
#   - CircuitPython 11.0.0-beta.0 on ESP32-P4 / ESP32-S31 (LVGL displayio)
# Pin names are for the Adafruit Metro ESP32-P4; on another board, change
# board.D9 / board.D10 to that board's D/C and CS pins — that is a wiring
# difference, not an API difference.

import board
import displayio
import terminalio
from fourwire import FourWire

from adafruit_display_text import label
import adafruit_ili9341

# The ONE line that differs when porting old tutorials to 11.0.0-beta.0:
# delete `displayio.release_displays()` if your old code called it —
# it is deprecated in favor of `display.deinit()` and disappears in 12.0.0.

spi = board.SPI()
display_bus = FourWire(spi, command=board.D9, chip_select=board.D10)
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

splash = displayio.Group()
display.root_group = splash

bitmap = displayio.Bitmap(320, 240, 1)
palette = displayio.Palette(1)
palette[0] = 0x00FF00
splash.append(displayio.TileGrid(bitmap, pixel_shader=palette))

text = label.Label(
    terminalio.FONT, text="Hello World!", color=0xFFFF00, x=90, y=110
)
splash.append(text)

while True:
    pass

One honest wrinkle: code from CircuitPython 8 or earlier also needs the display-bus import rename (displayio.FourWire became fourwire.FourWire) — that change landed in the 9.x era, so anything written for 9 or 10 already uses the new import, and the port is just the one-line deletion above. Pin names (board.D9, board.D10) are wiring, not API — swap them for your board's D/C and CS.

Parts list

PartRolePrice (dated, checked)
Adafruit Metro ESP32-P4 HydraThe MCU — RISC-V, 16 MB PSRAM, ESP32-C6 WiFi coprocessor$34.95, out of stock at Adafruit (checked 2026-11-30)
2.8–3.2in ILI9341 TFT with XPT2046 touchThe display — 240×320 over four-wire SPIAdafruit's 2.8" breakout $29.95 in stock (checked 2026-11-30); generic modules typically $8–15 per our catalog's structured estimate
BH1750 ambient light sensor (GY-302)The sensor — lux over I²C, address 0x23a few dollars as the GY-302 module
Breadboard, jumper wires, USB-C data cableassembly—

The catch of the moment: displayio-on-LVGL currently exists only on ESP32-P4 and ESP32-S31 boards, and hobbyist P4 boards are scarce. Adafruit's page also notes the current Metro ships the "v1" chipset, not the newer "v3" P4X. The same dashboard runs on any ESP32-S31 board that gets a beta.0 build — remap the pins and everything else holds. The TFT's touch controller is unused here; you buy the module for its panel.

Wiring

Everything is 3.3 V logic. The ILI9341's pins are silk-screened; the Metro's come straight from its pins.c:

Metro ESP32-P4 pin (GPIO)TFT pinNote
SCK (GPIO15)SCKboard.SPI()
MOSI (GPIO16)SDI / MOSIboard.SPI()
D10 (GPIO10)CSchip select
D9 (GPIO9)D/Cdata/command
3V3VCC and LEDbacklight
GNDGND
—MISO / SDOleave unconnected (touch/SD only)
Wiring diagram on paper: a dark Metro ESP32-P4 board card at the left with pins 3V3, GND, SCK (GPIO15), MOSI (GPIO16), D9 (GPIO9), D10 (GPIO10) wired by six curved jumpers to a cream 2.8-inch ILI9341 TFT card's VCC+LED, GND, SCK, SDI/MOSI, D/C and CS pins; MISO/SDO is marked unconnected; a white dotted STEMMA QT cable runs from the board's bottom connector to a green BH1750 (GY-302) sensor card; wiring notes at the bottom left and a coral 3V3-only badge at the top right.
Wiring: the ILI9341 on four-wire SPI plus power, and the BH1750 on the STEMMA QT / I2C connector — 3.3 V logic throughout.

The BH1750 (GY-302) goes on I²C: a STEMMA QT cable into the Metro's connector is easiest; otherwise SDA (GPIO33) → SDA, SCL (GPIO32) → SCL, 3V3 → VCC, GND → GND. Its address is 0x23 with ADDR low.

Flash it, then the libraries

  1. Download the 11.0.0-beta.0 UF2 for adafruit_metro_esp32p4 from the board's firmware page (the direct en_US link is on that page; it returned HTTP 200 as we wrote this).

  2. Double-reset into the bootloader, drag the UF2 onto METROP4BOOT.

  3. From the current Adafruit CircuitPython Bundle, copy adafruit_ili9341.mpy, adafruit_display_text/ and adafruit_bh1750.mpy to lib/. We tested against the current library releases — ILI9341 driver 2.0.4, Display Text 5.0.6, BH1750 1.1.19 — and the beta's release notes promise that "CircuitPython libraries from the 10.x bundles are still compatible with CircuitPython 11.0.0 builds."

  4. Save the dashboard below as code.py on CIRCUITPY and it starts on boot.

The dashboard

Two sensor tiles — live lux and session min/max — over a sweeping live graph, all plain displayio. Rounded cards are vectorio.Rectangle with the new radius keyword, which the newsletter flags as needing "far less memory than bitmaps for dashboard-style widgets"; the graph is a one-bit bitmap drawn column by column, scroll-by-erase, so nothing is ever copied. Scale is logarithmic and auto-ranging, because room light spans three decades between moonlight and desk lamp.

Mock-up of the 320x240 dashboard screen rendered from the project's own code layout with CircuitPython's terminal font: header LIGHT DASHBOARD with a small right-aligned CP 11.0.0-beta.0 label that fits inside the screen edge; two cards — LUX NOW with a large blue 418 and MIN / MAX with yellow 31 / 612; a live graph panel with a blue column sweep.
Illustration rendered from the code's own layout and fonts — not a photograph of a screen.
# code.py — light dashboard on the CircuitPython displayio / LVGL backend
# Target board: Adafruit Metro ESP32-P4
# Firmware: CircuitPython 11.0.0-beta.0 (prerelease, 2026-11-24) — ESP32-P4 uses
#   the new LVGL-based displayio; the displayio API is unchanged.
# Libraries (current releases, from the CircuitPython bundle):
#   adafruit_ili9341 2.0.4 · adafruit_display_text 5.0.6 · adafruit_bh1750 1.1.19
# Wiring: ILI9341 SPI TFT on board.SPI() (SCK/MOSI), CS->D10, D/C->D9;
#   BH1750 (GY-302) on the STEMMA QT / I2C header (SDA/SCL), address 0x23.

import board
import math
import time
import displayio
import terminalio
import vectorio
from fourwire import FourWire

import adafruit_ili9341
from adafruit_display_text import label
import adafruit_bh1750

# ---------------------------------------------------------------- display bus
# Ordinary four-wire SPI — the same construction as on CircuitPython 9.x/10.x.
# On 11.0.0-beta.0 the LVGL backend composes this display behind the same API.
spi = board.SPI()
display_bus = FourWire(spi, command=board.D9, chip_select=board.D10)
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

# ---------------------------------------------------------------- sensor
sensor = adafruit_bh1750.BH1750(board.STEMMA_I2C())

# ---------------------------------------------------------------- dashboard
# Everything below is plain displayio: Groups, vectorio shapes, a Bitmap
# graph and labels. Nothing here knows about LVGL.
root = displayio.Group()
display.root_group = root

palette = displayio.Palette(6)
palette[0] = 0x0F1B2D  # screen background
palette[1] = 0x1B2B44  # card fill
palette[2] = 0x5AC8F2  # accent (graph line, big value)
palette[3] = 0xEAF2FF  # primary text
palette[4] = 0x39536E  # grid lines / secondary text
palette[5] = 0xF2C94C  # min/max markers

# Screen background (rounded corners need vectorio on 11.0.0-beta.0:
# vectorio.Rectangle grew a `radius` keyword — far cheaper than a bitmap).
root.append(
    vectorio.Rectangle(
        pixel_shader=palette, width=320, height=240, color_index=0
    )
)

# Header
root.append(
    label.Label(
        terminalio.FONT,
        text="LIGHT DASHBOARD",
        color=0xEAF2FF,
        x=12,
        y=14,
    )
)
root.append(
    label.Label(
        terminalio.FONT,
        text="CP 11.0.0-beta.0",
        color=0x39536E,
        x=196,
        y=14,
    )
)

# Card: current lux (big number)
root.append(
    vectorio.Rectangle(
        pixel_shader=palette, width=140, height=104, x=8, y=30,
        color_index=1, radius=8,
    )
)
root.append(
    label.Label(terminalio.FONT, text="LUX NOW", color=0x39536E, x=20, y=44)
)
value_label = label.Label(
    terminalio.FONT, text="0", color=0x5AC8F2, scale=4, x=20, y=78
)
root.append(value_label)

# Card: session min / max
root.append(
    vectorio.Rectangle(
        pixel_shader=palette, width=140, height=104, x=172, y=30,
        color_index=1, radius=8,
    )
)
root.append(
    label.Label(terminalio.FONT, text="MIN / MAX", color=0x39536E, x=184, y=44)
)
minmax_label = label.Label(
    terminalio.FONT, text="-- / --", color=0xF2C94C, scale=2, x=184, y=80
)
root.append(minmax_label)

# Graph panel
root.append(
    vectorio.Rectangle(
        pixel_shader=palette, width=304, height=96, x=8, y=140,
        color_index=1, radius=8,
    )
)
root.append(
    label.Label(
        terminalio.FONT,
        text="LIVE GRAPH · one sample every 2 s · auto-scaled",
        color=0x39536E,
        x=20,
        y=154,
    )
)

# The graph itself: one 1-bit-per-pixel bitmap drawn as a TileGrid.
# 296 x 64 px, plotted sweep-style: a cursor column advances, clears the
# 12 px ahead of it, and drops one pixel for the new sample.
GRAPH_W = 296
GRAPH_H = 64
GRAPH_X = 12
GRAPH_Y = 164
graph = displayio.Bitmap(GRAPH_W, GRAPH_H, 2)
graph_palette = displayio.Palette(2)
graph_palette[0] = 0x1B2B44  # matches the card fill: erased pixels vanish
graph_palette[1] = 0x5AC8F2  # sample line
root.append(
    displayio.TileGrid(graph, pixel_shader=graph_palette,
                       x=GRAPH_X, y=GRAPH_Y)
)

# Grid lines inside the graph (four horizontal rules, drawn once)
for gy in (16, 32, 48):
    for gx in range(0, GRAPH_W, 2):
        graph[gx, gy] = 0  # index 0 is the card fill color: invisible rule
# (kept explicit: Bitmap.__setitem__ with the palette index)

# ---------------------------------------------------------------- loop
SAMPLE_S = 2.0          # seconds between samples
CURSOR_CLEAR = 12       # pixels erased ahead of the cursor
cursor_x = 0
lowest = None
highest = None
log_max = 1.0           # running top of scale, log10
last_sample = time.monotonic()

def to_y(lux):
    """Map a lux reading to a graph row (log scale, bottom-anchored)."""
    scaled = math.log10(max(lux, 1.0)) / log_max
    row = int((1.0 - min(scaled, 1.0)) * (GRAPH_H - 1))
    return row

def draw_column(x, row, color_index):
    """Draw a vertical sample trace: line from bottom to the sample row."""
    for y in range(GRAPH_H - 1, row - 1, -1):
        graph[x, y] = color_index

while True:
    now = time.monotonic()
    if now - last_sample < SAMPLE_S:
        continue
    last_sample = now

    lux = sensor.lux

    # erase ahead of the cursor (sweep-style scrolling, no bitmap copy)
    for dx in range(CURSOR_CLEAR):
        x = (cursor_x + dx) % GRAPH_W
        for y in range(GRAPH_H):
            graph[x, y] = 0

    # auto-scale the log top of scale, and track min / max
    if lowest is None or lux < lowest:
        lowest = lux
    if highest is None or lux > highest:
        highest = lux
    needed = math.log10(max(highest, 10.0))
    if needed > log_max:
        log_max = needed  # (scale only grows; the old trace stays put)

    value_label.text = "%d" % int(lux)
    minmax_label.text = "%d / %d" % (int(lowest), int(highest))

    draw_column(cursor_x, to_y(lux), 1)
    cursor_x = (cursor_x + 1) % GRAPH_W

Two implementation notes. The graph never shifts the bitmap — a cursor column advances and erases the twelve pixels ahead of it, oscilloscope-style — almost no RAM, no tearing. And the min/max tile is your reality check: when the trace jumps, the numbers tell you whether the light changed or the log scale re-ranged.

What to watch out for

RAM. The PR that added the backend says it plainly: "The LVGL implementation is focused on speed instead of memory footprint," and "LVGL may run out of memory during compositing and is hard to recover from. A new safe mode is added for this case." The newsletter's version: "The speed costs RAM, so code that ran slowly before may now run out of memory, and a new safe mode says so when it happens." The Metro's 16 MB of PSRAM gives room most boards never had, but the habit transfers: prefer vectorio shapes to bitmaps, keep bitmaps 1-bit, and treat a safe-mode screen after an edit as a RAM problem, not a crash.

E-paper. An LVGL implementation of EPaperDisplay landed in this same beta, but it is one of the newest pieces of the tree — this project deliberately stays on a TFT. If you need e-paper, stay on the classic displayio path until the LVGL one has some miles on it.

Alpha port. P4/S31 boards are alpha-status ports in the release notes. Expect rough edges that are not your bug.

Honesty split, per our house rule

What MCU Atlas verified first-hand on 2026-11-26, no hardware attached: both code files above compile clean under the mpy-cross cross-compiler built from the 11.0.0-beta.0 release tag itself; every board pin, displayio/vectorio/fourwire attribute and library constructor they use was checked against that tag's source tree and the current library releases (script in sources/api_check.py); the firmware UF2, product pages and every cited link returned HTTP 200 the same day. What we did not do: run this on a Metro ESP32-P4. Every performance and behavior statement above is attributed to the CircuitPython release notes, the PR, the Adafruit newsletter or Espressif — none of it is our measurement, and no speed or latency figures appear here. Treat the pin map as verified-from-source, not tested-on-a-breadboard.

Where to take it next

Add a second I²C sensor — temperature or CO₂ — and the tile grid extends itself. The TFT's XPT2046 touch is sitting unused on its own SPI bus; wiring it up and making the graph touch-to-rescale is the natural v2. When a stable CircuitPython 11 lands, revisit: half the caveats above should evaporate, and the code shouldn't change a line.