ESP32S3-CAM RC Car
A remote-controlled car built on an ESP32-S3-based platform that can be controlled by mouse, keyboard or a gamepad!
It also features front headlights with high and low beam modes and can capture photos.
Also published at https://www.instructables.com/ESP32S3-CAM-RC-Car/.
Recordings
Note: enable the sound by clicking on the speaker icon from the video toolbar.
https://github.com/user-attachments/assets/5d8425a9-dce1-491e-ae34-59c03d8f86cc
https://github.com/user-attachments/assets/d4d6b7d5-77e2-4f4a-8a79-1368959aa9ee
https://github.com/user-attachments/assets/c7326e6f-baf5-430e-8a99-d2c3559c9cec
https://github.com/user-attachments/assets/f941ac1c-32bb-405a-ad6e-40529a32f8a9
Description
This project is the successor to the ESP32CAM-RC-Car project, which was based on a previous-generation ESP32 board.
The ESP32-S3 is a more powerful microcontroller that delivers smooth, low-latency video streaming.
Also, this project uses the DRV8833 as a motor driver, improving power efficiency and reaching higher speeds.
Control methods
Mouse
By default, the car is controlled through a web page featuring a virtual joystick.
Keyboard
To use the keyboard, press the Enter key at any time. Press it again to switch back to the virtual joystick.
- Enable/Disable:
Enter
- Left/Right:
A/D, or ←/→
- Up:
W or ↑
- Reverse:
S or ↓
- Camera:
P or C
- Front LEDs:
L or F
- Max speed: from
1 (10) to 0 (100)
Gamepad
To use a USB PlayStation 3 compatible gamepad, press the Start button at any time. Press it again to switch back to the virtual joystick.
- Enable/Disable:
Start
- Left/Right:
left analog
- Up:
R2
- Reverse:
L2
- Max speed: on analog triggers, set by how far
R2/L2 is pressed (e.g. 90% pressed = 90% speed)
- Camera:
△
- Front LEDs:
□
Remote control
If you are familiar with configuring internet routers and setting port forwarding, you can also control your car remotely!
- Ensure you assign a static IP.
- Set up the following port forwarding rules:
- 8000 (web page)
- 8001 (video streaming)
- 8002 (WebSocket / joystick commands).
- If your ISP changes your public IP frequently, set up a DDNS service (e.g., No-IP)
Compatible boards
Freenove ESP32S3-CAM (Recommended)
This board is affordable and offers excellent build quality. It also provides a large number of GPIO pins.
Additionally, it features a built-in USB programmer, so you do not need an external USB programmer to flash it.
Instructions:
- At
Config.h, uncomment CAMERA_FREENOVE_ESP32S3_CAM
- In the PIO Arduino, use the env
esp32s3cam.
Seeed Studio XIAO ESP32-S3 Series
This very compact board offers excellent build quality, although it is more expensive. Another advantage is the connector for an external antenna and the built-in USB programmer. It is recommended to use its heat sinks due to the heat generated during streaming.
Instructions:
- At
Config.h, uncomment CAMERA_MODEL_XIAO_ESP32S3
- In the PIO Arduino, use the env
xiaoS3cam.
ESP32S3-CAM (“AI Thinker v2”)
This board is commonly sold as ESP32S3-CAM on some Chinese e-commerce websites and is considered the unofficial successor to the ESP32-CAM AI Thinker board. It can be found on AliExpress.
NOTE: There are slightly different versions of this board, and they may use different GPIO assignments. Additionally, the bright FLASH LED found on the original board has been replaced by an RGB LED on some models.
Instructions:
- At
Config.h, uncomment CAMERA_MODEL_AI_THINKER_V2
- In the PIO Arduino, use the env
esp32s3cam.
ESP32-CAM (“AI Thinker v1”)
This is the original ESP32-CAM AI-Thinker board, featuring the older ESP32-S series processor. You may occasionally experience brief streaming lag, but it is still a great choice for this project.
NOTE: This board includes a built-in high-brightness flash LED connected to GPIO 4. It will not be used in this project, as the front LEDs are intended to replace it. The front LEDs provide brighter illumination and better electrical isolation, helping to avoid interference with the video stream.
Instructions:
- At
Config.h, uncomment CAMERA_MODEL_AI_THINKER
- In the PIO Arduino, use the env
ai_tinker.
Schematics
Option 1 - Easier to build (uses L298N bridge)
I recommend starting with this project, as it is easier and faster to build while still being enough to get the car working perfectly.
Option 2 - More complex to build (uses DRV8833 bridge)
If you want to upgrade to a more energy-efficient project with faster motors, and you have time and experience with soldering components, this is a great option.
The DRV8833 uses modern MOSFET transistor and drops around 0.2-0.4v, while the L298N is based on older bipolar transistor technology and drops around 2-4 V. This means more voltage reaches the motor, resulting in better performance, less heat, and improved battery efficiency.
I could not find any motor shield so I had to design my own PCB. Download the Gerber file.
The cost was about 2 USD on EasyEDA, with shipping costs varying by country.
Components
Option 1 (L298N)
- 01 - L298N Dual H-Bridge board
Option 2 (DRV8833)
- 01 - DRV8833 Dual H-Bridge board
- 01 - L2596 Bulk Converter
About “PIO Arduino” IDE
This project was created on “Visual Studio Code” with “PIO Arduino” plugin.
Compared to the official Arduino IDE, this setup offers better dependency management, multi-environment (board) support, and a project structure that promotes modular and object-oriented code.
About the code
The parameters and PINs can be set in the file Config/src/Config.h
// WiFi credentials
#define WIFI_SSID "YOUR_SSID"
#define WIFI_PWD "YOUR_PWD"
// Access Point mode
// + true = creates a WiFi network without internet connection
// the car IP will always be http://192.168.4.1:8000
// + false = connect to an existing WiFi with internet connection
// the car IP will be assigned by the router http://X.X.X.X:8000
#define WIFI_AP_MODE true
// WiFi channel used in Access Point mode (1 to 13)
// pick a less crowded channel to reduce interference and latency
#define WIFI_AP_CHANNEL 1
// Set minimum motor speed (0 to 255)
#define MIN_MOTOR_SPEED 80
// Failsafe: stop the motors when no command is received for this long (ms).
// The web UI sends a command every 50 ms, so this gives a 10x margin.
#define COMMAND_TIMEOUT_MS 500
// Enable debug (prints car speed and direction in the serial)
#define JOYSTICK_DEBUG false
// Set camera model
#define CAMERA_FREENOVE_ESP32S3_CAM
// #define CAMERA_MODEL_XIAO_ESP32S3
// #define CAMERA_MODEL_AI_THINKER_V2
// #define CAMERA_MODEL_AI_THINKER
// Set JPEG quality (0 to 63 - lower means higher quality)
// NOTE: Higher image quality reduces CPU usage for compression.
#define JPEG_QUALITY 15
// Improve FPS by using double buffering (usually works perfectly
// for ESP32-S3 family)
#define INCREASE_FPS true
// Customize PINS
#if defined(CAMERA_FREENOVE_ESP32S3_CAM)
#define PIN_M1_IN1 42
#define PIN_M1_IN2 41
#define PIN_M2_IN1 40
#define PIN_M2_IN2 39
#define PIN_FRONT_LED 3
#define PIN_RGB_LED 48
// NOTE: higher resolutions affect framerate
#define FRAME_SIZE FRAMESIZE_VGA
#elif defined(CAMERA_MODEL_XIAO_ESP32S3)
#define PIN_M1_IN1 1
#define PIN_M1_IN2 2
#define PIN_M2_IN1 3
#define PIN_M2_IN2 4
#define PIN_FRONT_LED 9
#define PIN_BOARD_LED 7
// NOTE: higher resolutions affect framerate
#define FRAME_SIZE FRAMESIZE_VGA
#elif defined(CAMERA_MODEL_AI_THINKER_V2)
#define PIN_M1_IN1 14
#define PIN_M1_IN2 47
#define PIN_M2_IN1 38
#define PIN_M2_IN2 39
#define PIN_FRONT_LED 40
#define PIN_RGB_LED 48
// NOTE: higher resolutions affect framerate
#define FRAME_SIZE FRAMESIZE_VGA
#elif defined(CAMERA_MODEL_AI_THINKER)
#define PIN_M1_IN1 14
#define PIN_M1_IN2 15
#define PIN_M2_IN1 12
#define PIN_M2_IN2 13
#define PIN_FRONT_LED 3
#define PIN_BOARD_LED 33
// NOTE: higher resolutions affect framerate
#define FRAME_SIZE FRAMESIZE_VGA
#else
#error "Camera model not selected"
#endif
Fine-tuning customization can be done in the individual files like DCMotor.h for changing speed parameters
#ifndef DCMOTOR_H
#define DCMOTOR_H
#include <Arduino.h>
class DCMotor
{
public:
DCMotor(uint8_t pinIn1, uint8_t pinIn2);
void backward(uint8_t speed = 100);
void forward(uint8_t speed = 100);
void setMinAbsSpeed(uint8_t absSpeed);
void stop();
private:
uint8_t pinIn1;
uint8_t pinIn2;
uint8_t absSpeed = 0;
uint8_t maxAbsSpeed = 255;
uint8_t minAbsSpeed = 50;
uint8_t ignoreAbsSpeed = 30;
void setSpeed(uint8_t speed);
void write(uint8_t duty1, uint8_t duty2);
};
#endif
About Car Chassis
This project can work with a 2WD or 4WD car chassis like these ones:
Reference 1 (Brazil):
https://www.robocore.net/robotica-robocore/plataforma-robotica-rocket-tank
Reference 2 (International):
https://www.aliexpress.us/item/3256801542172576.html
Reference 3 (International):
https://www.aliexpress.us/item/3256805855273192.html
About the Power Supply
I recommend to use high quality 18650 batteries (3.7v - 4.2v, 2200mAh, at least 2C of discharge rate).
Most people prefer to use different power sources for ESP32-CAM (3.3v or 5v) and Bridge driver (7.4 - 8.4v).
I prefer to have a single power source and thus a single power switch. However, it is recommended to use capacitor to filter the electrical noise created by the bridge.
Fritzing file
The eletronic schematic was created in the Fritzing software and can be downloaded at
评论