Skip to content
Build GuidesNovember 24, 2026Foundational

Build a Wi-Fi Robot Car with ESP32

RTJ Editor
RoboTechJournal Contributor
Build a Wi-Fi Robot Car with ESP32
ContentsParts and ratings to check first

This project uses a generic full-size ESP32 development board, a two-wheel differential-drive chassis, two brushed DC gearmotors, and a dual H-bridge motor driver. A phone or computer sends short commands from a browser on the same local network. The ESP32 handles the web request; the driver—not the GPIO pins—switches motor current. This is a learning project, not a safety-rated remote-control system.

If you are still choosing the controller, start with our ESP32 board-selection guide. For wheel layout, frame material, and mounting, see the robot chassis guide.

Parts and ratings to check first

  • A standard ESP32 development board with accessible GPIO and a documented USB/serial programming path.
  • A two-wheel chassis, two brushed DC gearmotors, wheels, and a caster or skid.
  • A dual H-bridge driver whose motor-voltage range and current/thermal limits suit the exact motors and installation. A TI DRV8833 is one example of a dual bridge, not a universal choice; check its datasheet and the breakout board’s thermal design.
  • A battery or supply chosen for the motors and driver, plus a suitable fuse and correctly rated wires, switch, and connectors.
  • A separate regulated supply path for the ESP32 if the battery does not provide an input voltage supported by the board. Check regulator current and motor-induced voltage dips.

Read the motor datasheet for stall current at your chosen voltage. Use the driver’s specified continuous and peak current conditions, package, board copper, ambient temperature, and cooling to judge whether it can handle the load. A headline peak-current number is not a safe continuous-current guarantee. Check both motors starting or stalling together, battery sag, wiring, connectors, fuse coordination, and driver temperature. Begin with wheels lifted and a current-limited supply where practical.

Wire logic and motor power deliberately

Connect ESP32 GPIO outputs only to the driver’s logic inputs. Connect each motor to a driver output and the motor battery or supply to the driver’s motor-power input. Power the ESP32 through an input permitted by its board documentation; do not feed motor voltage into a 3.3 V pin. If you use separate motor and logic sources and the driver is not isolated, connect their grounds so the control signals have a common reference. “Separate supplies” does not mean galvanic isolation when grounds are joined.

Keep motor-current paths short and separate from sensitive signal wiring where practical. Common ground is needed for signal reference, but it does not remove motor noise or prevent the motor supply from disturbing the logic supply. Use suitable regulation, decoupling, wiring, and layout for the real components. Add a physical power switch and a reachable motor-power disconnect; software stop commands are not a substitute.

text
Battery / motor supply ── fuse ── H-bridge VM ── left and right motors          │                         │          └── suitable regulator ───┴── ESP32 board input (if designed for it)                                    │ESP32 GPIO ── driver logic inputs ┘ESP32 GND ───── common logic reference ───── driver GND
Conceptual wiring only. The battery, regulator, driver, grounding, fuse, and connectors must be selected for the actual robot. A shared ground is not isolation.

Choose and charge the battery safely

For a first build, an intact NiMH pack and a charger intended for that pack can avoid the extra handling and charging requirements of lithium cells. Match the pack voltage and expected current to the motors and driver, and do not use ordinary alkaline cells in a rechargeable charger. If you choose Li-ion or LiPo, use an intact pack with the correct cell count and chemistry-specific charger and protection arrangement. Follow the battery and charger manufacturers’ instructions; a board’s regulator or a generic USB cable is not a lithium-cell charger. Do not charge a damaged, swollen, unusually hot, or otherwise suspect cell. Disconnect the motor load during charging unless the battery/charger system explicitly supports that use.

A charger IC datasheet is not a complete battery-pack design. The TI BQ24074 documentation, for example, describes a specific single-cell linear charger and its operating limits; it is not a charger recommendation for every pack. Use only components and a charging procedure that match the battery manufacturer’s requirements.

Illustrative browser-control sketch

The example below uses the Arduino-ESP32 Wi-Fi and WebServer libraries and assumes a DRV8833-style two-input-per-motor interface: both inputs low coast the motor, while one input high selects a direction. The pin numbers are example assignments for a standard ESP32 development setup, not a universal pin map. Verify pins on your exact board, check your driver’s truth table, and keep the wheels off the ground for initial checks. This sketch is untested and provides no authentication, encryption, or certified stop function.

cpp
#include <WiFi.h>#include <WebServer.h> const char* ssid = "YOUR_2_4_GHZ_WIFI";const char* password = "YOUR_WIFI_PASSWORD";WebServer server(80); // Example only: confirm these pins and the driver's truth table.constexpr int LEFT_IN1 = 25;constexpr int LEFT_IN2 = 26;constexpr int RIGHT_IN1 = 27;constexpr int RIGHT_IN2 = 14;constexpr int DRIVER_SLEEP = 33; // DRV8833 nSLEEP: LOW disables the bridges. bool moving = false;unsigned long lastCommandMs = 0;constexpr unsigned long commandTimeoutMs = 400; void stopMotors() {  digitalWrite(LEFT_IN1, LOW);  digitalWrite(LEFT_IN2, LOW);  digitalWrite(RIGHT_IN1, LOW);  digitalWrite(RIGHT_IN2, LOW);  digitalWrite(DRIVER_SLEEP, LOW);  moving = false;} void motor(int in1, int in2, bool forward) {  digitalWrite(in1, forward ? HIGH : LOW);  digitalWrite(in2, forward ? LOW : HIGH);} void drive(const String& command) {  digitalWrite(DRIVER_SLEEP, HIGH);  if (command == "forward") {    motor(LEFT_IN1, LEFT_IN2, true);    motor(RIGHT_IN1, RIGHT_IN2, true);  } else if (command == "reverse") {    motor(LEFT_IN1, LEFT_IN2, false);    motor(RIGHT_IN1, RIGHT_IN2, false);  } else if (command == "left") {    motor(LEFT_IN1, LEFT_IN2, false);    motor(RIGHT_IN1, RIGHT_IN2, true);  } else if (command == "right") {    motor(LEFT_IN1, LEFT_IN2, true);    motor(RIGHT_IN1, RIGHT_IN2, false);  } else {    stopMotors();    return;  }  lastCommandMs = millis();  moving = true;} const char page[] PROGMEM = R"HTML(<!doctype html><meta name="viewport" content="width=device-width"><title>Robot control</title><button data-m="forward">Forward</button><button data-m="left">Left</button><button data-m="right">Right</button><button data-m="reverse">Reverse</button><button id="stop">STOP</button><script>let held = null, timer = null;async function send(m) { try { await fetch('/drive?m=' + m, {cache:'no-store'}); } catch (_) {} }function release() { held = null; clearInterval(timer); timer = null; send('stop'); }document.querySelectorAll('[data-m]').forEach(b => {  b.onpointerdown = e => { e.preventDefault(); release(); held = b.dataset.m; send(held);    timer = setInterval(() => held && send(held), 150); };  b.onpointerup = release; b.onpointercancel = release; b.onpointerleave = release;});document.querySelector('#stop').onclick = release;window.onblur = release;document.onvisibilitychange = () => document.hidden && release();</script>)HTML"; void setup() {  Serial.begin(115200);  pinMode(LEFT_IN1, OUTPUT); pinMode(LEFT_IN2, OUTPUT);  pinMode(RIGHT_IN1, OUTPUT); pinMode(RIGHT_IN2, OUTPUT);  pinMode(DRIVER_SLEEP, OUTPUT);  stopMotors();   WiFi.mode(WIFI_STA);  WiFi.begin(ssid, password);  while (WiFi.status() != WL_CONNECTED) delay(250);  Serial.println(WiFi.localIP()); // Open this address in a browser on the same LAN.   server.on("/", HTTP_GET, []() { server.send(200, "text/html", page); });  server.on("/drive", HTTP_GET, []() {    const String command = server.arg("m");    if (command == "stop") stopMotors();    else if (command == "forward" || command == "reverse" ||             command == "left" || command == "right") drive(command);    else { server.send(400, "text/plain", "Unknown command"); return; }    server.send(200, "text/plain", "OK");  });  server.begin();} void loop() {  server.handleClient();  if (moving && millis() - lastCommandMs > commandTimeoutMs) stopMotors();}

Open the printed local IP from a device on the same Wi-Fi network. The browser repeats the movement request while a button is held; the ESP32 stops when requests cease, the page loses focus, or the stop button is pressed. This timeout is only a secondary software precaution: packet delays, browser suspension, Wi-Fi loss, routing, or code faults can still make behavior unpredictable. Test with the wheels lifted, keep a physical disconnect within reach, and never expose this unauthenticated HTTP controller to the public internet or an untrusted network.

Network and browser limits

The controller works only when the browser can reach the ESP32 on the same routed local network. Guest Wi-Fi, client isolation, a captive portal, VPN rules, or a changing local address can block access. Browser timing and Wi-Fi latency vary; this is not a deterministic control link. Use a local network you control, avoid port forwarding, do not send controls over an open public hotspot, and use a physical stop that does not depend on the browser.

Troubleshooting checklist

  • Board will not connect: confirm the 2.4 GHz network credentials and router policy, then read the serial log and verify the printed address.
  • Page opens but motors do not move: check driver logic power, motor supply polarity, driver sleep/enable state, grounds, and the driver input truth table.
  • One wheel turns the wrong way: disconnect power and swap that motor’s leads or reverse its software direction; do not copy a pin map from a different board.
  • ESP32 resets when motors start: check motor stall current, battery sag, regulator margin, wiring, decoupling, connector condition, and whether motor current shares a weak logic-power path.
  • Driver becomes hot or shuts down: stop and compare actual load, startup/stall current, board thermal layout, and cooling with the driver datasheet. Do not keep retrying an overloaded driver.
  • Browser commands feel delayed or stop unexpectedly: check local-network isolation and signal quality. Reduce speed and stop testing until the physical disconnect works reliably.

Official references

More from Build Guides

How to Choose a Robot Chassis: Material, Drive Type, and Size Guide
RoboticsJun 24, 2026Foundational

How to Choose a Robot Chassis: Material, Drive Type, and Size Guide

A practical guide to choosing a robot chassis — comparing acrylic, aluminum, and 3D-printed options, drive configurations, and sizing considerations.

Build a Line-Following Robot from Scratch
Build GuidesFeb 20, 2026Foundational

Build a Line-Following Robot from Scratch

A practical, step-by-step engineering guide to building a PID-controlled line following robot.

How to Choose an ESP32 Board for Robotics
RoboticsNov 24, 2026Foundational

How to Choose an ESP32 Board for Robotics

A focused ESP32 board-selection guide covering usable I/O, 3.3 V logic, wireless variants, size, camera support, and debugging.