Files
julian 1cba9f30bc
Firmware / build (push) Successful in 10m49s
Reverse lights on DO0, Sport + Vehicle screens, per-DDE live data, ECU identification
- ReverseLight: isolated output DO0 (CH422G OC0 -> PC817 -> NPN sink) drives the
  reverse-lamp relay while the lever is in R on a live bus with ignition on; 10 Hz
  decision confirmed over 200 ms, written through the panel library's expander
  object so the backlight cannot undo it; `reverse status|on|off|force` console,
  default ON (NVS `revlight_en`). Wiki page reverse-lights-output with the wiring.
- Sport screen: BMW-style power + torque gauges (lv_meter on a dial-face image,
  image needle); PNG sources in assets/, tools/png2lvgl.py converter.
- Vehicle: final drive ratio + tyre circumference -> road speed, hp from torque;
  Settings > Vehicle page; `vehicle` console.
- Bench simulation (`sim` console) overlays torque / rpm / shaft on the snapshot.
- EcuIdent: KWP 1A 86 / 1A 80 read once, stored in NVS, shown on Settings >
  Vehicle, passive ECU CHANGED? check; `ecu` console.
- Ignition fallback from the 0x1D2 lever byte on buses without 0x3B4 (Patrol 2).
- Engine data: per-DDE `2C 10` identifier profiles (Patrol 1 vs Patrol 2
  rail 00C2 / boost 003A / battery 002F); DiagProbe liveConfigure().
- Wiki: Patrol 2 captures, vehicles page, obd identifier table per DDE, logs.
2026-10-28 16:46:42 +01:00

5.8 KiB

ESP32-S3-LCD-5B - PlatformIO Version

Automotive display controller for Waveshare ESP32-S3-Touch-LCD-5B (1024x600 RGB LCD).

Features

  • ✅ CAN bus - decodes the BMW M57N / ZF 6HP powertrain frames (gear, temperatures, rpm, ...)
  • ✅ Link to Inst. Cluster - data + gauge config @ 5 Hz over RS485 (UART1) and ESP-NOW
  • ✅ Screens - Driveline (boot), Sport (torque + power gauges), Engine data, Settings (Wi-Fi / Updates / System / Vehicle), Gauge Tuning; LVGL 8.4.0, hand-coded
  • ✅ Wi-Fi - one remembered network, joined at boot
  • ✅ OTA updates - signed releases from Gitea, installed from the Settings screen
  • ✅ Reverse lights - the isolated output DO0 switches a relay while the lever is in R
  • ✅ Settings persistence - NVS
  • ✅ FreeRTOS - Wi-Fi / UART / CAN on Core 0, LVGL on Core 1

Hardware

  • Board: Waveshare ESP32-S3-Touch-LCD-5B
  • Display: 1024x600 RGB LCD (5-inch capacitive touch)
  • MCU: ESP32-S3 dual-core @ 240MHz
  • Flash: 16MB
  • PSRAM: 8MB OPI PSRAM

Prerequisites

Install PlatformIO

Option A: VS Code Extension (Recommended)

  1. Install Visual Studio Code
  2. Install "PlatformIO IDE" extension from VS Code marketplace

Option B: Command Line

pip install -U platformio

Build & Upload

Full cheat-sheet for both controllers (build, upload, serial monitor, every console command, pairing, releases): docs/COMMANDS.md.

Using PlatformIO CLI

# Navigate to project directory
cd migrate-to-pio

# Build project (first build downloads libraries - takes ~5 min)
pio run

# Upload to board
pio run --target upload

# Monitor serial output
pio device monitor

# Or combine upload + monitor
pio run --target upload && pio device monitor

Using VS Code

  1. Open project folder in VS Code
  2. PlatformIO toolbar will appear at bottom
  3. Click "Build" (checkmark icon)
  4. Click "Upload" (arrow icon)
  5. Click "Serial Monitor" (plug icon)

Project Structure

platformio.ini              # PlatformIO configuration
partition_table.csv         # dual OTA slots (2 x 7.9 MB), NVS, coredump
src/
  main.cpp                  # setup, loop, console routing
  modules/                  # screens, Wi-Fi, link, OTA, tunables, ...
  drivers/can_driver.cpp    # CAN (TWAI)
include/
  config/                   # lv_conf.h, ota_config.h, board config
  display/                  # LVGL port
  protocol/automotive_data.h  # link protocol shared with Inst. Cluster
wiki/                       # project knowledge base

See CLAUDE.md for the architecture.

Configuration

Partition Scheme

Dual OTA (see partition_table.csv):

  • NVS: 20KB (settings, tunables, Wi-Fi) - never move it
  • OTA data: 8KB
  • app0 / app1: 7.9MB each (firmware ~1.7MB)
  • Coredump: 64KB

Edit partition_table.csv to customize partition sizes.

Serial Monitor

  • Baud Rate: 115200
  • Debug Level: Set in platformio.ini → CORE_DEBUG_LEVEL
    • 0 = None
    • 1 = Error (default)
    • 5 = Verbose

Libraries

Dependencies auto-managed by PlatformIO:

  • ESP32_Display_Panel @ 1.0.4
  • ESP32_IO_Expander @ 1.1.1
  • LVGL @ 8.4.0

Built-in ESP32 libraries:

  • WiFi, Preferences, FreeRTOS, TWAI (CAN bus)

Usage

WiFi Configuration

  1. Navigate to Settings screen
  2. Toggle WiFi ON
  3. Wait for network scan (~2-3 seconds)
  4. Select network from list
  5. Enter password (if secured)
  6. Connection status displayed

UART Transmission

  1. Navigate to Settings screen
  2. Toggle UART ON
  3. Data transmits @ 5Hz on:
    • TX: GPIO 43
    • RX: GPIO 44
    • Baud: 115200

Connect UART-to-USB adapter to monitor:

screen /dev/ttyUSB0 115200
# or
minicom -D /dev/ttyUSB0 -b 115200

Debug Metrics

  1. Navigate to Settings screen
  2. Toggle Debug ON
  3. FPS and CPU metrics appear on screen
  4. Updates every 1 second

Troubleshooting

Build Fails

Issue: Libraries not downloading

# Clear library cache and rebuild
pio lib update
pio run --target clean
pio run

Issue: Partition table not found

  • Ensure partition_table.csv exists in project root
  • Check board_build.partitions in platformio.ini

Upload Fails

Issue: Port not detected

# List available ports
pio device list

# Specify port manually
pio run --target upload --upload-port /dev/ttyUSB0

Issue: Permission denied on Linux

sudo usermod -a -G dialout $USER
# Log out and back in

Display Issues

Issue: White flash on boot

  • Normal - backlight control prevents most flashing
  • Optimized in main.cpp setup sequence

Issue: Screen drift (RGB LCD)

  • Handled by high-performance ESP32 libraries
  • Platform packages configured in platformio.ini

Memory Issues

Issue: Heap overflow / crashes

  • PSRAM is enabled in board config
  • Check board_build.psram_type = opi in platformio.ini
  • Verify LVGL buffer size in lvgl_v8_port.h

Performance

  • FPS: ~50 FPS @ 1024x600 resolution
  • CPU Load: ~80% (Core 1 LVGL rendering)
  • WiFi Scan: 1-3 seconds for 10-20 networks
  • UART Overhead: +1-2% CPU @ 5Hz transmission
  • Build Time:
    • First build: ~5-10 minutes (downloads libraries)
    • Incremental: ~10-30 seconds (much faster than Arduino IDE!)

Development

Adding Libraries

Edit platformio.ini → lib_deps:

lib_deps =
    existing/library@1.0.0
    new/library@2.0.0

Changing Debug Level

Edit platformio.ini → build_flags:

build_flags =
    -DCORE_DEBUG_LEVEL=5  ; 0=None, 1=Error, 5=Verbose

Custom Partition

  1. Edit partition_table.csv
  2. Adjust partition sizes (hex values)
  3. Rebuild: pio run

Original Arduino IDE Version

The original Arduino IDE project remains in parent directory for comparison/rollback if needed.

License

Generated with Claude Code - https://claude.com/claude-code