This project implements a robust, low-latency web interface hosted on a Raspberry Pi 5 to control an ESP32-based robot. The system acts as a bridge, allowing users to drive the robot and manipulate servos via a responsive web dashboard while the ESP32 handles real-time motor control.
We replaced standard timer-based loops with a custom Async/Await JavaScript architecture.
- No Command Buffering: The browser waits for a "ready" signal from the robot before sending the next command, preventing command pile-up during network lag.
- Instant Halt: The robot stops immediately when controls are released, eliminating "runaway robot" scenarios common in standard WiFi controllers.
- Redundant Stop System: Uses a "Double-Stop" protocol (sending the stop signal multiple times) to guarantee the robot halts even if a UDP/TCP packet is lost.
- Touch Safety Guard: Actively listens for
touchcancelandmouseleaveevents. If a user's finger slips off the button or an alert interrupts the screen, the motors cut power instantly.
- 3-Axis Manipulation: Dedicated sliders for controlling 3 independent servo motors (e.g., Base, Arm, Claw).
- Touch Optimization: CSS rules (
touch-action: manipulation) prevent accidental zooming or text selection during rapid driving. - Real-Time Telemetry: AJAX fetch calls provide live feedback from wheel encoders and onboard sensors.
Before uploading the firmware, wire your ESP32 to the motors and drivers (L298N) as shown below. The ESP32 acts as the low-level hardware controller.
Upload Target: ros2_bridge_esp32 (or your specific firmware file)
The Raspberry Pi 5 functions as the central web server and command hub. It hosts the user interface and relays commands to the ESP32 over WiFi or Serial.
- Flash ESP32: Upload the motor control code to your ESP32 using the Arduino IDE or PlatformIO.
- Setup RPi5: Run the web server script on your Raspberry Pi.
- Connect: Open the RPi5's IP address in your browser to access the control dashboard.