Module 2 • Autonomous 2WD ESP32-S3 Super-Kit Zero-Library C++

Session 6: DRV8833 Dual H-Bridge 2WD Obstacle Rover

Dual H-Bridge motor driver with 2x TT gear motors, chassis assembly, and autonomous radar navigation.

← Course Book 🏫 Satpuda Lab
Connect Robo Logo Connect Robo Kit

⚡ 4-Step Visual System Flow

No Text Walls • 1-Glance Architecture
Step 1 📡
Forward Sonar Scan
HC-SR04 Sonar

Measures distance to approaching walls or obstacles.

Step 2 🧠
Obstacle Avoidance
Distance < 20cm Rule

Rover detects dead-end and initiates evasive reverse turn.

Step 3 ⚡
DRV8833 Dual H-Bridge
IN1–IN4 Direction Pins

Reverses coil current polarity with 1.5A per channel.

Step 4 🤖
Differential Steering
Left & Right Gear Motors

Left wheel reverse + right wheel forward spins rover free!

1

🧰 Real Rover Components

DRV8833 Driver
DRV8833 Driver Dual H-Bridge
2WD Chassis
2WD Chassis Robot Frame
2x BO Motors
2x BO Motors Left + Right
7.4V Battery
7.4V Battery Powers DRV8833
Final 2WD Rover
Final 2WD Rover Goal Build
2

🎛️ Live DRV8833 Steering Simulator & Pinout

Sonar Distance: 35 cm
2WD ROVER FORWARD ↑ ↑ ↑
AIN1:1 AIN2:0 | BIN1:1 BIN2:0
DRV8833 Motor Power (VM)
Red Wire to 4x AA Battery (+) Rail (4.8V – 6V)
Battery (+)
Common Ground (GND)
Black Wire connecting Battery (-) and ESP32 GND
Common GND
Left Motor IN1 (Forward)
Blue Jumper Wire to DRV8833 IN1
GPIO 4
Left Motor IN2 (Reverse)
Blue Jumper Wire to DRV8833 IN2
GPIO 5
Right Motor IN3 (Forward)
Orange Jumper Wire to DRV8833 IN3
GPIO 6
Right Motor IN4 (Reverse)
Orange Jumper Wire to DRV8833 IN4
GPIO 7
3

⚡ Verified Codes (Click "⚡ Open in IDE" — Auto Board + Code!)

step1_motor_test.ino ESP32-S3 47 lines
/*
 * Session 6 - Step 1: DRV8833 Dual Motor Direction Test
 * Wiring: Left Motor -> AIN1=GPIO 4, AIN2=GPIO 5 | Right Motor -> BIN1=GPIO 6, BIN2=GPIO 7
 */
#define AIN1 4
#define AIN2 5
#define BIN1 6
#define BIN2 7
Preview (8 of 47 lines) — Click ⚡ Open in IDE to auto-load code & board!
✅ Output: Tests Forward ➔ Reverse ➔ Left ➔ Right! Swap motor wires if a wheel spins backward.
step2_pwm_speed.ino ESP32-S3 37 lines
/*
 * Session 6 - Step 2: Smooth PWM Speed Control on DRV8833 (ESP32 Core 3.x)
 * Ramps both motors smoothly from 0% to 100% and back down!
 */
#define AIN1 4
#define AIN2 5
#define BIN1 6
#define BIN2 7
Preview (8 of 37 lines) — Click ⚡ Open in IDE to auto-load code & board!
✅ Output: Smoothly ramps both wheels from slow to full speed via ESP32 Core 3.x ledcAttach!
step3_obstacle_rover.ino ESP32-S3 67 lines
/*
 * Session 6 - Final Project: 2WD Autonomous Obstacle Avoidance Rover
 * DRV8833: AIN1=4, AIN2=5, BIN1=6, BIN2=7 | Sonar: TRIG=12, ECHO=13 | Radar Servo: 14
 */
#define AIN1 4
#define AIN2 5
#define BIN1 6
#define BIN2 7
Preview (8 of 67 lines) — Click ⚡ Open in IDE to auto-load code & board!
✅ Output: Drives forward, stops <24cm, looks Left & Right with servo, and turns to clear path!
📥 33 Sketches (.ZIP) ← Session 5: Live Radar Session 7: OLED Robot Eyes & HUD →