ESP ZeroCode AI · Community
spider asdf
tengo un Seeed Studio XIAO ESP32-S3 Sense, podrías crear un circuito para manejar 12 cervos individualmente?
asdf— el_viejo27Download the firmware Open-source licences Fork it in the studio
What it does
- Twelve servo outputs drive the legs individually through a PCA9685 16-channel driver on I2C (channels 0–11, GPIO5/GPIO6)
- Four legs of three joints each (hip swing, upper, lower) — twelve 9 g metal-gear servos of the MG90S class
- The walking cycle runs on the device, so steps stay smooth — but only while the page keeps talking: 20 s without contact and the spider stops
- Steering from the web page with six direction switches — forward, backward, turn left, turn right, strafe left, strafe right — that combine (forward + turn right walks an arc); with all six off it stands still
- Walk speed adjustable from the web page (slider, 0–100), setting the gait cycle and stride
- Each servo's centre trimmed ±20° from the web page and saved, so the legs stand level on the floor
- Power: a 5-cell NiMH 6 V 2000 mAh pack feeds the servos on the driver's V+ terminal and, through a 5 V step-down, the board's 5 V pad — all grounds common, 1000 µF across the servo rail
- The device makes its own Wi-Fi network and serves the control page at http://192.168.4.1 — no app, no internet
- Power-on: stands up into its default stance and waits there for a command (the servos are limp until the firmware positions them)
- No controls on the body: the web page is the only interface (the board's own BOOT button is left untouched)
- Battery row on the page: pack volts and charge, read through a 100k/47k divider on GPIO1
- Low-battery protection: at 5.8 V the page flags the pack as low, at 5.4 V the spider stops, stands and refuses to walk until recharged
- Dead-man watchdog: if the page stops talking to the device for 20 s (phone closed, out of range, dead battery) the direction switches are cleared and the spider stands still where it is
Manual
Device Type
what: A four-legged, twelve-servo walking robot — a spider — that stands up on power-on and walks, turns and side-steps on orders from a phone or computer browser. — problem: A hobby quadruped usually needs a PC, a toolchain and a gamepad. This one is steered from a page the robot serves itself: nothing to install, no cloud account, no home Wi-Fi needed. — scope: Hobby robot on a Seeed XIAO ESP32-S3 Sense: twelve 9 g metal-gear servos, one PCA9685 driver, a 6 V NiMH pack.
Hardware
chip: esp32s3 — board: Seeed XIAO ESP32S3 Sense (xiao-esp32s3-sense) — gpios: pin: GPIO5 — role: I2C SDA to the PCA9685 (board pad D4) · pin: GPIO6 — role: I2C SCL to the PCA9685 (board pad D5) · pin: GPIO1 — role: battery sense, ADC1_CH0, junction of the pack divider — peripherals: part: PCA9685 16-channel PWM driver (0x40) — pins: VCC → 3V3, GND → GND, SDA → GPIO5, SCL → GPIO6, OE → GND (outputs always enabled), V+ → 6 V servo rail — note: 50 Hz shared PWM, 12-bit (4096 counts); a command angle 0–180° is written as the matching 1–2 ms pulse. · part: 12 × MG90S-class 9 g metal-gear servo — note: one leg is three joints: a hip that swings it forward/back, an upper that lifts it, a lower that sets the foot height. · part: Battery: 5-cell NiMH 6 V, 2000 mAh pack — note: feeds the servo rail at the driver's V+ and the 5 V step-down; a 1000 µF electrolytic sits across the servo rail to absorb the current spikes of twelve servos starting together. · part: 5 V step-down (buck, output set to 5.0 V, ≥2 A) — note: pack IN+/IN- → OUT+/OUT- to the board's 5V pad and GND; set the output with a meter before connecting the board. · part: Battery-sense divider 100 kΩ / 47 kΩ — note: pack + → 100 kΩ → GPIO1 → 47 kΩ → pack −. A full 6.5 V pack reads 2.07 V at the pin, a flat 5.0 V pack reads 1.59 V — both well inside the 3.3 V ADC range. — notUsed: the camera, PDM microphone and microSD slot of the Sense expansion board stay unused · the board's BOOT button is left as it is · no LED, screen or buzzer on the robot
Inputs
kind: web switch — label: Walk forward — hardware: a boolean row on the page — behavior: switching it on adds forward translation to the gait; the robot starts walking from whatever pose it is standing in and keeps walking until the switch (or all direction switches) is off. · kind: web switch — label: Walk backward — hardware: a boolean row on the page — behavior: same, translation reversed. · kind: web switch — label: Turn left / Turn right — hardware: two boolean rows on the page — behavior: adds a yaw rate: alone, the robot rotates on the spot; with forward or backward on, it walks an arc. · kind: web switch — label: Strafe left / Strafe right — hardware: two boolean rows on the page — behavior: adds sideways translation: alone it side-steps, combined with forward/backward it walks a diagonal. · kind: web slider — label: Speed — hardware: 0–100 row on the page, default 60 — behavior: sets the gait cycle from 0.9 s per step pair (slow, long stride) to 0.35 s (fast, short stride). Changing it while walking is applied to the next step, no stop needed. · kind: web slider ×12 — label: Trim per joint — hardware: twelve −20…+20° rows, one per servo, default 0 — behavior: an offset added to every commanded angle of that joint; used once during assembly to make the twelve legs stand level, and saved in flash so it survives a reboot.
Outputs
kind: actuator — label: Twelve leg joints — hardware: PCA9685 channels 0–11 on the servo rail — behavior: the only physical output. Every pose the robot takes — stand, lift one leg, plant it, step forward, rotate — is a set of twelve angles recomputed by the gait on the device, 30–50 times a second, and written to the driver. · kind: web reading — label: Battery — hardware: GPIO1 ADC through the 100k/47k divider — behavior: pack volts and an estimated charge percentage, refreshed with the page. With a NiMH pack the percentage is a straight line from 6.5 V (100 %) to 5.0 V (0 %). Below 5.8 V the row is flagged low. · kind: web reading — label: State — hardware: a value row on the page — behavior: one of Stopped (standing), Walking, Low battery — what the robot is doing right now, so a phone that reconnects mid-walk shows the truth instead of guessing.
Connectivity
stack: webui — transport: Wi-Fi 2.4 GHz access point made by the device — purpose: the control page at http://192.168.4.1 — no home network, no cloud, no account, no internet
Commissioning
method: soft AP + built-in page — instructions: Switch the pack on. On the phone or laptop, join the Wi-Fi network named ZeroCode-<id>; its password is generated on first boot and printed on the USB serial console (any serial terminal, 115200 baud). Open http://192.168.4.1 — the direction switches, the speed slider, the battery row and the twelve trim rows are all there. Up to four phones/laptops can join at once, and a phone on that network has no internet while connected.
Business Logic
powerOnBehavior: The servos are limp on power-up — the driver has no position of its own. Within about two seconds the board brings its access point up, loads the saved trims and drives all twelve joints to the standing pose (hips near centre, upper joints lifting the body, lowers setting the feet), then holds torque. It does not walk until a direction switch is switched on. A board reset in the middle of a walk has the same effect: ~2 s of limp legs, then it stands up again. — automationRules: Nothing runs on a clock and nothing moves without a switch on the page. Two rules act on their own. Battery protection: at 5.8 V or below the page flags the pack low and the robot keeps walking; at 5.4 V or below walking stops, it settles into its standing pose and refuses new walking commands until the pack reads 5.9 V or more again. Dead-man watchdog: while a direction switch is on, the robot must hear from the page every few seconds; after 20 s with no contact at all (phone screen off, browser closed, phone out of range, Wi-Fi dropped) it clears all six direction switches and stands still — it never walks unattended. When the phone comes back the switches read off and the robot waits, so walking always has to be asked for again. — dayToDayOperation: Switch the pack on, wait two seconds for it to stand. Join ZeroCode-<id> from the phone and open the page. Switch 'forward' on and it walks; drag Speed to taste. Add 'turn right' for an arc, 'strafe left' for a diagonal side-step. Keep the page open in the foreground while it walks — the page is the leash: if the phone sleeps, is put away or walks out of range and the page stops talking for 20 s, the robot plants its feet and stands still. Switch the direction switches off and it stops and stands where it is. To put it away, switch the pack off: the legs go limp, so pick it up first.
Factory Reset
trigger: The factory_reset command on the USB serial console — there is no button and no reset gesture, so any reset needs a cable and a terminal. — effect: Erases the saved trims and the network password and reboots. The robot comes back with all trims at zero (it stands crooked until re-trimmed), a fresh ZeroCode-<id> password printed in the boot log, and the network name and page address unchanged because they come from the hardware address.
Failure Modes
scenario: The page is closed, the phone sleeps, or the phone leaves the network while walking — behavior: the robot finishes the step it is in and stops: after 20 s with no contact from the page it clears the six direction switches and stands still holding torque. Reconnecting the phone shows everything off, so walking has to be asked for again. · scenario: The pack goes flat or is unplugged mid-step — behavior: the board loses power and the servos lose torque at the same moment, so the legs collapse. Plugging the pack back in stands it up again with the saved trims; nothing is lost but the pose. · scenario: Battery low (≤5.4 V) — behavior: walking stops and the robot stands, the page reports Low battery, and further walking switches are refused until the pack is charged — a 9 g servo without torque collapses the robot mid-step. · scenario: A leg is blocked or a servo stalls — behavior: nothing detects it: the driver has no current sensing. The servo holds torque and warms, the pack sags and the battery row drops — the owner is expected to switch the direction off and free the leg. · scenario: Wi-Fi interference or a crowded 2.4 GHz room — behavior: the page refreshes every few seconds and a switch can take a moment to land. The robot never stops walking because of it; rejoining from a nearer phone fixes it. · scenario: Firmware crash or watchdog reset — behavior: the board reboots, the servos go limp for about two seconds and the robot stands up again; the direction switches come back off, so it does not resume walking by itself.
Power Management
batteryPowered: true — sleepMode: none — the access point and the gait have to run continuously while the pack is on; there is no deep sleep and no idle timeout — runtime: roughly 45–60 minutes of continuous walking, or several hours standing and holding torque, on a 2000 mAh 5-cell NiMH pack — wakeSources: the pack switch only
Custom Behavior
gait: A one-leg-at-a-time crawl (wave) gait: one leg lifts and swings while the other three stay planted, so the body is never unsupported. Slower than a trot, but far steadier on 9 g servos and on a floor that is not perfectly flat. — steeringModel: Direction is a translation vector (forward/back plus strafe left/right) and a yaw rate (turn left/right); the gait adds them, so all combinations are legal — including walking a circle and side-stepping on a diagonal. — trims: Per-joint trim in degrees (±20) is stored in flash, added to every commanded angle of that joint; it is the only calibration the robot has, and it is what makes twelve cheap servos stand level. — servoMapping: Angle 0–180° → 1–2 ms pulse at 50 Hz, written to PCA9685 channel of that joint; joint sign and range are fixed per leg so a mirrored leg needs no special case in the firmware. — commandWatchdog: The gait runs on the device for smoothness, but every /api/state poll from the page counts as a heartbeat. While any direction switch is on, 20 s without a heartbeat clears the six direction switches (so the page and the robot agree) and stands the robot where it is. Twenty seconds is roughly eight missed polls — long enough for a hiccup, short enough that a runaway is impossible.
Published 28 Nov 2026
Firmware and source licensed Apache-2.0; photos and text CC-BY-4.0.
The firmware includes open-source software — open-source licences and notices; some components may be used only with Espressif chips.
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy · Cookie Policy