An ESP32 Controls This FPV Wi-Fi-Enabled Car
With only a phone, ESP32, camera module, and some motors, The Wrench was able to make a tiny yet quick FPV car that streams its perspective.
The world of FPV
FPV, or first-person view, is a technique in operating radio controlled vehicles where a camera is mounted to the vehicle, often a drone or car, which then sends a live video feed to the operator. Ultimately, this gives the feeling of actually driving/piloting in the first-person rather than as an external controller and can lead to better performance overall. The YouTuber and maker known as "The Wrench" sought to build his own RC car version from inexpensive hardware, as he wanted to replace the low-latency transmitter and headset with Wi-Fi and a phone.
Building and assembling the hardware
To make this all work, The Wrench chose the Xiao ESP32S3 Sense board from Seeed Studio due to its very small size, onboard Wi-Fi/Bluetooth Low Energy radio, and expansion port. This last item is in the form of a fine-pitch socket that lets an accompanying OV2640 camera module connect and provide real-time video, still images, and audio.
On the movement side of things, the car propels itself via a set of four 6mm geared DC motors that were attached in parallel to a single L298N motor driver board. Powering these motors and Xiao ESP32 is a single 3.7V 500mAh LiPo battery cell, and all of these components were mounted onto a simple 3D printed car chassis.
Live-streaming challenges
Sending and receiving live video on any device is a challenge, but it becomes far more difficult when bandwidth and processing power are constrained on the source device and when low latency is a must-have. The program running on the ESP32 handles these constraints by exposing a local webserver and access point with several endpoints. The main one, /stream
, reads the latest frame from the camera module, converts it to a compressed JPEG, and sends it back to the client, forming a motion JPEG or MJPEG image source. This way, the ESP32 doesn't have to maintain a session and continuously push frames unless it is requested to do so by the client.
The web application
Beyond getting an image, the webserver is configured to return a webpage when the index is accessed. In it there are several buttons that each emit a direction event, which in turn causes an HTTP request to be sent to the corresponding endpoint. The ESP32 then handles these requests by either setting the wheel motor speeds in the case of forward, backward, left, and right, or toggling its LED on or off. To see more about this project, you can read The Wrench's write-up here on Instructables or watch his YouTube video here.