A DIY RC car project that uses a USB joystick to control a four-wheeled vehicle via ESP32 microcontrollers and ESP-NOW wireless communication.
- USB joystick support for intuitive control
- Wireless communication using ESP-NOW protocol
- Dual control modes:
- Simple mode (4-direction control)
- Throttle and steering mode (proportional control)
- Real-time control with minimal latency
- Automatic safety stop on signal loss
- Support for various USB joysticks
- Configurable motor calibration
- Built-in deadband compensation
- ESP32 Development Board
- USB Joystick
- USB cables
- Power supply (USB or battery)
- ESP32 Development Board
- L298N Motor Driver
- 4× DC Motors (6-12V)
- Battery Pack (6-12V)
- Chassis (DIY or pre-made)
- Jumper Wires
- Power supply for ESP32
- Arduino IDE
- Required Libraries:
- ESP32-USB-Soft-Host
- ESP-NOW
- WiFi.h
- Connect the ESP32 to the USB joystick:
- GPIO 16 → USB D+ (Green wire)
- GPIO 17 → USB D- (White wire)
- GND → USB GND (Black wire)
- 5V → USB VCC (Red wire)
-
Connect ESP32 to L298N Motor Driver:
ESP32 → L298N GPIO 16 → IN1 GPIO 17 → IN2 GPIO 18 → IN3 GPIO 19 → IN4 GPIO 22 → ENA GPIO 23 → ENB
-
Connect L298N to Motors:
L298N → Motors OUT1, OUT2 → Right Motors OUT3, OUT4 → Left Motors
-
Power Connections:
Battery (6-12V) → L298N 12V L298N 5V → ESP32 VIN GND → Common Ground
-
Install Required Libraries:
# Clone ESP32-USB-Soft-Host library git clone https://github.com/tobozo/ESP32-USB-Soft-Host.git # Move to Arduino libraries folder
-
Configure Arduino IDE:
- Select ESP32 board
- Set upload speed to 115200
- Select correct COM port
-
Upload Code:
- Upload transmitter code to the controller ESP32
- Upload receiver code to the car's ESP32
-
Get receiver's MAC address:
- Upload and run the included MAC address finder sketch
- Copy the printed MAC address
-
Update transmitter code:
uint8_t receiverMacAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // Replace with your MAC
Adjust motor calibration values in MotorCalibration
class:
static constexpr float leftMotorMultiplier = 1.0; // Adjust if needed
static constexpr float rightMotorMultiplier = 1.0; // Adjust if needed
static constexpr float turnSpeedMultiplier = 0.7; // Adjust turn speed
static constexpr float turnRatio = 0.5; // Adjust turn sharpness
- Power up both transmitter and receiver units
- Wait for ESP-NOW connection (LED indicator)
- Control modes:
- Default: Simple 4-direction control
- Press joystick button to toggle throttle/steering mode
- Emergency stop: Release joystick or power off transmitter
Common issues and solutions:
-
Motors don't respond:
- Check power connections
- Verify MAC address configuration
- Check motor driver connections
-
Erratic movement:
- Calibrate motors using multiplier values
- Check for loose connections
- Verify power supply stability
-
Connection issues:
- Ensure both units are powered
- Check MAC address configuration
- Verify ESP-NOW initialization
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- ESP32-USB-Soft-Host library
- ESP-NOW documentation and examples
- Arduino community for various inspirations
For support and questions:
- Open an issue
- Check existing documentation
- Review closed issues for similar problems
Made with ❤️ by Ahammad Nafiz