Skip to content

Start your own ESPHome screen from this project

You want a Home Assistant dashboard on an ESP32 touch screen with ESPHome and LVGL, but not this exact tablet. This page says what you can take from this project, how a second board was added to it, and what only holds on the M5Stack Tab5 and the ESP32-P4. Everything below was built and run on two ESP32-P4 boards (the M5Stack Tab5 and the Waveshare ESP32-P4 7B); nothing was tried on another chip.

What you can reuse as it is

The code rules. Ten numbered rules, each born from a real bug or a slow screen, most of them checked by a test (tools/check_tab5_code_rules.py, run by pytest). Seven of them hold for any ESPHome + LVGL firmware; the full text is in Tab5/AGENTS.md:

Rule Why it matters on any ESPHome + LVGL screen
1. No colour set on a widget, a role style instead ESPHome freezes a text_color: / bg_color: at compile time: a theme can only change colours that come from a shared style
2. A sensor: never touches lv_obj_*, it calls a named C++ function the drawing logic stays in one place and can be tested (ADR-0006)
3. No static inside a lambda for shared state each lambda is a separate function: use globals:
4. No std::string by value in a hot path sliders and frequent updates allocate on every call otherwise
5. A widget repeated three times or more goes through a builder or an !include with vars one fix instead of N copies
9. Every MDI icon shown is in its font's glyphs:, every glyph listed is shown a missing glyph draws an empty box, with no build error
10. Our C++ is called from a lambda: action, never from an event field or an "apply" action value since ESPHome 2026.10.0 those values are written before the includes: and do not see your C++ (esphome/esphome#21303)

The three others are this project's own choices: the shared popup chrome (rule 7, ADR-0009), no Home Assistant entity or action in the firmware, only events (rule 8, ADR-0025), and esphome compile before every commit (rule 6). They are worth copying, but your project can live without them.

The design decisions that do not depend on the board (all of them):

  • ADR-0001: Home Assistant pushes what changed, the screen never polls.
  • ADR-0003: one service call carries a whole list as a delimited string, instead of one call per value.
  • ADR-0004: no PNG with transparency, backgrounds baked opaque.
  • ADR-0019: the screen knows slots, a Home Assistant blueprint maps them to your entities; changing a light needs no flash.
  • ADR-0020: no secret in the firmware, Home Assistant provides the API key, updates are signed.
  • ADR-0021: the screen is drawn on a PC (ESPHome's host platform, stubbed hardware), so every change is seen without the device.
  • ADR-0025: the screen sends events; one Home Assistant package maps them to a list of allowed actions.
  • ADR-0029: one C++ palette and role styles, so themes change at run time.
  • ADR-0046: one shared brick for popups with pages swiped left and right.
  • ADR-0063: several screens in one home, each with its own name.

The troubleshooting log. Known incidents labels each of its 20 incidents: 11 apply to any ESPHome + LVGL screen (Home Assistant side, ESPHome's API, the LVGL schema, the build), 9 are specific to the Tab5 or the ESP32-P4. Read the first kind before you debug your own screen.

The way to code with an AI. This project was written with AI agents, and the method is in the files:

  • an AGENTS.md at the root (read first, rules, boundaries), one per folder for its detail, and a CLAUDE.md beside each that only imports it, so every tool reads the same text;
  • an [AI-CONTEXT] block at the top of each firmware file (role, constraints), [AI-WARNING] on a deliberate fix that looks like a bug, so that an audit does not "correct" it back, [AI-DEBUG] on a good observation point (debugging);
  • the decisions in docs/decisions/ and the incidents in troubleshooting, so that a question already settled is not asked again;
  • tests that read the real YAML and C++ (code rules, popup chrome, line counts of CARTOGRAPHIE_TAB5.md), so a rule written in AGENTS.md is also checked.

How a second screen was added: the Waveshare 7B

The Waveshare ESP32-P4-WIFI6-Touch-LCD-7B (7 inches, 1024×600) runs the same firmware as the Tab5 (5 inches, 1280×720) since 2026-10-14. How it was done, in ADR-0061:

  1. One substitution picks the board: tab5_carte (tab5 by default, waveshare-7b) loads Tab5/paquets/carte-<board>.yaml, the hardware of that board, and geometrie-<board>.yaml, its screen size, panel size, LVGL rotation and font scale. Building for the 7B: python -m esphome -s tab5_carte waveshare-7b compile tab5-ha-hmi.yaml.
  2. The size is written once: the layout tokens derive from it, and the C++ gets it through build flags (-DTAB5_ECRAN_L, -DTAB5_ECRAN_H). A test checks the C++ against the tokens for every board.
  3. Hardware the new board lacks keeps its ids, as stubs (battery gauge, clock chip, power switches): the other packages do not change, and Home Assistant finds the same entities.
  4. The layout is the Tab5's, scaled: every position x × L / 1280, y × H / 720; large fonts scaled by 0.82, small ones kept readable; a few texts moved where they no longer fitted.
  5. Then the board itself: panel mounted upside down, ESPHome 2026.9.1 at least, PSRAM at 200 MHz.

The ADRs that followed are what a board can change: ADR-0005 (the boot delay comes from the board), ADR-0064 (how each panel really turns off), ADR-0065 (games as an optional module, off on a board without a motion sensor, tab5_jeux), ADR-0069 (screen direction set from Home Assistant). The board page: Waveshare 7B; side by side: Tab5 or 7B.

For a third ESP32-P4 board, the same path: a carte-<board>.yaml and a geometrie-<board>.yaml, stubs for what is missing, then the off-device render at its size. Not tried.

What only holds on the ESP32-P4 and the Tab5

  • The display link: both boards drive a MIPI-DSI panel; ESPHome's mipi_dsi page describes it as the interface « available in the ESP32-P4 ».
  • Wi-Fi through a co-processor: the ESP32-P4 has no radio of its own (« ESP32-P4 does not include built-in Wi-Fi or Bluetooth », ESP-IDF); Wi-Fi comes from an ESP32-C6 over SDIO, ESPHome's esp32_hosted. Two incidents of the troubleshooting log come from that link.
  • The hardware JPEG decoder of the P4 (ESP-IDF) decodes the camera pictures.
  • The rotation: the Tab5's panel is portrait, turned by LVGL (rotation: 270); on the ESP32-P4 that software rotation uses the PPA, the P4's 2D accelerator (ESPHome lvgl).
  • The Tab5's own hardware: the display reset behind an I/O expander (1 s at boot), the battery charger and gauge, the motion sensor of the tilt games, the three display revisions (hardware, pinout, battery).
  • This project's Home Assistant side: the « Tab5 » integration for HACS, the blueprint and the packages are written for this firmware's contract.

And an ESP32-S3?

Not tried in this project: nothing here was built or run on an ESP32-S3. What official sources say, read on 2026-11-19:

Point What the source says Source
LVGL in ESPHome needs « an ESP32 or RP2040 »; PSRAM « generally recommended », especially for large colour displays esphome.io/components/lvgl
ESP32-S3 in ESPHome listed among the supported ESP32 variants esphome.io/components/esp32
Parallel RGB panels mipi_rgb « requires an ESP32 (usually an ESP32-S3…) », with PSRAM esphome.io/components/display/mipi_rgb
Wi-Fi the ESP32-S3 has « integrated 2.4 GHz, 802.11 b/g/n Wi-Fi »: no co-processor, no esp32_hosted espressif.com, ESP32-S3
MIPI-DSI on the ESP32-S3 none: in ESP-IDF v5.5.5, SOC_MIPI_DSI_SUPPORTED is declared for the ESP32-P4 and absent for the ESP32-S3, which declares SOC_LCD_I80_SUPPORTED and SOC_LCD_RGB_SUPPORTED (read on 2026-11-19) soc_caps.h, ESP32-S3, soc_caps.h, ESP32-P4
Hardware JPEG decoder on the ESP32-S3 none: in ESP-IDF v5.5.5, SOC_JPEG_CODEC_SUPPORTED is declared for the ESP32-P4 and absent for the ESP32-S3 (read on 2026-11-19) soc_caps.h, ESP32-S3, soc_caps.h, ESP32-P4
Voice (micro_wake_word, voice_assistant) on the ESP32-S3 not verified (the component pages name no chip) micro_wake_word, voice_assistant

So on an ESP32-S3 the board package (display, touch, Wi-Fi) would be written from scratch; the rules, the design decisions, the Home Assistant side and the method above do not depend on the chip. Whether this firmware's screens, fonts and memory fit an ESP32-S3: not verified.