Skip to content

A complete guide to building a Bluetooth-controlled robo-car using ESP32, featuring variable speed control, 8-direction movement, and smooth PWM motor control. This project utilizes 4 DC gear motors, BTS7960 motor drivers, and an HC-06 Bluetooth module for wireless navigation.

Notifications You must be signed in to change notification settings

AdityaPandey-DEV/Robo-Car-Racing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Robo-Car-Racing

ESP32 Robot Car with Bluetooth Control

A 4-motor robot car controlled via Bluetooth using ESP32, HC-06 Bluetooth module, and BTS7960 motor drivers. Features variable speed control (0-100%) and 8-direction movement capabilities.

Project Overview

This project implements a fully functional Bluetooth-controlled robot car with:

  • 4x 12V 500 RPM DC Gear Motors - Two motors per side (left and right)
  • 2x BTS7960 Motor Drivers - One driver for left side, one for right side
  • ESP32 Microcontroller - Main control unit
  • HC-06 Bluetooth Module - Wireless communication interface
  • Variable Speed Control - 0-100% in 10% increments
  • 8-Direction Movement - Forward, backward, left, right, and 4 diagonal directions

Components List

Component Quantity Specifications
ESP32 Development Board 1 Any ESP32 variant (ESP32-WROOM, ESP32-DevKit, etc.)
HC-06 Bluetooth Module 1 3.3V logic, 9600 baud default
BTS7960 Motor Driver 2 High-current H-bridge driver
12V DC Gear Motor 4 500 RPM, suitable current rating
12V Battery Pack 1 Sufficient capacity for motors (2-5A per motor)
5V Power Supply 1 For ESP32 (USB or regulated supply)
Jumper Wires As needed 22-24 AWG for signals, 18-20 AWG for motor power
Breadboard/PCB 1 For prototyping or permanent mounting

Features

  • ✅ Bluetooth wireless control via HC-06 module
  • ✅ Variable speed control (0-100% in 10% steps)
  • ✅ 8-direction movement (forward, back, left, right, 4 diagonals)
  • ✅ Smooth PWM-based motor control
  • ✅ Emergency stop function
  • ✅ Real-time command processing
  • ✅ Serial debugging support

Quick Start Guide

1. Hardware Setup

  1. Review Connections

    • Read CONNECTIONS.md for detailed wiring instructions
    • Ensure all components are properly connected
    • Verify all GND connections are common (shared ground)
  2. Power Supplies

    • Connect ESP32 via USB or 5V regulated supply
    • Connect 12V battery pack to both BTS7960 modules (B+ and B-)
    • Critical: Connect 12V battery negative to common GND
  3. Initial Check

    • Power on ESP32 and verify it initializes
    • Check Serial Monitor (115200 baud) for startup messages
    • Verify HC-06 LED is blinking

2. Software Setup

  1. Install Arduino IDE

    • Download from arduino.cc
    • Install ESP32 board support:
      • File → Preferences → Additional Board Manager URLs
      • Add: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
      • Tools → Board → Boards Manager → Search "ESP32" → Install
  2. Upload Code

    • Open robot_car.ino in Arduino IDE
    • Select board: Tools → Board → ESP32 Arduino → Your ESP32 board
    • Select port: Tools → Port → (your ESP32 port)
    • Click Upload button
    • Wait for "Done uploading" message
  3. Verify Upload

    • Open Serial Monitor (Tools → Serial Monitor)
    • Set baud rate to 115200
    • You should see initialization messages

3. Bluetooth Pairing

  1. Enable Bluetooth on your smartphone/tablet
  2. Scan for devices - Look for "ESP32_RobotCar"
  3. Pair - Default PIN is usually "1234" or "0000"
  4. Verify connection - Device should show as "Connected"

4. Install Control App

Recommended Android apps:

  • Arduino Bluetooth Controller (by Mightyohm)
  • Bluetooth RC Controller (by SimpleSoft)

See TESTING.md for detailed app configuration and button mapping.

5. Test the Car

  1. Start with wheels off ground (safety first!)
  2. Test basic movements: Forward (F), Backward (B), Left (L), Right (R)
  3. Test speed control: Set speed to 20% (2), then try movements
  4. Test on ground at low speed, then gradually increase

See TESTING.md for comprehensive testing procedures.

Command Reference

Movement Commands

Command Function Description
F Forward Both sides move forward
B Backward Both sides move backward
L Turn Left Right forward, left backward (spin left)
R Turn Right Left forward, right backward (spin right)
G Forward Left Right full speed, left reduced (diagonal)
1 Forward Right Left full speed, right reduced (diagonal)
H Back Left Right backward full, left backward reduced
J Back Right Left backward full, right backward reduced
S Stop Stop all motors

Speed Control Commands

Command Speed PWM Value
0 0% 0
2 20% 51
3 30% 77
4 40% 102
5 50% 128 (default)
6 60% 153
7 70% 179
8 80% 204
9 90% 230
q 100% 255

Note: Speed 10% (command '1') conflicts with Forward Right movement. In current implementation, '1' triggers Forward Right. To achieve 10% speed, use speed 0% and gradually increase, or modify the code.

Special Commands

Command Function Description
D Stop All Emergency stop - stops motors and resets speed to default

File Structure

Robo car racing/
├── README.md           # This file - project overview and quick start
├── CONNECTIONS.md      # Detailed wiring diagram and connections
├── TESTING.md          # Comprehensive testing guide and troubleshooting
└── robot_car.ino       # Main Arduino code for ESP32

Technical Specifications

Hardware

  • Microcontroller: ESP32 (240 MHz dual-core, WiFi/Bluetooth)
  • Bluetooth Module: HC-06 (Classic Bluetooth, 9600 baud)
  • Motor Drivers: BTS7960 (43A peak, H-bridge)
  • Motors: 12V DC Gear Motors, 500 RPM
  • PWM Frequency: 1000 Hz
  • PWM Resolution: 8-bit (0-255)

Software

  • Platform: Arduino IDE with ESP32 support
  • Bluetooth Library: BluetoothSerial (built-in)
  • Communication: Serial over Bluetooth (9600 baud)
  • Command Protocol: Single ASCII character commands

Safety Warnings

⚠️ CRITICAL SAFETY INFORMATION

  1. Power Supply Isolation

    • ESP32 and motors use separate power supplies
    • Never connect motor power (12V) directly to ESP32
    • Always use common ground connection
  2. Current Requirements

    • Motors can draw 2-5A each at full load
    • Ensure battery pack can supply sufficient current
    • Use appropriate wire gauge for motor connections (18-20 AWG)
  3. Testing Safety

    • Always test with wheels off ground first
    • Start with low speeds
    • Keep hands away from moving parts
    • Have emergency stop ready (D command)
  4. Battery Safety

    • Use appropriate battery type (LiPo, NiMH, etc.)
    • Monitor battery voltage - don't over-discharge
    • Use proper battery protection circuits if needed
    • Charge batteries in safe location
  5. Electrical Safety

    • Disconnect power before making wiring changes
    • Check for short circuits before powering on
    • Use proper insulation on all connections
    • Ensure no loose wires

Troubleshooting

Common issues and solutions:

Motors Not Moving

  • Check 12V battery connection and charge
  • Verify BTS7960 enable pins (L_EN, R_EN) are HIGH
  • Check motor connections to M+ and M- terminals
  • Verify common ground connection

Bluetooth Not Connecting

  • Check HC-06 VCC is 3.3V (not 5V)
  • Verify TXD/RXD connections (crossed: TX→RX, RX→TX)
  • Try different pairing codes: "1234", "0000"
  • Ensure device is within range (10 meters)

Wrong Motor Direction

  • Swap M+ and M- connections on affected driver
  • Or modify code to reverse direction logic

ESP32 Resets/Crashes

  • Check power supply quality and current capacity
  • Verify no short circuits
  • Check for overheating

For detailed troubleshooting, see TESTING.md.

Customization

Adjust Default Speed

In robot_car.ino, modify:

int currentSpeed = 128;  // Change this value (0-255)

Adjust PWM Frequency

In robot_car.ino, modify:

#define PWM_FREQUENCY  1000  // Change frequency in Hz

Adjust Diagonal Movement Speed Ratio

In diagonal movement functions, modify the speed reduction:

int leftSpeed = currentSpeed / 2;  // Change /2 to /3, /4, etc.

Change Bluetooth Device Name

In robot_car.ino, modify:

SerialBT.begin("ESP32_RobotCar");  // Change device name

Project Status

✅ Hardware connections documented
✅ Arduino code implemented
✅ Testing procedures documented
✅ Command protocol defined
✅ Safety guidelines provided

Future Enhancements

Possible improvements:

  • Add obstacle avoidance sensors
  • Implement speed ramping for smoother acceleration
  • Add battery voltage monitoring
  • Implement PID control for precise movement
  • Add LED indicators for status
  • Create custom mobile app
  • Add IMU for orientation control
  • Implement autonomous navigation modes

License

This project is provided as-is for educational and hobby purposes.

Support

For issues or questions:

  1. Review CONNECTIONS.md for wiring issues
  2. Review TESTING.md for testing and troubleshooting
  3. Check Serial Monitor output for error messages
  4. Verify all connections match the documentation

Acknowledgments

  • ESP32 Arduino Core developers
  • BTS7960 motor driver documentation
  • HC-06 Bluetooth module community

Happy Building! 🚗💨

Remember: Safety first, test thoroughly, and have fun!

About

A complete guide to building a Bluetooth-controlled robo-car using ESP32, featuring variable speed control, 8-direction movement, and smooth PWM motor control. This project utilizes 4 DC gear motors, BTS7960 motor drivers, and an HC-06 Bluetooth module for wireless navigation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages