Wi-Fi robot car on an ESP32 with a web control page: design worksheet and code

A ₹1,340 design worksheet for a robot car you drive from a phone browser over the ESP32’s own Wi-Fi hotspot, with a command table, a safe stop-on-silence timer and PWM levels explained.

About the author · Editorial & verification standards

  • Parts₹1,340
  • Bench time4–6 h
  • LevelIntermediate
  • ReviewedNov 2026

A ₹1,340 robot car that needs no app and no router. The ESP32 makes its own Wi-Fi hotspot, serves a small control page, and drives the motors while a button on the page is held. A stop-on-silence timer stops the car by itself if the phone goes out of range.

Scope: intermediate. This is a design worksheet with illustrative costs. It has not been bench-tested by this site. The speed table below was computed by script. The sketch was written for the arduino-esp32 3.x core, where analogWrite is available; on the older 2.x core you would use ledcSetup and ledcAttachPin instead. The hotspot name and password in the sketch are placeholders and the password must be changed.

How it works

The ESP32 runs as a Wi-Fi access point and a web server. A phone joins the hotspot and opens the default address of the access point, 192.168.4.1. The page has five buttons. Holding a button sends a short request such as /cmd?d=F every 150 ms, and releasing it sends /cmd?d=S for stop.

If the phone leaves range or the page closes, no more requests arrive. The sketch stops the motors when 500 ms have passed since the last request, which is more than three missed requests. This stop-on-silence rule is the most important safety feature of any remote-controlled robot.

Bill of materials

PartQtyUnitTotal
ESP32 development board1₹450₹450
L298N motor driver board1₹180₹180
2WD chassis kit with two gear motors and wheels1₹450₹450
Battery holder with two 18650 cells1₹210₹210
Jumper wires1₹50₹50
Parts total₹1,340

Scroll the table sideways to see every column.

Prices checked Nov 2026. Shipping and tools are not included.

Prices are illustrative figures for Indian sellers in November 2026, before shipping, and have not been checked against current listings.

The numbers

Speed levelPWM value (0 to 255)Duty
Slow10039%
Medium16063%
Fast22086%
Full255100%
Duty = value / 255. Motors usually need a minimum PWM to start turning, which depends on the motor and battery.

Requests every 150 ms are about 6.7 a second. With a 500 ms timeout, three requests in a row must be lost before the car stops, which smooths short Wi-Fi glitches without leaving it running for long.

Power and wiring

PartConnects toNote
L298N ENA / IN1 / IN2GPIO 14 / 26 / 27Left motor
L298N ENB / IN3 / IN4GPIO 13 / 32 / 33Right motor
ESP32 power5 V from the L298N 5V output, or a USB power bankDo not feed the ESP32 5 V and USB together
BatteryL298N 12V inputJoin the ESP32 GND to the L298N GND
The L298N logic inputs generally accept 3.3 V signals from the ESP32, but check your board. Avoid GPIO 12 and the other boot-strapping pins.

The sketch

// ESP32 Wi-Fi robot car: hotspot + web control + L298N
// Design worksheet: for the arduino-esp32 3.x core. Change the password!

#include <WiFi.h>
#include <WebServer.h>

const char* AP_NAME = "RobotCar";
const char* AP_PASS = "change-this-pass";   // at least 8 characters

const int L_EN = 14, L_IN1 = 26, L_IN2 = 27;
const int R_EN = 13, R_IN3 = 32, R_IN4 = 33;
const int SPEED = 160;
const unsigned long TIMEOUT_MS = 500;

WebServer server(80);
char cmd = 'S';
unsigned long lastCmd = 0;

const char PAGE[] PROGMEM = R"rawliteral(
<!doctype html><meta name=viewport content="width=device-width,initial-scale=1">
<style>button{width:30vw;height:20vw;font-size:8vw;margin:1vw;touch-action:none}</style>
<div><button onpointerdown="hold('F')" onpointerup="rel()" onpointerleave="rel()">F</button></div>
<div><button onpointerdown="hold('L')" onpointerup="rel()" onpointerleave="rel()">L</button>
<button onpointerdown="hold('R')" onpointerup="rel()" onpointerleave="rel()">R</button></div>
<div><button onpointerdown="hold('B')" onpointerup="rel()" onpointerleave="rel()">B</button></div>
<script>
let t=null;
function send(d){fetch('/cmd?d='+d).catch(()=>{});}
function hold(d){rel();send(d);t=setInterval(()=>send(d),150);}
function rel(){if(t){clearInterval(t);t=null;send('S');}}
</script>
)rawliteral";

void drive(int left, int right) {
  digitalWrite(L_IN1, left >= 0);  digitalWrite(L_IN2, left < 0);
  digitalWrite(R_IN3, right >= 0); digitalWrite(R_IN4, right < 0);
  analogWrite(L_EN, abs(left));
  analogWrite(R_EN, abs(right));
}

void handleCmd() {
  if (server.hasArg("d")) { cmd = server.arg("d")[0]; lastCmd = millis(); }
  server.send(200, "text/plain", "ok");
}

void setup() {
  int pins[] = {L_EN, L_IN1, L_IN2, R_EN, R_IN3, R_IN4};
  for (int p : pins) pinMode(p, OUTPUT);
  drive(0, 0);
  WiFi.softAP(AP_NAME, AP_PASS);
  server.on("/", []() { server.send_P(200, "text/html", PAGE); });
  server.on("/cmd", handleCmd);
  server.begin();
}

void loop() {
  server.handleClient();
  if (millis() - lastCmd > TIMEOUT_MS) cmd = 'S';
  switch (cmd) {
    case 'F': drive(SPEED, SPEED); break;
    case 'B': drive(-SPEED, -SPEED); break;
    case 'L': drive(-SPEED, SPEED); break;
    case 'R': drive(SPEED, -SPEED); break;
    default:  drive(0, 0);
  }
}

Anyone who joins the hotspot can drive the car, so choose a real password. Because the sketch uses a plain web server and no encryption beyond Wi-Fi’s own, do not put anything private on this network. The sketch has been proofread but not compiled on this site.

Test plan

  1. Join the hotspot: connect a phone and open 192.168.4.1; the five buttons should appear.
  2. Wheels up: test each button with the wheels off the floor and swap motor wires if a direction is wrong.
  3. Stop on release: hold F, release it, and confirm the car stops at once.
  4. Stop on silence: hold F, then turn off the phone’s Wi-Fi and check the car stops within about half a second.
  5. Range: walk away indoors and note where commands start to lag.
  6. Battery: watch whether the ESP32 resets when the motors start, which means the supply is sagging.

What usually goes wrong

SymptomLikely causeFix
Page does not loadPhone is on mobile data or another Wi-FiJoin the RobotCar hotspot and disable mobile data
Car runs after releaseRelease event missedThe 500 ms timeout stops it; check the timeout logic
ESP32 resets when motors startVoltage dipPower the ESP32 from a separate bank or add a capacitor
analogWrite not foundOlder ESP32 coreUpdate the core or use the ledc functions
One side always wrongMotor wires reversedSwap that motor’s two wires

Upgrades

  • Speed slider: add a slider to the page.
  • Telemetry: show battery voltage on the page.
  • Camera: use an ESP32-CAM for a video view.
  • Station mode: join your home Wi-Fi instead of making a hotspot.

Cost and parts notes

The ₹1,340 total is an illustration and does not include shipping. Use the cost calculator to compare sellers.

Common questions

Why does the car need its own hotspot?

It means the car works anywhere, even without a router.

What is the stop-on-silence timer for?

It makes the car stop if the phone disconnects, so it cannot run away.

Can several phones connect?

Yes, and each can send commands, which is why the password matters.

Why not use WebSockets?

They would reduce latency, but plain requests are simpler to write and are enough for a small car.

Last reviewed: November 2026. This is a design worksheet with illustrative costs. It has not been bench-tested by this site; library names, pins and limits must be checked against your board and the current library versions, and measurements from your build are welcome.

More builds

Next builds to try

Free: the final-year project pack

A shortlist with BOMs, a report outline that matches the usual chapter scheme, a costing sheet and 40 viva questions. Built for the February–April submission season.

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.