Hexapod: Build an ESP32-S3 Six-Legged Robot with 18 Dynamixels
The finished Hexapod with its 18 Dynamixel servos, OLED face and LED strip
- Custom ESP32-S3 board (16 MB flash, 8 MB PSRAM)
- 18x Dynamixel XC430-T240BB-T servos
- MPU6050 IMU
- SH1106 128x64 OLED display
- 19x WS2812B LED strip
- I2S DAC / amplifier
- Separate handheld ESP-NOW transmitter
What you will build
Hexapod is a complete six-legged walking robot, not just a firmware sketch. The repository contains the firmware, a custom ESP32-S3 PCB (EasyEDA project, Gerbers, schematic and bill of materials), the Fusion source and STLs for the chassis and legs, and the manuals and inverse-kinematics write-up. Everything you need to reproduce the machine lives in one place.
The finished robot does a lot:
- Inverse kinematics per leg. Each of the six legs solves for coxa, femur and tibia angles from a target foot position, with targets clamped to the reachable workspace.
- Three walking gaits - tripod, tetrapod and ripple - selected on the fly. Step length, step height and ground clearance can be changed from the transmitter while the robot is walking.
- Self-levelling.
LevelGaitreads the IMU and counters chassis tilt so the body stays level on uneven ground while the feet stay planted. - Posing. With the feet planted, the chassis can be translated and rotated in roll, pitch and yaw independently of the legs.
- Animated face. A 128x64 OLED shows eyes that track the joystick, blink and change mood with the robot's state. It doubles as the fault display if something fails at startup.
- Sound and lights. I2S audio for startup, shutdown and error tones, and a 19-LED strip whose effect follows the state machine.
- Power awareness. Servo torque is released after a period of inactivity, and the robot parks itself if the radio link drops.
Why build it? Legged robots are one of the best ways to learn real-time control on a microcontroller. This project gives you a worked, tested reference for running 18 bus servos at 200 Hz on an ESP32-S3, along with a clean split of tasks across both cores. The two linked videos show it levelling on planted feet and changing its walk mid-stride, so you can see what the end result should look like before you start.
\2What you need
The hardware is specified in the README, and the PCB files and bill of materials are in hardware/.
| Part | What | Notes |
|---|---|---|
| Controller | Custom ESP32-S3 board | 16 MB flash, 8 MB PSRAM |
| Servos | 18x Dynamixel XC430-T240BB-T | 3 joints per leg; one half-duplex bus at 3 Mbaud, protocol 2.0 |
| IMU | MPU6050 | I2C, shares the bus with the display |
| Display | SH1106 128x64 OLED | I2C, monochrome |
| LEDs | 19x WS2812B | single data line |
| Audio | I2S DAC / amplifier | 44.1 kHz, 16-bit stereo |
| Transmitter | Separate handheld unit | ESP-NOW, WiFi channel 1 |
The transmitter is its own project in the forgevolt/Transmitter repository, so plan on building two devices. The chassis and legs are 3D printed from the STLs in mechanics/, which also holds print profiles and dimensioned drawings.
Wiring
software/Hexapod/PinMap.h is the single source of truth for every GPIO. The schematic is in hardware/schematic.pdf. The README mirrors the pin map:
| Function | Signal | GPIO |
|---|---|---|
| Dynamixel | RX | 18 |
| Dynamixel | TX | 17 |
| Dynamixel | direction | 16 |
| I2C (display + IMU) | SDA | 8 |
| I2C (display + IMU) | SCL | 9 |
| I2S (audio) | BCLK | 14 |
| I2S (audio) | LRC / word select | 21 |
| I2S (audio) | DOUT | 13 |
| LED strip | data | 11 |
| On/off switch | input | 48 |
| USB sense | input | 10 |
Software
You need the Arduino IDE with esp32 core 3.3.12 (IDF v5.5.5). The firmware does not compile against core 2.x. Install these libraries through the Arduino Library Manager, at the versions the project is built and tested against:
| Library | Version |
|---|---|
| FastLED | 3.10.6 |
| Dynamixel2Arduino | 0.8.2 |
| MPU6050_light (by rfetick) | 1.2.1 |
| U8g2 | 2.36.19 |
| Streaming | 6.3.0 |
| SoundEngine | 1.1.1 |
| ESPNowUtilities | 1.0.1 |
| VectorUtilities | 1.0.0 |
The last three were written for this project and its transmitter; all three are in the Library Manager, so nothing needs installing by hand. Note that several MPU6050 libraries exist - the one used here is rfetick's MPU6050_light.
Typical use cases
A worked example of running inverse kinematics and 18 bus servos at 200 Hz on an ESP32-S3 with tasks pinned across both cores.
Drive it from the separate handheld transmitter over ESP-NOW, switching gaits and tuning step parameters while it walks.
The IMU-based LevelGait keeps the chassis level on uneven ground, and posing mode lets you move the body independently of the feet.
PCB files, Fusion source, STLs, schematic, BOM and manuals are all in the repository, so the whole machine can be reproduced.
How it works
The firmware runs as four FreeRTOS tasks, deliberately split across the two cores so nothing can delay servo timing:
| Task | Priority | Core | Rate | Does |
|---|---|---|---|---|
schedulerTask |
8 | 1 | 200 Hz | the control loop: gait step, IK, servo write |
linkTask |
3 | 0 | - | ESP-NOW send and receive |
peripheralsTask |
2 | 1 | 50 Hz | IMU read, display and LED updates |
fillBuffer |
1 | 1 | - | mixes and queues the next audio chunk (owned by SoundEngine) |
The control loop is the highest priority task. Each cycle it advances the gait, runs inverse kinematics for every leg and writes the resulting angles to the Dynamixel bus. The IK derivation in Leg.cpp follows Jakob Leander's tutorial, and docs/ works it through for this specific leg geometry.
The display and the IMU share one I2C bus, owned exclusively by peripheralsTask. That matters for a practical reason: the display runs the bus at 800 kHz and U8g2 does not restore the previous clock, so the task pulls it back to 400 kHz before every IMU read, because the MPU6050 is not rated above that.
The radio link uses software/Hexapod/RCProtocol.h, which defines the wire format. It is a copy - the master lives in the transmitter repository because the format follows the transmitter's hardware, and Arduino cannot include across sketch folders. cAppProtocolVersion guards against drift: both ends check it on every frame, so a stale copy shows up as a logged mismatch at pairing instead of silently misread data.
Build and flash the firmware
Once the libraries are installed, the Arduino IDE workflow is straightforward:
- Open
software/Hexapod/Hexapod.inoin the Arduino IDE. - Select board ESP32S3 Dev Module.
- Set the Tools menu as in the table below. Four entries differ from the defaults: Flash Size 16 MB, PSRAM OPI PSRAM (8 MB), Partition Scheme Custom and USB CDC On Boot Enabled.
- Upload.
| Tools menu | Setting |
|---|---|
| USB CDC On Boot | Enabled |
| CPU Frequency | 240MHz (WiFi) |
| Core Debug Level | None |
| Events Run On | Core 1 |
| Flash Mode | QIO 80MHz |
| Flash Size | 16MB (128Mb) |
| Arduino Runs On | Core 1 |
| Partition Scheme | Custom |
| PSRAM | OPI PSRAM |
| Upload Mode | UART0 / Hardware CDC |
| Upload Speed | 921600 |
| USB Mode | Hardware CDC and JTAG |
software/Hexapod/partitions.csv sits in the sketch folder and the ESP32 core picks it up in preference to the Tools menu. It defines a 6 MB application partition plus a 9.8 MB LittleFS partition. Nothing writes to that filesystem today; the space is reserved.
If you prefer arduino-cli, the same settings as an FQBN:
esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=16M,PartitionScheme=custom,PSRAM=opi
Checking warnings
software/Hexapod/build_opt.h enables -Wall, -Wextra, -Wdouble-promotion and -Wsign-compare. -Wdouble-promotion is especially useful on the ESP32-S3, which has no hardware double: it catches float maths that silently turns into slow double maths. The firmware builds without a warning from its own sources, though the core and libraries (mostly FastLED) still produce several hundred.
In the IDE, do not use Compiler warnings: None - it passes -w and hides everything. For a full log, use the arduino-cli bundled with the IDE (macOS paths shown):
CLI="/Applications/Arduino IDE.app/Contents/Resources/app/lib/backend/resources/arduino-cli"
cd software
"$CLI" compile --clean --warnings all \
--fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=16M,PartitionScheme=custom,PSRAM=opi" \
Hexapod 2>&1 | tee ~/hexapod-build.log
--warnings all matters: without it arduino-cli defaults to none, which also passes -w.
Servo setup and first walk
Flashing the main sketch is not the last step. Before the robot will walk, every servo needs an ID and the bus baud rate set, and the joint limits need to be read off. The software/DynamixelUtilities/ folder holds the bring-up and calibration sketches for exactly this, and its README gives the order to run them in.
One set of joint limits covers all six legs (Hexapod.cpp), so when you measure limits, take values that hold for every leg rather than the most permissive leg.
For operating the finished robot, the project ships two manuals in docs/:
- Quick guide (
docs/QUICKSTART.md) - one page for anyone handed the robot: controls, what the lights mean, what is normal. - Operating manual (
docs/MANUAL.md) - the full version: servo setup, every control in every mode, timeouts and troubleshooting.
If something fails at startup, watch the OLED - it doubles as the fault display - and listen for the error tone from the I2S audio.
Ideas to extend it, and limitations
Because the firmware is split into clear tasks and libraries, there are obvious places to build on:
- Use the spare flash. The custom partition table reserves a 9.8 MB LittleFS partition that nothing uses yet. Logging gait data or storing additional audio clips are natural fits.
- Add gaits or motion curves. The gait motion curves come from the VectorUtilities library, and three gaits are already switchable at runtime, so adding a fourth follows an existing pattern.
- New face moods or LED effects. The eyes and the 19-LED strip both follow the state machine; extending either means adding states or effects rather than rewriting the display code.
- Build the transmitter first. The handheld unit is a separate ESP-NOW project; if you change
RCProtocol.hin one place, bumpcAppProtocolVersionand copy it to the other.
Be realistic about scope. This is an advanced build: a custom PCB, 18 Dynamixel XC430-T240BB-T servos on a 3 Mbaud bus, a 3D-printed chassis and a second device for control. The firmware requires esp32 core 3.3.12 and will not compile against core 2.x, and the pinned library versions are the ones it is tested against. The pin map and the single-bus I2C ownership rule are not arbitrary - the IMU must not be clocked above 400 kHz, and only peripheralsTask may touch that bus. Follow the README's constraints and the project gives you a well-engineered, fully documented legged robot to learn from.
Hexapod is a serious, fully documented legged robot that covers mechanics, electronics and firmware in one MIT-licensed repository. The parts list is demanding - a custom board and 18 Dynamixel servos - but the clear task architecture, pinned library versions and step-by-step calibration sketches make it a strong reference for anyone building walking robots on ESP32-S3.
Sources
github.comforgevolt/Hexapod — repository & READMEFacts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.



