esp32.diy

Hexapod: Build an ESP32-S3 Six-Legged Robot with 18 Dynamixels

Nov 26, 2026 · 8 min read

Advanced 44 stars 6 forks C++ MIT Updated 2026-11-20

The finished Hexapod with its 18 Dynamixel servos, OLED face and LED strip

TL;DR Hexapod is a six-legged walking robot built around a custom ESP32-S3 board that drives 18 Dynamixel XC430 servos with per-leg inverse kinematics at 200 Hz. It walks in three gaits, levels its chassis with an MPU6050, shows an animated face on an OLED and is steered from a separate handheld transmitter over ESP-NOW.
What you need
  • 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
BoardCustom ESP32-S3 board (16 MB flash, 8 MB PSRAM)
FrameworkArduino IDE, esp32 core 3.3.12 (IDF v5.5.5)
LanguageC++
Servos18x Dynamixel XC430-T240BB-T, 3 Mbaud, protocol 2.0
LicenseMIT
DifficultyAdvanced

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:

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.

The chassis and legs modelled in Fusion, with source and STLs in the mechanics folder\2
The chassis and legs modelled in Fusion, with source and STLs in the mechanics folder

What 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

Learn real-time robot control

A worked example of running inverse kinematics and 18 bus servos at 200 Hz on an ESP32-S3 with tasks pinned across both cores.

Remote-controlled walking robot

Drive it from the separate handheld transmitter over ESP-NOW, switching gaits and tuning step parameters while it walks.

Self-levelling platform

The IMU-based LevelGait keeps the chassis level on uneven ground, and posing mode lets you move the body independently of the feet.

Complete open hardware reference

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:

  1. Open software/Hexapod/Hexapod.ino in the Arduino IDE.
  2. Select board ESP32S3 Dev Module.
  3. 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.
  4. 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/:

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:

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.

Verdict

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 & README

Facts 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.