Firmware
The Robomates firmware runs on an ESP32 and handles everything from self-balancing to wireless communication. Built with PlatformIO using the Arduino framework.
View on GitHub →Features
Self-Balancing
PID-based pitch stabilization using an MPU6050 IMU and field-oriented control (FOC) of two BLDC motors
Sub-GHz Radio
CC1101 transceiver at 869.525 MHz for inter-robot communication with ~50 m range
BLE Connectivity
Connects to the web app and gamepads simultaneously via Bluepad32 dual-mode stack
Hardware Crypto
ATECC508A chip gives each robot a unique ECDSA P-256 identity for authentication
Fall Detection
Automatic detection when a robot tips over, with 150 ms debounce for reliable triggering
Proximity Scanning
RSSI-based close-range detection between robots for games like Zombie Tag
Temperature Monitoring
Three TMP117 sensors on main and motor boards with automatic overheat protection
Gamepad Support
PS5, PS4, Xbox, Switch Pro, Joy-Con, and more via Bluetooth Classic
Build Targets
Three firmware variants built from the same codebase
| Target | Description | Use Case |
|---|---|---|
robot |
Standard robot firmware | Normal gameplay |
robot_certification |
Certification / pairing mode | Initial setup — registers the crypto key |
repeater |
RF-to-BLE bridge | Relays between the web app (BLE) and robots (RF) |
Architecture
FreeRTOS Tasks
| Task | Core | Priority | Stack | Purpose |
|---|---|---|---|---|
| BalanceControl | 1 | 5 | 16 KB | IMU reading, PID loops, motor output, fall detection |
| CC1101Task | 0 | 2 | 8 KB | RF receive/transmit, message processing |
| Arduino loop | 1 | 1 | — | BLE, serial, controller input, LED updates, battery/temp |
Balance Controller
The balance system uses cascaded PID controllers running at high priority on Core 1:
| Controller | P | I | D | Purpose |
|---|---|---|---|---|
| Stability | 0.46 | 1.3 | 0.009 | Primary pitch stabilization |
| Velocity | 0.015 | 0.001 | 0 | Forward / backward speed |
| Steering | 0.02 | 0 | 0 | Left / right turning |
| Crawl | 0.004 | 0 | 0 | Low-speed crawling when fallen |
Communication Protocol
All RF messages use a common frame: start canary 0xAB, payload, 16-bit checksum, end canary 0xCD.
| Message | ID | Size | Direction | Purpose |
|---|---|---|---|---|
| PING | 0x01 | 57 B | Robot → all | Status broadcast every 750 ms |
| UPDATE_STATUS | 0x02 | 18–243 B | HQ → robots | LED / speed / torque commands |
| SCAN | 0x03 | 11 B | Robot → nearby | Proximity detection burst |
UPDATE_STATUS carries per-robot LED colors and speed/torque coefficients for up to 16 robots in a single packet.
Timing
Libraries
| Library | Version | Purpose |
|---|---|---|
| SimpleFOC | 2.3.2 | BLDC field-oriented control |
| FastLED | 3.10.1 | WS2812B LED control |
| SparkFun ATECCX08a | 1.3.1 | Crypto chip driver |
| Adafruit TMP117 | 1.0.3 | Temperature sensor driver |
| RadioLib | bundled | CC1101 radio driver |
| Bluepad32 | bundled | Bluetooth gamepad stack |
LED Indication
| Condition | LED Position | Color |
|---|---|---|
| Normal operation | Bottom LEDs | Off |
| Low battery | Bottom LEDs | Yellow |
| Overheating | Bottom LEDs | White |
| Motors disabled | Bottom LEDs | Red |
| Temp sensor failure | Bottom LEDs | Pink |
| Scan detected | Eyes | Magenta (1.5 s) |
Flashing
Via USB (HQ Serial Dev Tool)
- Open Robomates HQ → Serial Dev page
- Connect the robot via USB
- Select the firmware file and flash
Via PlatformIO
git clone https://github.com/user/robomates-firmware.git
cd robomates-firmware
pio run -e robot -t upload