← All Projects

ESP32 WiFi-Controlled Robotic Car

79 viewsMarch 10, 2026
ESP32WiFiRoboticsMotorsPWMWeb Server

Build a high-torque WiFi-controlled robotic car using an ESP32 and L298N motor driver. Features a custom web-based dashboard for real-time smartphone control, two-wheel drive with a caster for agile maneuvering, and Li-ion power management.

Components & Supplies

×1ESP32 Dev Module
×1L298N Dual H-Bridge Motor Driver
×13S 18650 Li-ion Battery Pack
×1LM2596 Buck Converter
×2DC Geared Motor (TT Motor)
×1Caster Wheel

Circuit Connections

ComponentPinPinComponent
ESP32GPIO 26IN1L298N
ESP32GPIO 27IN2L298N
ESP32GPIO 14IN3L298N
ESP32GPIO 12IN4L298N
L298NOUT1/OUT2A/BMotor L
L298NOUT3/OUT4A/BMotor R
3S BatteryVCCIN+Buck Converter
Buck ConverterOUT+VINESP32

The Architecture

This project uses the ESP32 to host a local web server, providing a virtual joystick or button interface accessible via any browser on the same WiFi network. The ESP32 sends PWM signals to the L298N H-bridge driver, which controls the speed and direction of two DC gear motors.

Hardware emphasizes stability and torque, utilizing a 3S Li-ion battery pack stepped down via a Buck module to power the logic while providing full voltage to the motors.

Hardware Stack

Key Components:

  • ESP32: WiFi handling and PWM logic.
  • L298N: Dual H-bridge motor driver (up to 2A per channel).
  • Gear Motors: High torque motors for driving wheels.
  • Buck Module: DC-DC step down to keep ESP32 safe from 12V battery.
arduinoESP32 Web Server Sketch
#include <WiFi.h>
#include <WebServer.h>

const char* ssid = "RoboCar-AP";
const char* password = "12345678";

WebServer server(80);

// Motor Pins
const int IN1 = 26; const int IN2 = 27;
const int IN3 = 14; const int IN4 = 12;

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

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

void handleRoot() {
  String html = "<html><body><h1>RoboCar</h1><button onclick=\"fetch('/f')\">Forward</button><button onclick=\"fetch('/s')\">Stop</button></body></html>";
  server.send(200, "text/html", html);
}

void setup() {
  pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  WiFi.softAP(ssid, password);
  server.on("/", handleRoot);
  server.on("/f", moveForward);
  server.on("/s", stopMotors);
  server.begin();
}

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