Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bluepad-racer

ESP32 Bluetooth RC car controlled via gamepad using Bluepad32.

Features

  • Bluetooth gamepad control (DualShock, Xbox, Switch, etc.)
  • Servo steering with proportional control
  • DC motor throttle with forward/reverse
  • Battery voltage monitoring with LED indicators
  • Rumble feedback support
  • Player LED indicators

Hardware Requirements

Component Quantity Description
ESP32 DOIT DevKit V1 1 Main controller
TB6612FNG 1 Dual H-Bridge motor driver
SG90 Servo 1 Steering mechanism
DC Motor 1 Drive motor (6-12V)
Battery 1 6-12V LiPo or similar
MP1584EN Buck Converter 1 5V-30V to 5V DC-DC 3A (ESP32 + Servo power)
LEDs 3 Green, Yellow, Red (optional)
Resistors 3 220Ω for LEDs (optional)
Resistors 2 22kΩ + 10kΩ for voltage divider (optional)

Wiring Schematics

ESP32 Pin Mapping

┌─────────────────────────────────────────────────────────┐
│                        ESP32                            │
│                                                         │
│  GPIO18 ──────────────────► Servo Signal                │
│  GPIO25 ──────────────────► TB6612 PWMA                 │
│  GPIO26 ──────────────────► TB6612 AIN1                 │
│  GPIO27 ──────────────────► TB6612 AIN2                 │
│  GPIO33 ──────────────────► TB6612 STBY                 │
│  GPIO34 ──────────────────► Battery ADC (via divider)   │
│  GPIO12 ──────────────────► Green LED                   │
│  GPIO13 ──────────────────► Yellow LED                  │
│  GPIO14 ──────────────────► Red LED                     │
│  GND    ──────────────────► Common Ground               │
│  VIN    ──────────────────► 5V (from MP1584EN Buck)     │
└─────────────────────────────────────────────────────────┘

TB6612FNG Motor Driver

┌─────────────────────────────────────────────────────────┐
│                    TB6612FNG                            │
│                                                         │
│  VM  ──────────────────► Battery (+) 6-12V              │
│  VCC ──────────────────► ESP32 3V3                      │
│  GND ──────────────────► Common Ground                  │
│  PWMA ─────────────────► ESP32 GPIO25                   │
│  AIN1 ─────────────────► ESP32 GPIO26                   │
│  AIN2 ─────────────────► ESP32 GPIO27                   │
│  STBY ─────────────────► ESP32 GPIO33                   │
│  A01  ─────────────────► Motor (+)                      │
│  A02  ─────────────────► Motor (-)                      │
└─────────────────────────────────────────────────────────┘

5V Buck Converter (MP1584EN)

┌─────────────────────────────────────────────────────────┐
│            MP1584EN DC-DC Buck Converter                │
│                                                         │
│  IN+  ──────────────────► Battery (+) 6-12V             │
│  IN-  ──────────────────► Battery (-) / GND             │
│  OUT+ ──────────────────► ESP32 VIN / 5V                │
│  OUT- ──────────────────► Common Ground                 │
│                                                         │
│  ┌─────────────────────────────────────────────────┐    │
│  │  ESP32 VIN  ◄─────── OUT+                       │    │
│  │  Servo VCC  ◄─────── OUT+ (Red wire)            │    │
│  │  Common GND ◄─────── OUT- / IN- / Battery (-)   │    │
│  └─────────────────────────────────────────────────┘    │
│                                                         │
│  Note: Adjust potentiometer on module to output 5V      │
└─────────────────────────────────────────────────────────┘

Servo Motor (SG90)

┌─────────────────────────────────────────────────────────┐
│                    SG90 Servo                           │
│                                                         │
│  Brown/Black ──────────► GND                            │
│  Red         ──────────► 5V (from MP1584EN Buck Conv)   │
│  Orange      ──────────► ESP32 GPIO18                   │
└─────────────────────────────────────────────────────────┘

Battery Voltage Monitor (Divider)

┌─────────────────────────────────────────────────────────┐
│              Voltage Divider Circuit                    │
│                                                         │
│  Battery (+) ──┬── R1 (22kΩ) ──┬── ESP32 GPIO34         │
│                │               │                        │
│                │            R2 (10kΩ)                   │
│                │               │                        │
│  Battery (-) ──┴───────────────┴── GND                  │
│                                                         │
│  Vout = Vin × R2/(R1+R2)                                │
│  Divider Ratio: 10k/(22k+10k) = 0.3125                  │
│  Max Safe Input: 3.3V → Max Battery: ~10.5V             │
└─────────────────────────────────────────────────────────┘

Battery Indicator LEDs

┌─────────────────────────────────────────────────────────┐
│                LED Connections                          │
│                                                         │
│  ESP32 GPIO12 ── R (220Ω) ──► Green LED ──► GND         │
│  ESP32 GPIO13 ── R (220Ω) ──► Yellow LED ──► GND        │
│  ESP32 GPIO14 ── R (220Ω) ──► Red LED ──► GND           │
└─────────────────────────────────────────────────────────┘

Battery Connections

┌───────────────────────────────────────────────────────────┐
│                   Battery Connections                     │
│                                                           │
│  Battery (+) ──┬──► TB6612 VM (motor power)               │
│                │                                          │
│                └──► MP1584EN IN ──► OUT ──┬──► ESP32 VIN  │
│                                           │               │
│                                           └──► Servo VCC  │
│                                                           │
└───────────────────────────────────────────────────────────┘

Complete System Overview

┌─────────────────────────────────────────────────────────┐
│                   SYSTEM DIAGRAM                        │
│                                                         │
│   ┌──────────┐       Bluetooth     ┌─────────┐          │
│   │ Gamepad  │ ◄─────────────────► │  ESP32  │◄──┐      │
│   └──────────┘                     └────┬────┘   │      │
│                                         │        │      │
│                    ┌────────────────────│        │      │
│                    │                    │        │      │
│              ┌─────▼─────┐        ┌─────▼─────┐  │      │
│              │  TB6612   │        │   Servo   │  │      │
│      ┌─ VM ─►│   FNG     │        │   SG90    │  │      │
│      │       └─────┬─────┘        └───────────┘  │      │
│      │             │                    ▲        │      │
│      │       ┌─────▼─────┐              │        │      │
│      │       │    DC     │              │        │      │
│      │       │   Motor   │              │        │      │
│      │       └───────────┘              │        │      │
│      │                                  │        │      │
│      │             ┌─────────────────────────────┘      │
│      │             │ 5V (powers ESP32 + Servo)          │
│      │       ┌───────────┐                              │
│      │       │ MP1584EN  │                              │
│      │       │  Buck     │                              │
│      │       │ Converter │                              │
│      │       └─────▲─────┘                              │
│      │             │ 6-12V                              │
│      │       ┌───────────┐                              │
│      └───────│ Battery   │                              │
│              │ 6-12V     │                              │
│              └───────────┘                              │
└─────────────────────────────────────────────────────────┘

Setup Instructions

Prerequisites

  1. Install Arduino CLI
  2. Connect ESP32 via USB

Quick Setup

# Install board core and libraries
make setup

# Compile and upload
make upload

# Open serial monitor
make monitor

Manual Setup

# Add board manager URLs
arduino-cli config add board_manager.additional_urls \
    https://raw.githubusercontent.com/ricardoquesada/esp32-arduino-lib-builder/master/bluepad32_files/package_esp32_bluepad32_index.json

# Update board index
arduino-cli core update-index

# Install ESP32 Bluepad32 core
arduino-cli core install esp32-bluepad32:esp32

# Install required libraries
arduino-cli lib install "Bluepad32" "ESP32Servo"

Controller Mapping

Input Action
Right Stick X-axis Steering (left/right)
Right Stick Y-axis Throttle (forward/reverse)
Button A Cycle LED color (Red → Green → Blue)
Button B Cycle player LEDs
Button X Rumble feedback

Make Targets

Target Description
make compile Compile the sketch
make upload Compile and upload via USB
make upload-ota Compile and upload via OTA
make monitor Open serial monitor (115200 baud)
make setup Install board core and libraries
make clean Remove build artifacts
make size Show sketch size info
make help Show all available targets

Troubleshooting

Controller Not Connecting

  1. Ensure Bluetooth is enabled on your device
  2. Press the pairing button on your gamepad
  3. Check serial monitor for connection messages
  4. Try BP32.forgetBluetoothKeys() in setup() to reset pairings

Motor Not Working

  1. Check TB6612FNG wiring (especially VM for motor power)
  2. Verify STBY pin is HIGH
  3. Ensure battery has sufficient charge

Servo jittering

  1. Ensure buck converter is outputting stable 5V (adjust potentiometer)
  2. Check servo power wire connected to buck converter OUT+
  3. Adjust SERVO_MIN_ANGLE/SERVO_MAX_ANGLE if needed

Build Errors

  1. Run make setup to install required board and libraries
  2. Check Arduino IDE Board Manager for ESP32 Bluepad32
  3. Verify all libraries are installed: make libs

License

MIT License - see LICENSE for details.

About

ESP32 Bluetooth RC car controlled via gamepad using Bluepad32.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages