This build turns a 2WD RC car into a robot you drive from a browser tab. The ESP32 C3 Super Mini has WiFi built in, so there's no extra module to wire up. It runs a web server for the control page and a WebSocket server for commands, so when you press an arrow button the car reacts immediately instead of waiting on a page reload.
The full tutorial, with every detail and the line-by-line code explanation, is on our site: ESP32 C3 Super Mini - Controls Car via Web
What you need
- ESP32 C3 Super Mini
- USB Cable Type-A to Type-C (for USB-A PC)
- USB Cable Type-C to Type-C (for USB-C PC)
- L9110S Motor Driver Module
- IR Remote Controller Kit
- CR2025 Battery (for IR Remote controller)
- 1.5V AA Battery (for ESP32 C3 Super Mini and Car)
- Jumper Wires
- Breadboard
- DIYables Sensor Kit (18 sensors/displays)
Wiring
Four GPIO pins go to the L9110S motor driver, two per motor: GPIO5 and GPIO6 drive motor A, GPIO7 and GPIO10 drive motor B. Never wire a motor straight to a GPIO pin, it needs far more current than a pin can supply, which is exactly why the L9110S driver sits in between.
The L9110S has no onboard 5V regulator, so you power the whole circuit from one source: four 1.5V AA batteries wired to VCC and GND on the L9110S give 6V for the motors and the board. The ESP32 C3 Super Mini only tolerates 3.3V on its GPIO pins, so never connect a 5V or 6V line to one directly. Keep GPIO8 and GPIO9 free since they're boot pins, and leave GPIO20/GPIO21 alone since they're the Serial Monitor UART.
How it works
Type the board's IP address into a browser, and the web server sends back the control page with HTML, CSS and JavaScript. That JavaScript then opens a WebSocket connection to the board. Every time you press or release an arrow button, it sends a small command number over that connection instead of reloading the page.
On the ESP32 C3 Super Mini side, the WebSocket server reads each command number and sets the four L9110S pins HIGH or LOW accordingly, which spins the motors forward, backward, or turns the car by running only one wheel.
Code
The project uses two files: an .ino file with the board logic, and an index.h file holding the webpage's HTML, CSS and JavaScript as a string, so the page content stays separate from the control code. The sketch uses the DIYables ESP32 WebServer library to connect to WiFi, serve the page, and open a WebSocket server on port 81.
Incoming WebSocket messages are parsed as command numbers, CMD_FORWARD, CMD_BACKWARD, CMD_LEFT, CMD_RIGHT, CMD_STOP, each mapped to a function that drives the four motor pins. Comments in the sketch walk through each part.
esp32-c3-super-mini-controls-car-via-web.ino
/*
* This ESP32 C3 Super Mini code was developed by newbiely.com
*
* This ESP32 C3 Super Mini code is made available for public use without any restriction
*
* For comprehensive instructions and wiring diagrams, please visit:
* https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-controls-car-via-web
*/
#include <DIYables_ESP32_WebServer.h>
#include "index.h"
#define CMD_STOP 0
#define CMD_FORWARD 1
#define CMD_BACKWARD 2
#define CMD_LEFT 4
#define CMD_RIGHT 8
#define MOTOR_A_IA_PIN 5 // The ESP32 C3 SuperMini pin connected to the A-IA pin of the L9110S (Motor A)
#define MOTOR_A_IB_PIN 6 // The ESP32 C3 SuperMini pin connected to the A-IB pin of the L9110S (Motor A)
#define MOTOR_B_IA_PIN 7 // The ESP32 C3 SuperMini pin connected to the B-IA pin of the L9110S (Motor B)
#define MOTOR_B_IB_PIN 10 // The ESP32 C3 SuperMini pin connected to the B-IB pin of the L9110S (Motor B)
// WiFi credentials
const char WIFI_SSID[] = "YOUR_WIFI_SSID";
const char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD";
// Create web server instance
DIYables_ESP32_WebServer server;
DIYables_ESP32_WebSocket* webSocket;
// Web Page handlers
void handleHome(WiFiClient& client, const String& method, const String& request, const QueryParams& params, const String& jsonData) {
server.sendResponse(client, HTML_CONTENT); // HTML_CONTENT is from index.h
}
// WebSocket event handlers
void onWebSocketOpen(net::WebSocket& ws) {
Serial.println("New WebSocket connection");
// Send welcome message
const char welcome[] = "Connected to ESP32 WebSocket Server!";
}
void onWebSocketMessage(net::WebSocket& ws, const net::WebSocket::DataType dataType, const char* message, uint16_t length) {
String angle = String(message);
int command = angle.toInt();
Serial.print("command: ");
Serial.println(command);
switch (command) {
case CMD_STOP:
Serial.println("Stop");
CAR_stop();
break;
case CMD_FORWARD:
Serial.println("Move Forward");
CAR_moveForward();
break;
case CMD_BACKWARD:
Serial.println("Move Backward");
CAR_moveBackward();
break;
case CMD_LEFT:
Serial.println("Turn Left");
CAR_turnLeft();
break;
case CMD_RIGHT:
Serial.println("Turn Right");
CAR_turnRight();
break;
default:
Serial.println("Unknown command");
}
}
void onWebSocketClose(net::WebSocket& ws, const net::WebSocket::CloseCode code, const char* reason, uint16_t length) {
Serial.println("WebSocket client disconnected");
}
void setup() {
Serial.begin(115200);
delay(1000);
pinMode(MOTOR_A_IA_PIN, OUTPUT);
pinMode(MOTOR_A_IB_PIN, OUTPUT);
pinMode(MOTOR_B_IA_PIN, OUTPUT);
pinMode(MOTOR_B_IB_PIN, OUTPUT);
Serial.println("ESP32 C3 SuperMini Web Server and WebSocket Server");
// Configure web server routes
server.addRoute("/", handleHome);
// Start web server with WiFi connection
server.begin(WIFI_SSID, WIFI_PASSWORD);
// Enable WebSocket functionality
webSocket = server.enableWebSocket(81);
if (webSocket != nullptr) {
// Set up WebSocket event handlers
webSocket->onOpen(onWebSocketOpen);
webSocket->onMessage(onWebSocketMessage);
webSocket->onClose(onWebSocketClose);
} else {
Serial.println("Failed to start WebSocket server");
}
}
void loop() {
// Then handle HTTP requests
server.handleClient();
// Handle WebSocket
server.handleWebSocket();
}
void CAR_moveForward() {
digitalWrite(MOTOR_A_IA_PIN, HIGH);
digitalWrite(MOTOR_A_IB_PIN, LOW);
digitalWrite(MOTOR_B_IA_PIN, HIGH);
digitalWrite(MOTOR_B_IB_PIN, LOW);
}
void CAR_moveBackward() {
digitalWrite(MOTOR_A_IA_PIN, LOW);
digitalWrite(MOTOR_A_IB_PIN, HIGH);
digitalWrite(MOTOR_B_IA_PIN, LOW);
digitalWrite(MOTOR_B_IB_PIN, HIGH);
}
void CAR_turnLeft() {
digitalWrite(MOTOR_A_IA_PIN, HIGH);
digitalWrite(MOTOR_A_IB_PIN, LOW);
digitalWrite(MOTOR_B_IA_PIN, LOW);
digitalWrite(MOTOR_B_IB_PIN, LOW);
}
void CAR_turnRight() {
digitalWrite(MOTOR_A_IA_PIN, LOW);
digitalWrite(MOTOR_A_IB_PIN, LOW);
digitalWrite(MOTOR_B_IA_PIN, HIGH);
digitalWrite(MOTOR_B_IB_PIN, LOW);
}
void CAR_stop() {
digitalWrite(MOTOR_A_IA_PIN, LOW);
digitalWrite(MOTOR_A_IB_PIN, LOW);
digitalWrite(MOTOR_B_IA_PIN, LOW);
digitalWrite(MOTOR_B_IB_PIN, LOW);
}
Things that go wrong
If no IP address prints, double check the WiFi name and password; the board only joins 2.4GHz networks, not 5GHz. If the page won't open, make sure your phone and the board are on the same WiFi network. Missing button images just mean no internet access, since those load from the web.
If the car drives the wrong way, swap the two motor wires on the L9110S output terminal. If the motors stall as soon as they start, the AA batteries are likely weak, swap in fresh ones.
Full tutorial
The complete tutorial - wiring diagram, code explanation and troubleshooting - is here: https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-controls-car-via-web

Top comments (0)