A WiFi-controlled floor cleaning robot built for an engineering exploration exhibition. Controlled entirely from a browser on the same network. No app, no cloud, no external server.
Total Build Cost: ~Rs. 2,200
- Browser-based control UI served directly from the ESP32
- 4-wheel drive with forward, backward, left, and right movement
- HC-SR04 ultrasonic sensor on a servo doing a continuous 0–180 degree sweep while the robot moves
- 3-direction obstacle scan (Left, Center, Right) with live distance readings in the UI
- Auto-stop when center distance drops below 20 cm, with a directional suggestion based on which side has more clearance
- Spinning mop motor controlled via a 2-channel relay, toggled from the UI
- OLED display (SSD1306) showing live system status on the robot:
- IP address and WiFi signal bars
- Animated robot face (happy / alert on obstacle)
- Current direction with arrow icon (IDLE / FORWARD / BACK / LEFT / RIGHT / STOP)
- Live L / C / R sensor distances
- Spinner on/off status with spinning animation
- Boot animation with loading bar and READY screen
- 4S Li-ion battery pack with an onboard charging module
| Component | Qty | Est. Cost (Rs.) |
|---|---|---|
| ESP32 Dev Module + Arduino Extension Board | 1 | 400 |
| L298N Motor Driver Module | 1 | 120 |
| DC Gear Motors with wheels | 4 | 400 |
| HC-SR04 Ultrasonic Sensor | 1 | 80 |
| SG90 Servo Motor | 1 | 80 |
| 2-Channel Relay Module | 1 | 80 |
| Spinner DC Motor + Mop | 1 | 200 |
| 4S 18650 Battery Pack (4 cells + holder) | 1 | 300 |
| OLED Display (0.96", SSD1306, I2C) | 1 | 150 |
| Battery Charging Module | 1 | 200 |
| Breadboard | 1 | 60 |
| Connecting Wires, Switch, Misc | - | 100 |
| Total | ~Rs. 2,200 |
Prices are approximate based on local market / online purchase at the time of the build.
Motor Driver (L298N)
IN1 -> GPIO 16
IN2 -> GPIO 17
IN3 -> GPIO 27
IN4 -> GPIO 26
Ultrasonic Sensor (HC-SR04)
TRIG -> GPIO 18
ECHO -> GPIO 19
Servo (SG90)
SIG -> GPIO 14
Relay Module
IN1 -> GPIO 25 (active LOW)
OLED Display (SSD1306, I2C)
SDA -> GPIO 21
SCL -> GPIO 22
Install these libraries via the Arduino Library Manager before compiling:
- ESP32Servo by Kevin Harrington
- Adafruit SSD1306 by Adafruit
- Adafruit GFX Library by Adafruit
- Wire (built-in with ESP32 core — no install needed)
Board: ESP32 Dev Module
Board Manager URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Clone or download this repository.
- Open
robot_oled.inoin the Arduino IDE. - Update the WiFi credentials at the top of the file:
const char* ssid = "YOUR_WIFI_SSID"; const char* password = "YOUR_WIFI_PASSWORD";
- Install all dependencies listed above.
- Select ESP32 Dev Module as the board.
- Upload the sketch.
- Watch the OLED boot animation — it shows a loading bar, then "READY".
- The OLED will display "Connecting WiFi..." with a dot animation until connected.
- Once connected, the IP address is shown on the OLED. Open that IP in any browser on the same network.
The IP address is also printed to the Serial Monitor at 115200 baud.
The ESP32 runs an HTTP server on port 80. Every button press in the UI sends a GET request to a route on the ESP32 (/front, /back, /left, /right, /stop, /spinner/on, /spinner/off). The UI polls /status every 500 ms to update live sensor readings and spinner state.
The OLED refreshes every ~200 ms (every 4 loop cycles at 50 ms delay). It shows:
- Top bar: IP address + WiFi signal strength bars
- Face area: Happy face during normal operation; alert/surprised face when an obstacle is detected
- Direction panel: Text label and filled arrow icon matching the current movement direction
- Bottom sensor bar: Live L / C / R distances in cm; flashing "!! OBSTACLE !!" warning when center < 20 cm
- Status strip: SPIN:ON / SPIN:OFF text with a spinning line indicator when the mop is running
While the robot is moving, the servo continuously sweeps from 0 to 180 degrees. Distances are bucketed by angle into Left (0–60°), Center (60–120°), and Right (120–180°). If the center distance drops below 20 cm, the motors stop automatically, currentDir is set to 5 (obstacle), and the OLED switches to the alert face.
When the /front command is received, a full 3-point scan runs first. If center is clear, the robot moves forward. If blocked, it reports back with a directional suggestion (LEFT or RIGHT based on which side has more clearance).
The relay module is wired active-LOW. The mop spinning motor is toggled independently of movement, so you can run the mop while stationary or while driving.
4S 18650 Li-ion pack (14.8V) → L298N VCC for motors, L298N onboard 5V regulator → ESP32 VIN. All other 5V modules draw from the L298N regulator output. The OLED runs on 3.3V from the ESP32.
| L298N Pin | Connection |
|---|---|
| IN1 | GPIO 16 |
| IN2 | GPIO 17 |
| IN3 | GPIO 27 |
| IN4 | GPIO 26 |
| OUT1, OUT2 | Left-side motors |
| OUT3, OUT4 | Right-side motors |
| VCC | Battery positive (14.8V) |
| GND | Common ground |
| 5V out | ESP32 VIN |
Enable the onboard regulator jumper on the L298N if your module has one.
| Command | IN1 | IN2 | IN3 | IN4 |
|---|---|---|---|---|
| Forward | HIGH | LOW | HIGH | LOW |
| Backward | LOW | HIGH | LOW | HIGH |
| Turn Left | LOW | HIGH | HIGH | LOW |
| Turn Right | HIGH | LOW | LOW | HIGH |
| Stop | LOW | LOW | LOW | LOW |
If the robot turns the wrong way, swap the IN1/IN2 or IN3/IN4 pairs for that side.
| HC-SR04 Pin | Connection |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | GPIO 18 |
| ECHO | GPIO 19 |
The ESP32 is 3.3V logic. The HC-SR04 ECHO pin outputs 5V. A voltage divider (1k + 2k resistor) on the ECHO line is recommended to protect the GPIO.
| Relay Pin | Connection |
|---|---|
| VCC | 5V |
| GND | GND |
| IN1 | GPIO 25 |
| COM1 | Mop motor power in |
| NO1 | Mop motor + terminal |
Active-LOW. GPIO 25 HIGH = relay OFF, GPIO 25 LOW = relay ON. Initialised HIGH on startup so the mop is off by default.
| OLED Pin | Connection |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
Default I2C address is 0x3C. If the display does not initialise, try 0x3D. I2C is initialised with
Wire.begin(21, 22)in setup.
Venu Bot/
├── robot_oled.ino Main sketch (with full OLED support)
├── README.md This file
├── schematic.md Detailed wiring reference
└── bot Images/ Photos of the build
Darshan Pawar
GitHub: github.com/Darshanpawar7
