RobotGuide

Hardware & electrical · topic E10 · 25 hours

ESP32 & wireless co-processors

What a robot lacks most is not compute; it is a cheap side channel: get sensor data out, get debug commands in, let a phone see the status. An ESP32 does all three for a couple dozen yuan, and it is dual-core — one core runs control, one runs networking, neither interrupting the other.

Foundations stage · Intermediate
System software · Hands-on Embedded & controls · Proficient Mechanical · Aware

Tools
Tools

What to learn

  • Two development routes: Arduino core (fast, good enough) and ESP-IDF (native FreeRTOS, reaches down to the metal)
  • The wireless trio: WiFi + MQTT for telemetry, BLE for provisioning and near-field debugging, OTA for cable-free upgrades
  • Dual-core split: pin the control task to core 0, put networking on core 1, pass data through queues — no shared global variables
  • The boundary: wireless latency runs from tens to hundreds of milliseconds and is unpredictable — telemetry and monitoring only, never a real-time control loop

The lesson · plain words

The ESP32 is the standard «wireless sidekick» on robots: a WiFi+Bluetooth dual-core MCU for a few yuan a chip. What it can and cannot do must be drawn sharply — wireless is not a bus.

The physical reality of a wireless link

WiFi's TCP retransmission saves the data but turns latency into a lottery: 2 ms with good signal, and one packet retransmitted three times means 60 ms+. Drag the distance slider in the figure: as the loss rate climbs, «goodput» and worst-case latency degrade together.

Memorize the conclusion: WiFi reliability means «delivered eventually», not «delivered on time». Data collection, telemetry, and config push can all ride WiFi; any closed-loop control cannot.

Interactive figure · drag it and see

What this figure shows: packets crossing a link where some are marked lost and others retransmitted, driven by a distance/obstruction (signal quality) slider, with live loss-rate and goodput readouts. Takeaway: the WiFi real-time paradox — retransmits buy reliability and turn latency into a lottery; fine for data collection, never for servo control.

The ESP32's correct job

The sidekick trio: wireless telemetry (status reporting / remote viewing), low-power standby (deep-sleep mode keeps watch overnight), distributed sensor nodes (collect over I2C/SPI, then package and upload). The dual-core architecture (protocol-stack core + application core) makes all of this comfortable.

Jobs it should not hold: real-time motor control (interrupt latency is not deterministic), safety logic (if the wireless link drops, what happens to safety?). Safety always stays on the wired main controller.

Engineering essentials

Provisioning is the biggest productization trap. Pick one of SmartConfig / provisioning button / AP mode, and always keep a degraded mode that «works locally even when it cannot connect». Reconnection needs exponential backoff — frantic retries will drag down both you and the router.

Antenna and layout: keep the module's antenna area free of copper, away from metal enclosures and motors. Half of the field complaints about «WiFi being flaky» are antenna layout, the other half channel congestion (change channels / move to 5 GHz).

How far to go

Be able to sketch an ESP32 + main-controller architecture: ESP32 collects sensors → reports over WiFi/MQTT → main controller receives on UART. Explain why the control loop never rides WiFi. Implement graceful degradation: record locally when disconnected, backfill after reconnection.

Three questions — do you really get it?

1. Why should closed-loop control never ride WiFi?

  • ARetransmission makes latency jitter uncontrollable and worst-case delay unbounded
  • BNot enough bandwidth
  • CHigh power consumption
Show answer

A. TCP retransmission protects data, not timing. A control loop needs bounded latency.

2. The sensible role for an ESP32 on a robot is?

  • AMain controller running the control loop
  • BWireless telemetry / sensor node / low-power standby sidekick
  • CSafety logic
Show answer

B. Sidekick positioning: wireless is its value; real time is not.

3. Field WiFi «works, then stops working» — what do you check first?

  • AAntenna layout and channel
  • BSwap the ESP32
  • CReboot the router
Show answer

A. Copper over the antenna area, metal shielding, and channel congestion account for the overwhelming majority. Rebooting the router is burying your head in the sand.

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

  • Putting motor control inside a WiFi callback: it jitters the moment you connect and stops the moment you disconnect
  • Using WiFi as the e-stop path: the router hiccups and the machine keeps moving

You have learned enough when

Build the complete chain «ESP32 reads an IMU → reports over MQTT → a web page shows it live», and state which data must not travel over wireless.

The Chinese edition carries the full topic page for ESP32 & wireless co-processors, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/E10/.