Episode #3 · DRV8833

The Tiny Chip That Drives Your Wheels

Your microcontroller can't power a motor. The DRV8833 is the $1 H-bridge that sits between the brain and the muscle — direction and speed for two motors.

Episode video — paste your YouTube ID to embed

What it is

A small breakout with the DRV8833 chip — a dual motor driver, so one board runs two DC motors (perfect for a two-wheel bot). Inside is an H-bridge: a switch arrangement that can flip the current direction so a motor goes forward and backward, and chop the power thousands of times a second so you control speed.

The bare minimum to use it

  • Two sides: one for power + motors, one for control signals from the ESP32.
  • Four control pins: AIN1/AIN2 (motor A), BIN1/BIN2 (motor B). One high + one low spins a direction; flip to reverse; both low = stop.
  • Motor power is a battery into the driver's input — not the ESP32.
  • PWM the control pins for speed instead of just on/off.
The mistake everyone makes once: forgetting the common ground. Battery GND, driver GND, and ESP32 GND must all connect — or the motors do random nonsense.

Wiring

Battery (+) ──▶ DRV8833 VM        Motor A ──▶ AOUT1 / AOUT2
Battery (−) ──┬─▶ DRV8833 GND     Motor B ──▶ BOUT1 / BOUT2
              └─▶ ESP32 GND        (COMMON GROUND)

ESP32 GPIO 5 ─▶ AIN1   GPIO 6 ─▶ AIN2   (left motor)
ESP32 GPIO 7 ─▶ BIN1   GPIO 10 ─▶ BIN2  (right motor)
ESP32-C3 SuperMini miniRobo pin map: servos on GPIO 3 and 4, motors on GPIO 5, 6, 7 and 10, onboard LED on GPIO 8

C3 SuperMini pin map — the motor control pins are GPIO 5, 6, 7 and 10.

The code

Drives two motors forward, reverse, and turn using PWM speed control. Full sketch in the sidebar.

// miniRobo EP3 — DRV8833 two-motor drive (ESP32)
const int AIN1=5, AIN2=6, BIN1=7, BIN2=10;

void motor(int in1, int in2, int spd) {   // spd: -255..255
  if (spd >= 0) { analogWrite(in1, spd);  analogWrite(in2, 0); }
  else          { analogWrite(in1, 0);    analogWrite(in2, -spd); }
}
void drive(int l, int r){ motor(AIN1,AIN2,l); motor(BIN1,BIN2,r); }

void setup() {
  int pins[]={AIN1,AIN2,BIN1,BIN2};
  for (int p: pins) pinMode(p, OUTPUT);
}
void loop() {
  drive(200, 200); delay(1000);   // forward
  drive(-200,-200); delay(1000);  // reverse
  drive(200,-200); delay(700);    // spin
  drive(0, 0);     delay(1000);   // stop
}

What I wish I knew

  • Tie the grounds together. One wire fixes a world of weird behavior.
  • Check the current. The DRV8833 is for small motors; big hungry ones need a bigger driver.
  • Motors are noisy. A small ceramic cap across the terminals stops resets and glitches.
  • Wheel spins backward? Swap the two motor wires (or flip the pin in code).
  • Brownout on startup? Healthy battery, and ideally a clean separate feed to the ESP32.