ESP32 robot car: Wi-Fi build sheet with browser control

Control a robot car from a phone browser over Wi-Fi. A ₹1,520 build with the ESP32 pin map, motor safety and the brown-out fix.

About the author · Sources, testing and AI policy

  • Parts₹1,520
  • Bench time4–5 h
  • LevelIntermediate
  • ReviewedOct 2026
Illustration of a Wi-Fi controlled robot car with an ESP32 board and phone controller

A ₹1,520 robot car you control from a phone browser, with no app to install. The ESP32 runs a small web server; the page has hold-to-move buttons and a stop. The build includes a separate 5 V rail for the ESP32, a pin map that avoids the boot-strapping pins, a 1.5-second command timeout and the Wi-Fi settings that decide whether the car connects at all. This ESP32 robot car needs no app, runs from a separate 5 V rail and stops by itself when the connection drops.

Scope: intermediate. You should be comfortable uploading to an ESP32 and reading a serial monitor. The motors run at full speed because the L298N enable jumpers stay in place; speed control is listed as the first upgrade once the car drives reliably.

What you are building

The ESP32 connects to a 2.4 GHz Wi-Fi network and serves a page at its IP address. Pressing and holding a direction button sends a request to the car; releasing it sends a stop. If the phone disconnects or the browser tab closes without a stop, the firmware stops the motors after 1.5 seconds. That timeout is the difference between a toy and a robot that keeps driving into a wall.

Bill of materials

PartQtyUnitTotal
ESP32 DevKit V11₹420₹420
L298N motor driver1₹180₹180
TT gear motor with wheel2₹110₹220
Acrylic chassis1₹80₹80
2×18650 holder with cells1₹220₹220
5 V 3 A buck converter1₹220₹220
Caster wheel and screws1₹40₹40
Jumper wire set1₹50₹50
Switch and foam tape1₹30₹30
USB data cable1₹60₹60
Parts total₹1,520

Scroll the table sideways to see every column.

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

Two items are easy to skip and should not be: the buck converter and the USB data cable. The ESP32’s radio draws short bursts of current; the L298N’s small 5 V regulator is a poor supply for it. A 5 V 3 A buck converter gives the board a stable rail. A charge-only USB cable will power the board but will not let you upload. Prices are from Indian sellers in October 2026, before shipping.

ESP32 robot car pin map

L298NESP32Note
IN1GPIO 26Left motor direction
IN2GPIO 27Left motor direction
IN3GPIO 14Right motor direction
IN4GPIO 13Right motor direction
ENA / ENBKeep jumpersMotors enabled at full speed
+12VBattery +2S 18650 pack, 7.4 V nominal
GNDBattery − and common groundESP32, buck and L298N share ground
Buck 5 VESP32 5V / VINDo not use the 3.3 V pin as an input
The chosen GPIOs avoid the ESP32 boot-strapping pins (0, 2, 4, 5, 12, 15). A motor driver pulling GPIO12 high at boot can stop the board from starting.

Power and wiring

  1. Set the buck converter output to 5.0 V with a multimeter before connecting the ESP32. Most modules ship at a different voltage.
  2. Connect the 2S pack through the switch to the L298N +12V and GND terminals.
  3. Connect the same battery input to the buck converter. Its 5 V output goes to the ESP32 5V/VIN pin, and its ground joins the common ground.
  4. Wire the four L298N input pins to the ESP32 pins in the table. Leave the ENA and ENB jumpers installed.
  5. Connect the motors to the L298N outputs. If a side runs backwards, swap that motor’s two leads.
  6. Keep the ESP32 antenna end away from the battery and the motor wires. Do not wrap the board in foil or place it under a metal chassis.

Voltage warning: the L298N input pins are driven at 3.3 V by the ESP32. Most L298N modules accept that as a logic high, but some clones are marginal. If the motors do not switch, measure the input pin voltage and check the module’s logic threshold before assuming the code is wrong. The separate 5 V rail is the first thing to wire on an ESP32 robot car.

The sketch

Change the first two lines to your Wi-Fi name and password. The network must be 2.4 GHz; the ESP32 cannot see a 5 GHz-only hotspot. If the connection fails within 15 seconds, the board starts its own access point called RobotCar with the password build1234.

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

const char* SSID = "YOUR_2G4_WIFI";
const char* PASS = "YOUR_PASSWORD";

const int IN1 = 26;
const int IN2 = 27;
const int IN3 = 14;
const int IN4 = 13;

WebServer server(80);
unsigned long lastCommand = 0;
bool moving = false;

const char PAGE[] = R"rawliteral(
<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Robot car</title>
<style>
body{font-family:system-ui,sans-serif;background:#0b1220;color:#fff;text-align:center;margin:0;padding:24px}
button{width:92px;height:64px;margin:5px;font-size:16px;border:0;border-radius:8px;background:#ff5a1f;color:#0b1220;font-weight:700;touch-action:none}
#s{color:#9aa4b2}
</style>
<h1>Robot car</h1>
<p id="s">Hold a button to move</p>
<div>
<button onpointerdown="go('f')" onpointerup="go('s')">Forward</button><br>
<button onpointerdown="go('l')" onpointerup="go('s')">Left</button>
<button onpointerdown="go('s')">Stop</button>
<button onpointerdown="go('r')" onpointerup="go('s')">Right</button><br>
<button onpointerdown="go('b')" onpointerup="go('s')">Back</button>
</div>
<script>
function go(d){fetch('/cmd?d='+d).then(r=>r.text()).then(t=>document.getElementById('s').textContent=t)}
</script>
)rawliteral";

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  stopMotors();

  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(SSID, PASS);

  unsigned long start = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - start < 15000) {
    delay(500);
    Serial.print(".");
  }

  if (WiFi.status() == WL_CONNECTED) {
    WiFi.setSleep(false);
    Serial.println();
    Serial.print("Open http://");
    Serial.println(WiFi.localIP());
  } else {
    WiFi.mode(WIFI_AP);
    WiFi.softAP("RobotCar", "build1234");
    Serial.println();
    Serial.print("AP mode. Open http://");
    Serial.println(WiFi.softAPIP());
  }

  server.on("/", []() {
    server.send(200, "text/html", PAGE);
  });

  server.on("/cmd", []() {
    String d = server.arg("d");
    if (d == "f") {
      forward();
    } else if (d == "b") {
      backward();
    } else if (d == "l") {
      turnLeft();
    } else if (d == "r") {
      turnRight();
    } else {
      stopMotors();
    }
    lastCommand = millis();
    moving = (d != "s");
    server.send(200, "text/plain", moving ? "Moving" : "Stopped");
  });

  server.begin();
  lastCommand = millis();
}

void loop() {
  server.handleClient();

  if (moving && millis() - lastCommand > 1500) {
    stopMotors();
    moving = false;
    Serial.println("Command timeout: stopped");
  }
}

void forward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void backward() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void turnLeft() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void turnRight() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void stopMotors() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Upload with the ESP32 board package installed in the Arduino IDE. If the upload fails, hold the BOOT button as the upload starts, release it when the progress bar moves, then press EN once after the upload finishes. A USB cable that only charges will show a port but no data.

Test plan

  1. Serial first: open the monitor at 115200 and confirm the IP address. If it says AP mode, connect to the RobotCar network and open 192.168.4.1.
  2. Wheels up: test each direction and confirm the stop button. Do not put the car down until the directions match the labels.
  3. Timeout: hold forward, close the browser tab, and confirm the motors stop within about two seconds.
  4. Range: drive on the floor at increasing distance from the router. Note where the controls become laggy.
  5. Battery sag: run for ten minutes, then measure the pack and feel the L298N heatsink. A hot driver or a slow car means the pack or the wiring is undersized.
  6. Recovery: switch the router off and on. Does the car reconnect? If not, reset it and record the behaviour in your report.

What usually goes wrong

SymptomLikely causeFix
Cannot see the network5 GHz hotspot or a captive-portal campus Wi-FiUse a 2.4 GHz phone hotspot with no login page, or use AP mode
Board reboots when motors startESP32 powered from the L298N 5 V rail or a weak buckUse the 5 V 3 A buck, common ground, short leads
Car turns the wrong wayMotor pair reversedSwap that motor’s leads, not the code
Buttons lag or stickWi-Fi sleep or a weak signalWiFi.setSleep(false) is already set; move closer to the router
Nothing moves but the page loadsL298N inputs not reaching logic high or jumpers removedMeasure the input pins; restore the ENA/ENB jumpers
Car keeps driving after releasePointer event not received by the browserThe 1.5 s timeout should stop it; check the serial log and the browser’s pointer support

Upgrades

  • Speed control: remove the ENA/ENB jumpers and add PWM. On the ESP32 Arduino core 3.x, use ledcAttach(pin, 1000, 8) and ledcWrite(pin, duty); on older cores, use ledcSetup and ledcAttachPin.
  • Better UI: a joystick or a WebSocket connection instead of one request per press.
  • Safety: an ultrasonic sensor that stops the car before a collision, independent of the phone.
  • Camera: an ESP32-CAM adds video but also heat and power problems. Plan the supply before buying it.

Cost and parts notes

The ₹1,520 total is a planning figure from October 2026 and excludes shipping. The ESP32 guide explains the 3.3 V logic and ADC limits; the L298N guide explains why the driver gets hot. For a robot that must avoid obstacles on its own, start with the obstacle avoiding build instead.

Common questions

Can I use an Arduino Uno with a Wi-Fi shield instead?

You can, but the ESP32 is cheaper, smaller and already has Wi-Fi and Bluetooth. The ESP32 also has enough memory and speed for a web server without a shield stack.

Why does the ESP32 not see my hostel Wi-Fi?

Many campus networks use a captive portal, enterprise login or 5 GHz-only radios. The ESP32 supports WPA2 personal on 2.4 GHz, not a browser login page. Use a phone hotspot or AP mode.

Can I power the car from a phone power bank?

A power bank can run the ESP32, but it may shut off when the motors draw a spike. Use a 2S pack with a proper buck converter for the electronics, and keep the motor supply separate.

Is it safe to control the car from a browser?

On your own hotspot, yes, for a student project. Do not expose the car to the public internet. The page has no login, and anyone on the same network can send commands.

Keep reading

Sources and further reading

Documents used to check the numbers on this page:

Last reviewed: October 2026. Reviewed against the ESP32 DevKit pinout and the L298N reference circuit. This build has not been bench-tested by this site. The pin choices avoid boot-strapping conflicts, but always test with the wheels off the ground.

Newer builds and guides

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.