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

TargetDescriptionUse 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)
The repeater runs on the same ESP32 hardware but without motors or balance control. It bridges the web app (BLE) to all robots on the field (RF).

Architecture

FreeRTOS Tasks

TaskCorePriorityStackPurpose
BalanceControl 1516 KB IMU reading, PID loops, motor output, fall detection
CC1101Task 028 KB RF receive/transmit, message processing
Arduino loop 11 BLE, serial, controller input, LED updates, battery/temp

Balance Controller

The balance system uses cascaded PID controllers running at high priority on Core 1:

ControllerPIDPurpose
Stability0.461.30.009Primary pitch stabilization
Velocity0.0150.0010Forward / backward speed
Steering0.0200Left / right turning
Crawl0.00400Low-speed crawling when fallen
Target pitch-0.61 rad
Fall threshold±0.8 rad
Max velocity30 (normal) / 40 (boost)
Motor controlFOC via SimpleFOC 2.3.2

Communication Protocol

All RF messages use a common frame: start canary 0xAB, payload, 16-bit checksum, end canary 0xCD.

MessageIDSizeDirectionPurpose
PING0x0157 BRobot → allStatus broadcast every 750 ms
UPDATE_STATUS0x0218–243 BHQ → robotsLED / speed / torque commands
SCAN0x0311 BRobot → nearbyProximity detection burst
PING carries: battery voltage, controller type, robot name, temperatures, firmware version, LED states, speed/torque, fall status, and nearby robot IDs.

UPDATE_STATUS carries per-robot LED colors and speed/torque coefficients for up to 16 robots in a single packet.

Timing

Ping interval750 ms + 20% jitter
Triggered ping<100 ms after update
TX retries3 per message
Scan burst1.5 s duration, 200 ms interval

Libraries

LibraryVersionPurpose
SimpleFOC2.3.2BLDC field-oriented control
FastLED3.10.1WS2812B LED control
SparkFun ATECCX08a1.3.1Crypto chip driver
Adafruit TMP1171.0.3Temperature sensor driver
RadioLibbundledCC1101 radio driver
Bluepad32bundledBluetooth gamepad stack

LED Indication

ConditionLED PositionColor
Normal operationBottom LEDs Off
Low batteryBottom LEDs Yellow
OverheatingBottom LEDs White
Motors disabledBottom LEDs Red
Temp sensor failureBottom LEDs Pink
Scan detectedEyes Magenta (1.5 s)

Flashing

Via USB (HQ Serial Dev Tool)

  1. Open Robomates HQ → Serial Dev page
  2. Connect the robot via USB
  3. 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