HubController – ESP32 Command Hub for Embedded Devices
HubController is a lightweight command-based firmware, written in B4R, for the ESP32 designed to control motors, signals, sensors, and LEDs in embedded systems such as model railways, automation hubs, and robotics.
It acts as a central hub: clients send small binary commands over USB serial or BLE, and HubController executes them on connected hardware.
The design focuses on predictable behavior, clean modular architecture, and low-latency command execution resulting in a simple and reliable embedded control node that can be controlled from different platforms.
Overview with Demo Application
HubController Key Features
HubController Binary Protocol (HubBin)
The binary frame is intentionally tiny as 5-bytes only:
Example Run motor with address (10), command set speed (5) and speed (70).
Each device & peripheral has an unique address.
Client applications currently exist in:
Demo Project – RailYard
The current demonstration is RailYard, a LEGO® train and layout control system for schools and fairs:
Source Code
Source code may be published later when the project structure stabilizes.
Next Steps
Personal Note on Development
Creating HubController has been a learning-rich journey, tackling challenges such as:
Disclaimer
LEGO® is a trademark of the LEGO Group of companies which does not sponsor or endorse this project.
HubController is a lightweight command-based firmware, written in B4R, for the ESP32 designed to control motors, signals, sensors, and LEDs in embedded systems such as model railways, automation hubs, and robotics.
It acts as a central hub: clients send small binary commands over USB serial or BLE, and HubController executes them on connected hardware.
The design focuses on predictable behavior, clean modular architecture, and low-latency command execution resulting in a simple and reliable embedded control node that can be controlled from different platforms.
Overview with Demo Application
HubController Key Features
- deterministic command execution
- extremely small binary protocol
- transport-agnostic design
- modular device and peripheral architecture
- cooperative event loop (no blocking)
- designed for embedded reliability
HubController Binary Protocol (HubBin)
The binary frame is intentionally tiny as 5-bytes only:
B4X:
[HDR][ADR][CMD][VAL][FTR]
1B 1B 1B 1B 1B
Example Run motor with address (10), command set speed (5) and speed (70).
B4X:
[0x19] [10] [5] [70] [0x58]
Client applications currently exist in:
- B4J - RailYardGUI (B4XPages, HMITiles, ASyncCanvas), RailYardCommander (B4XPages, HMITiles), RailYardDCCBridge (Console)
- B4A- RailYardCommander (B4XPages, HMITiles)
- Python - RailYardGUI ((PySide6), RailYardDCCBridge (Console)
Demo Project – RailYard
The current demonstration is RailYard, a LEGO® train and layout control system for schools and fairs:
- Controls 1 loco via BLE - Lego City Hub or BuWizz2. Planned Power Functions Motor
- Switches and detectors controlled via USB serial
- Supports simple automated schedules
- Designed to run without Wi-Fi, making it portable and flexible
Source Code
Source code may be published later when the project structure stabilizes.
Next Steps
- Create a custom BLE device: Loco with Power Functions Motor
- Create HarbourYard with crane driven by GeekServo motors
Personal Note on Development
Creating HubController has been a learning-rich journey, tackling challenges such as:
- Designing a strong modular setup with many classes and code modules
- Balancing USB serial vs BLE/Wi-Fi client control
- Handling quirks of ESP32 NimBLE (created rNimBLEClient & rNimBLEServer) vs Arduino BLE libraries for stability
Disclaimer
LEGO® is a trademark of the LEGO Group of companies which does not sponsor or endorse this project.
Last edited: