Advanced
6 hours
Bluetooth Controlled Robot Car with ESP32
This robot car project combines mechanics (4WD chassis), power electronics (L298N dual H-bridge), and wireless control (ESP32 Bluetooth Classic). The ESP32-CAM variant adds a live 320×240 video stream so you can drive the robot FPV-style from your phone. Custom speed control uses PWM for smooth acceleration rather than just on/off motor control.
What You’ll Need
- 4WD robot car chassis kit (includes 4 DC motors and wheels)
- ESP32 DevKit (or ESP32-CAM for video streaming)
- L298N dual H-bridge motor driver module
- 7.4 V 2S LiPo battery (1500 mAh minimum)
- LiPo balance charger
- Ultrasonic sensor HC-SR04 (front-facing for obstacle detection)
- HC-05 Bluetooth module OR use ESP32’s built-in Bluetooth
- Android smartphone + Arduino Bluetooth Controller app (or write your own)
Step-by-Step Instructions
- Assemble the chassis: Follow the kit instructions to mount all four motors. Pair left-front/left-rear motors together on one side, right-front/right-rear on the other.
- Wire L298N: Motor pair A → OUT1/OUT2. Motor pair B → OUT3/OUT4. IN1–IN4 → ESP32 GPIO pins 25, 26, 27, 14. ENA and ENB (enable, PWM speed control) → GPIO 32 and 33 (LEDC PWM capable pins on ESP32).
- Power routing: 7.4 V LiPo → L298N 12 V input. L298N’s 5 V output → ESP32 VIN. Do NOT power the ESP32 from L298N’s 5 V if using the camera — use a separate 3.3 V LDO.
- Bluetooth command parsing: Use ESP32 BluetoothSerial library. In loop(), read incoming bytes. Define a command set: F=forward, B=backward, L=left, R=right, S=stop. Digits 1–9 set speed (PWM 0–255). Parse and apply to L298N enable pins.
- Add obstacle avoidance: Read HC-SR04 every 100 ms in a FreeRTOS task. If distance < 20 cm, override BT command with automatic stop/reverse.
- If using ESP32-CAM: Use the CameraWebServer example to stream video on port 81. Access from phone browser while using a Bluetooth controller app simultaneously.
- Trim and tune: If robot pulls left/right in a straight line, adjust PWM values for each motor pair slightly to compensate for motor speed differences.
Safety Notes
- LiPo batteries can catch fire if over-discharged, punctured, or incorrectly charged — always use a balance charger and never discharge below 3 V per cell (6 V total for 2S).
- Add a main power switch — never rely on the Bluetooth control as the only off switch.
- Spinning rubber wheels at full power can trap fingers — keep hands clear when testing.
Tips & Troubleshooting
- If one side of motors doesn’t respond, check the L298N IN pin connections and verify the enable pin is PWM HIGH, not LOW.
- Bluetooth range is typically 10 m — switch to WiFi control with UDP packets for longer range and lower latency.
- Add encoders to the motors for closed-loop speed control and straight-line driving capability.