Skip to the content
PCBKitNew board
2 layers34.1 × 99 mmDuploTrainController NG, the printed circuit board in 3D

ESP32 Remote Controller for Lego DUPLO Trains with Record/Replay Function

Size
34.1 × 99 mm
Copper layers
2
Thickness
1.6 mm
Parts
16
Nets
26
Pads
67
Tracks, vias
55, 0
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
7 Dec 2025
Updated
16 Jul 2026

Overview

DuploTrainController NG is an open-source printed circuit board by rzuehlsd, from the rzuehlsd/DUPLO_Train_Remote_Controller repository on GitHub. It is a 2-layer board of 34.1 × 99 mm with 16 parts on 26 nets, routed with 55 tracks and 0 vias.

Its parts include 7 resistors, 7 switches, 1 capacitor and 1 IC. It belongs with the radio and wireless boards and the ESP32 boards of this library.

README

README.md

DUPLO Train Controller NG

ESP32-S3-based handheld controller for LEGO DUPLO trains, implementing BLE communication, deterministic command handling, replay/record, sensor routing, and low-power sleep/wake behavior.

LEGO and DUPLO are trademarks and copyrighted properties of the LEGO Group. This project is an independent, community-driven development and is not affiliated with, authorized, endorsed, or sponsored by the LEGO Group.

Overview

This repository contains the complete implementation package for the controller:

  • firmware sources for application logic and BLE runtime
  • schematic/PCB design files and manufacturing outputs
  • OpenSCAD enclosure sources and 3D-print assets

The target hardware is an ESP32-S3 board with one RGB status LED, six front-panel buttons connected through an ADC resistor ladder, and one rotary encoder with push button.

At runtime, the firmware separates BLE processing from UI/control logic and uses queue-based cross-task communication. The resulting behavior is:

  • non-blocking command flow during connect/reconnect phases
  • explicit distinction between BLE link-up and application-ready state
  • stable reconnect behavior after train power-cycle
  • deterministic replay/record using fixed-size command buffering
  • power management with controlled sleep entry and defined wake path

Overview Demo Video

The short feature demonstration is available here:

DuploTrain demo preview

Hardware Gallery

Controller and PCB 3D View

DUPLO Train Controller in blue enclosure Controller board 3D view

Schematic

Controller schematic

Manufacturing Note

I have been using PCBWay for PCB manufacturing for many years and have consistently had a great experience with production quality, lead time, shipping reliability, and overall pricing.

For this controller revision, I also used the PCB assembly service. The result was especially positive: when I made a few minor part-selection mistakes in the BOM, PCBWay engineering proactively reached out, clarified the issues, and helped resolve everything quickly before production. For future, more complex designs, especially boards with a higher SMD component density, this assembly workflow is now my preferred path.

Current Feature Status

Implemented features (high level):

  • automatic BLE connection to the DUPLO train
  • reconnect after train power-cycle in about 2 to 3 seconds in practice
  • command acceptance immediately after reaching ready state
  • thread-safe separation of UI logic and BLE communication
  • record/replay of user interactions with timestamps
  • sensor processing for color, speed, and voltage
  • color sensor debouncing via stability timer
  • sleep after 5 minutes of inactivity
  • wake via encoder button, including RTC and GPIO fallback
  • upload window only with intentional encoder hold during startup

Status-LED

The controller LED indicates the current state as follows:

  • Yellow blinking: controller is booting
  • Blue blinking: BLE link is up, hub initialization still running
  • Green blinking: hub is operational and commands can be executed
  • Green occasional short pulses: operational and idle
  • Violet blinking: recording active
  • Yellow blinking: replay active
  • Solid red: emergency stop active
  • Red short blink sequence: train low-voltage warning
  • White blinking: hub disconnected
  • 5x green: wake from sleep confirmed
  • 2x red: sleep entry indication

Important: Green now explicitly means not just "connected" but "ready for commands".

Controls

  • Rotate encoder: set speed reverse, stop, forward
  • Short encoder press: wake from sleep
  • Hold encoder during startup >= 2 s: open 10-second upload window
  • REC: start/stop recording
  • PLAY: play the latest recording once
  • STOP: stop replay/recording and toggle emergency stop
  • LIGHT: cycle train light colors
  • SOUND: cycle sounds
  • WATER: trigger water action

Color Bricks

The following color bricks of the DUPLO Train are also recognized:

  • Yellow: horn
  • Red: stop train
  • Green: stop and switch driving direction
  • White: toggle light
  • Blue: water action, then continue at previous speed

Architecture in Short

  • Core 0: BLE-Task (DuploHub)
  • Core 1: Arduino-Loop (TrainController)
  • Main Loop -> commandQueue -> BLE-Task
  • BLE-Task -> responseQueue -> Main Loop

Details are documented in ARCHITECTURE.md.

Project Structure

Build

Main environment:

bash
platformio run -e esp32-s3-fh4r2

Upload:

bash
platformio run -e esp32-s3-fh4r2 --target upload

Serial monitor:

bash
platformio device monitor --environment esp32-s3-fh4r2

Diagnostic environment for the ADC monitor:

bash
platformio run -e esp32-s3-input-monitor

Hardware Requirements

  • ESP32-S3 board with RGB LED and USB-C charging
  • 6 buttons on an ADC resistor ladder
  • 1 rotary encoder with push button
  • LEGO DUPLO train hub

Implementation Details

  • TrainController.cpp contains the full application logic, input processing, sleep/wake, and UI state.
  • DuploHub.cpp encapsulates BLE lifecycle, queue processing, sensor routing, and replay/record.
  • myLegoHub.cpp contains DUPLO-specific Legoino helper logic.
  • Post-connect hub initialization runs non-blocking in the main loop so the BLE task is not blocked.
  • Reconnect scans use a shorter search window, significantly reducing real-world reconnect time.

Documentation

Open Topics

Currently most relevant:

  • further facade consolidation through myLegoHub
  • potential pairing/preference logic for a preferred train
  • hardware-level controller battery monitoring

The detailed work list is in ToDo.md.

Parts

16
QtyValueFootprintReferences
11.5KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR5
1100nCapacitor_SMD:C_0805_2012MetricC1
113kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR7
12,2kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1
13.3kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR6
1430Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR2
1620Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR3
1910Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR4
1ESP32-S3_SUPERMINI_SMDESP32-S3_SUPERMINI_SMD:MODULE_ESP32-S3_SUPERMINI_SMDU1
1LED CycleButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW5
1PlayButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW2
1RecordButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW1
1Sound CycleButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW6
1Speed / WakeupRotary_Encoder:RotaryEncoder_Bourns_Vertical_PEC12R-3x17F-SxxxxSW0
1StopButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW3
1WaterButton_Switch_SMD:SW_SPST_Omron_B3FS-101xPSW4

Questions

How big is the DuploTrainController NG PCB?

It measures 34.1 × 99 mm and has 2 copper layers, 1.6 mm thick.

What parts does the DuploTrainController NG use?

16 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the DuploTrainController NG KiCad files?

From the rzuehlsd/DUPLO_Train_Remote_Controller repository on GitHub, at the commit this page was made from: the board is hardware/DuploTrainController NG/DuploTrainController NG.kicad_pcb and its schematic hardware/DuploTrainController NG/DuploTrainController NG.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the DuploTrainController NG design in my own project?

Its repository states no licence, so its author keeps all rights: ask rzuehlsd before reusing the design.

Similar boards

  • 2 layers140.5 × 30 mmType e, the printed circuit board in 3D

    Type e

    google/mozc-devices

    Circuit diagrams and firmware source code for Gboard DIY keyboards

    16 parts3kApache-2.0
  • 2 layers41.4 × 14.5 mmU2f zero, the printed circuit board in 3D

    U2f zero

    conorpp/u2f-zero

    U2F USB token optimized for physical security, affordability, and style

    16 parts2.4k
  • 2 layers122 × 37 mmV0-UmbilicalBoard, the printed circuit board in 3D

    V0-UmbilicalBoard

    VoronDesign/Voron-Hardware

    Cool Hardware designed by the Voron Design group

    16 parts1.1kGPL-3.0
  • 2 layers152 × 57.6 mmVideoslotadapter, the printed circuit board in 3D

    Videoslotadapter

    hoglet67/RGBtoHDMI

    Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

    16 parts1kGPL-3.0
  • 2 layers36 × 63.4 mmSmart ringfinal layout, the printed circuit board in 3D

    Smart ringfinal layout

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    16 parts915
  • 2 layers60 × 40 mmHASwitchPlate, the printed circuit board in 3D

    HASwitchPlate

    aderusha/HASwitchPlate

    LCD touchscreen for Home Automation

    16 parts738MIT
  • 2 layers21.1 × 26.9 mmDemo, the printed circuit board in 3D

    Demo

    easyw/kicadStepUpMod

    kicadStepUp: ECAD to MCAD FreeCAD WorkBench

    16 parts704