RoboticsIntermediatePRJ-030

ESP32 Wi-Fi Robot Car

The car makes its own Wi-Fi hotspot; drive it from any phone browser.

Built and tested by Vishnu M · Industrial Robotics Institute

Circuit diagram of the ESP32 Wi-Fi Robot Car using ESP32
Circuit diagram · ESP32
LevelIntermediate
Build time3–4 hours
BoardESP32
Parts8 components

What is the ESP32 Wi-Fi Robot Car?

A robot car controlled over Wi-Fi from a phone or laptop. The ESP32 creates its own hotspot called ESP32_Robot and serves a control page with Forward, Back, Left, Right and Stop buttons. Each button press tells the ESP32 to drive the motors through an L298N motor driver. No router or internet needed.

How it works

  1. The ESP32 starts its own Wi-Fi hotspot (ESP32_Robot).
  2. You connect your phone to it and open 192.168.4.1 in a browser.
  3. The ESP32 serves a page with five control buttons.
  4. Each button opens a link such as /forward; the ESP32 runs the matching motor function.
  5. The L298N motor driver spins the motors in the chosen direction.

Parts list

ComponentQty
ESP32 Dev Board1
L298N Motor Driver Module1
BO Gear Motors4
Robot Chassis1
Wheels and Caster Wheel1
18650 Lithium Batteries2
2-cell 18650 Battery Holder with Switch1
Jumper WiresAs needed

Software

  • Arduino IDE
  • ESP32 board package
  • WiFi and WebServer libraries

Wiring and connections

FromConnect to
L298N IN1 (left motor)GPIO 26
L298N IN2 (left motor)GPIO 27
L298N IN3 (right motor)GPIO 14
L298N IN4 (right motor)GPIO 12
Battery +L298N 12V
Battery −L298N GND
ESP32 GNDL298N GND

How to build the ESP32 Wi-Fi Robot Car

  1. Build the chassis with the four BO motors, wheels and battery holder.
  2. Wire the motors to the L298N outputs (left pair and right pair).
  3. Connect L298N IN1–IN4 to ESP32 GPIO 26, 27, 14 and 12, and join the grounds.
  4. Upload the code from the Arduino IDE.
  5. Power on the robot, then on your phone connect to Wi-Fi "ESP32_Robot" (password 12345678).
  6. Open a browser and type 192.168.4.1 (without www).
  7. Use the buttons to drive.

ESP32 Wi-Fi Robot Car code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.

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

const char* ssid = "ESP32_Robot";
const char* password = "12345678";

WebServer server(80);

int IN1 = 26;
int IN2 = 27;
int IN3 = 14;
int IN4 = 12;

String webpage = R"====(
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{ text-align:center; font-family:Arial; background:#222; color:white; }
button{ width:120px; height:60px; font-size:20px; margin:10px; border-radius:10px; }
</style>
</head>
<body>
<h2>ESP32 Robot Control</h2>
<button onclick="location.href='/forward'">Forward</button><br>
<button onclick="location.href='/left'">Left</button>
<button onclick="location.href='/stop'">Stop</button>
<button onclick="location.href='/right'">Right</button><br>
<button onclick="location.href='/back'">Backward</button>
</body>
</html>
)====";

void handleRoot() { server.send(200, "text/html", webpage); }

void forward() {
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
  server.send(200, "text/html", webpage);
}

void backward() {
  digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
  server.send(200, "text/html", webpage);
}

void left() {
  digitalWrite(IN1, LOW);  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
  server.send(200, "text/html", webpage);
}

void right() {
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);  digitalWrite(IN4, HIGH);
  server.send(200, "text/html", webpage);
}

void stopRobot() {
  digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
  server.send(200, "text/html", webpage);
}

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

  WiFi.softAP(ssid, password);

  server.on("/", handleRoot);
  server.on("/forward", forward);
  server.on("/back", backward);
  server.on("/left", left);
  server.on("/right", right);
  server.on("/stop", stopRobot);
  server.begin();
}

void loop() {
  server.handleClient();
}

Real-world uses

  • Wi-Fi robotics learning
  • Remote inspection rovers
  • Robotics clubs
  • Phone-controlled vehicles

Frequently asked questions

What is a ESP32 Wi-Fi Robot Car?

A robot car controlled over Wi-Fi from a phone or laptop. The ESP32 creates its own hotspot called ESP32_Robot and serves a control page with Forward, Back, Left, Right and Stop buttons.

What components are needed for the ESP32 Wi-Fi Robot Car?

You need: ESP32 Dev Board (1), L298N Motor Driver Module (1), BO Gear Motors (4), Robot Chassis (1), Wheels and Caster Wheel (1), 18650 Lithium Batteries (2), 2-cell 18650 Battery Holder with Switch (1), Jumper Wires. Software: Arduino IDE, ESP32 board package, WiFi and WebServer libraries.

Is the ESP32 Wi-Fi Robot Car project good for beginners?

It is rated intermediate and takes about 3–4 hours to build, using the ESP32. The guide on this page explains every connection and step.

Where can I get the code for the ESP32 Wi-Fi Robot Car?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the ESP32 Wi-Fi Robot Car?

Yes. IRI sells a kit with the parts for this project (PRJ-030). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo