ESP32 C3 Super Mini - DRV8833 DC Motor Driver

The ESP32 C3 Super Mini is small, and so is the DRV8833 motor driver. Put them together and you get a motor controller that fits inside a matchbox-sized robot. This tutorial starts with one DC motor, then moves on to two motors, like the wheels of a small car.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - DRV8833 DC Motor Driver

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×DRV8833 Motor Driver Module
2×5V DC Motor
1×5V Power Adapter
1×DC Power Jack
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Part 1 needs only one DC motor. The second motor is for Part 2.

Overview of DRV8833 DC Motor Driver

A GPIO pin of the ESP32 C3 Super Mini gives only a few milliamps at 3.3V. A DC motor needs hundreds of milliamps. The DRV8833 sits in the middle: the board sends small control signals, and the driver switches the motor current from a separate power supply. Inside the chip there are two H-bridges, so one module can run two DC motors, and each motor can turn both ways.

Key Features:

  • Two motor channels: motor A on OUT1/OUT2, motor B on OUT3/OUT4
  • Motor supply (VCC pin): 2.7V to 10.8V
  • About 1.5A per channel continuous, 2A peak with good cooling
  • MOSFET outputs with low resistance (about 360 mΩ), so less heat and less voltage loss than the L298N
  • PWM speed control up to 50 kHz
  • Built-in protection: under-voltage lockout, over-current and thermal shutdown

Why DRV8833 is Great for the ESP32 C3 Super Mini:

  • No logic power pin. The chip makes its own logic voltage, so 3.3V control signals work directly
  • Small enough to sit next to the Super Mini on a mini breadboard
  • Runs well from 4 x AA batteries (about 6V) or a 5V adapter
  • It can also drive one small bipolar stepper motor, but this tutorial uses DC motors only

DRV8833 Module Pinout

DRV8833 Motor Driver Pinout

The common red or blue DRV8833 board has these pins:

  • IN1, IN2: control inputs for motor A. Connect them to two PWM pins of the ESP32 C3 Super Mini.
  • IN3, IN4: control inputs for motor B. Also two PWM pins.
  • OUT1, OUT2: outputs to the two wires of motor A.
  • OUT3, OUT4: outputs to the two wires of motor B.
  • VCC: motor power, 2.7V to 10.8V, from the external supply (not from the board).
  • GND: ground. It must be shared by the supply, the driver and the ESP32 C3 Super Mini.
  • EEP: the sleep pin (nSLEEP). HIGH = driver on, LOW = driver asleep. In this tutorial it goes to 3.3V.
  • ULT: the fault output (nFAULT). It goes LOW on over-current or overheating. You can leave it unconnected.

※ NOTE THAT:

Pin labels vary between makers. Some modules print AIN1, AIN2, BIN1, BIN2, AOUT1, AOUT2, BOUT1, BOUT2, SLP and FLT instead. The job of each pin is the same.

How the IN Pins Control a Motor

The DRV8833 has no ENA or ENB speed pin like the L298N. Each motor uses only its two IN pins. Their logic levels set what the motor does:

IN1 (or IN3) IN2 (or IN4) Motor action
LOW LOW Coast - power off, the motor rolls to a stop
PWM / HIGH LOW Forward - the PWM duty sets the speed
LOW PWM / HIGH Reverse - the PWM duty sets the speed
HIGH HIGH Brake - the motor stops fast

So for speed control, PWM goes on one IN pin while the other stays LOW. This means both IN pins of a motor must be PWM-capable. On the ESP32 C3 Super Mini almost every GPIO can make PWM, so this is easy.

Part 1: Control One DC Motor

Wiring Diagram - One Motor

The wiring diagram between ESP32 C3 Super Mini DRV8833 one DC motor

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Connect To
IN1 ESP32 C3 Super Mini GPIO4
IN2 ESP32 C3 Super Mini GPIO3
EEP ESP32 C3 Super Mini 3.3V
GND ESP32 C3 Super Mini GND and power supply (-)
VCC 5V power supply (+)
OUT1 Motor wire 1
OUT2 Motor wire 2
  • Note: Power the motor from the 5V adapter through the DC power jack. Never take motor power from the 5V or 3.3V pin of the ESP32 C3 Super Mini.
  • Note: Connect all grounds together: adapter (-), DRV8833 GND and ESP32 C3 Super Mini GND. Without a common ground, the motor does not respond.
  • Note: GPIO4 and GPIO3 are free, PWM-capable pins. Avoid GPIO2, GPIO8 and GPIO9 (boot pins), GPIO18/GPIO19 (USB) and GPIO20/GPIO21 (serial).
  • Note: If the motor turns the wrong way, swap the two motor wires on OUT1 and OUT2.

ESP32 C3 Super Mini Code - One Motor

This sketch runs one motor through every state of the truth table above.

What the code does:

  • Sets GPIO4 and GPIO3 as the IN1 and IN2 outputs
  • Ramps the motor up from stop to full speed in the forward direction
  • Holds full speed for 2 seconds
  • Lets the motor coast to a stop
  • Runs the motor in reverse at about 70% speed
  • Brakes the motor and repeats
  • Prints each state to the Serial Monitor
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-drv8833-dc-motor-driver */ /* * ESP32 C3 Super Mini - DRV8833 DC Motor Driver (one motor) * * The motor is wired to channel A of the DRV8833 (OUT1 / OUT2). * The DRV8833 has no "enable" pin for speed. Instead, we send PWM * straight into IN1 or IN2: * IN1 = PWM, IN2 = LOW -> motor spins forward at that speed * IN1 = LOW, IN2 = PWM -> motor spins in reverse at that speed * IN1 = LOW, IN2 = LOW -> coast (the motor rolls freely to a stop) * IN1 = HIGH, IN2 = HIGH -> brake (the motor stops quickly) */ #define IN1_PIN 4 // ESP32 C3 Super Mini GPIO4 -> DRV8833 IN1 (motor A control 1) #define IN2_PIN 3 // ESP32 C3 Super Mini GPIO3 -> DRV8833 IN2 (motor A control 2) // The DRV8833 EEP (sleep) pin is tied to 3.3V, so the driver is always awake. void setup() { Serial.begin(115200); // start the Serial Monitor at 115200 baud pinMode(IN1_PIN, OUTPUT); // IN1 is an output pin pinMode(IN2_PIN, OUTPUT); // IN2 is an output pin // We only use analogWrite() on these pins (never digitalWrite()). // Once a pin makes PWM on the ESP32, analogWrite() is the safe way to keep using it. analogWrite(IN1_PIN, 0); // IN1 LOW analogWrite(IN2_PIN, 0); // IN2 LOW -> motor starts in coast (stopped) Serial.println("DRV8833 one motor test is ready"); } void loop() { // 1) Speed up forward, little by little Serial.println("Forward: speeding up"); for (int speed = 0; speed <= 255; speed += 5) { // 0 = stopped, 255 = full speed analogWrite(IN2_PIN, 0); // keep IN2 LOW so the motor turns forward analogWrite(IN1_PIN, speed); // PWM on IN1 sets the speed delay(40); // short wait, so the full ramp takes about 2 seconds } // 2) Hold full speed for a moment Serial.println("Forward: full speed"); delay(2000); // 3) Coast: both inputs LOW, the motor slows down by itself Serial.println("Coast (free stop)"); analogWrite(IN1_PIN, 0); // IN1 LOW analogWrite(IN2_PIN, 0); // IN2 LOW delay(2000); // give the motor time to roll to a stop // 4) Reverse at about 70% speed Serial.println("Reverse: 70% speed"); analogWrite(IN1_PIN, 0); // IN1 LOW so the motor turns in reverse analogWrite(IN2_PIN, 180); // PWM on IN2 sets the reverse speed (180 of 255 is about 70%) delay(3000); // 5) Brake: both inputs HIGH, the motor stops at once Serial.println("Brake (fast stop)"); analogWrite(IN1_PIN, 255); // IN1 HIGH (255 = always on) analogWrite(IN2_PIN, 255); // IN2 HIGH delay(2000); Serial.println("----- repeat -----"); }

Detailed Instructions

  • New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Super Mini tutorial first to set up your development environment.
  • Wire the parts: Follow the one-motor wiring diagram. Leave the 5V adapter unplugged for now.
  • Connect USB cable: Plug the ESP32 C3 Super Mini into your computer with a USB Type-C cable.
  • Open Arduino IDE: Select the ESP32 C3 Super Mini board and its COM port.
  • Copy the code: Paste the code above into a new sketch. No extra library is needed, analogWrite() is built in.
  • Upload the code: Click the Upload button.
How to upload ESP32 C3 Super Mini code on Arduino IDE
  • Power the motor: Now plug in the 5V adapter.
  • Open Serial Monitor: Set the baud rate to 115200.
  • Watch the motor: It speeds up, runs, coasts, turns backward, then brakes.
  • Pro Tip: Listen to the stop. A coast stop is slow and soft. A brake stop is short and sharp. That is the difference between LOW/LOW and HIGH/HIGH.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
DRV8833 one motor test is ready Forward: speeding up Forward: full speed Coast (free stop) Reverse: 70% speed Brake (fast stop) ----- repeat ----- Forward: speeding up Forward: full speed
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Line-by-line Code Explanation

The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!

Part 2: Control Two DC Motors

With the second channel, the same module can drive the left and right wheels of a small robot car. Motor A is the left wheel and motor B is the right wheel.

Wiring Diagram - Two Motors

The wiring diagram between ESP32 C3 Super Mini DRV8833 two DC motors

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Connect To
IN1 ESP32 C3 Super Mini GPIO4
IN2 ESP32 C3 Super Mini GPIO3
IN3 ESP32 C3 Super Mini GPIO1
IN4 ESP32 C3 Super Mini GPIO0
EEP ESP32 C3 Super Mini 3.3V
GND ESP32 C3 Super Mini GND and power supply (-)
VCC 5V power supply (+)
OUT1, OUT2 Motor A (left wheel)
OUT3, OUT4 Motor B (right wheel)
  • Note: Two motors pull about twice the current. A 5V 2A adapter or a 4 x AA battery pack is a good choice.
  • Note: For a battery robot, keep the battery voltage below 10.8V. A 2S Li-ion pack (up to 8.4V) is fine, a 3S pack is too high.
  • Note: GPIO1 and GPIO0 are also free, PWM-capable pins, so the four IN pins stay away from the boot pins (GPIO2, GPIO8, GPIO9) and the USB pins (GPIO18, GPIO19).

ESP32 C3 Super Mini Code - Two Motors

This sketch uses a helper function for each motor. You give it a signed speed: a positive number turns the wheel forward, a negative number turns it backward, and 0 stops it.

What the code does:

  • Sets GPIO4, GPIO3, GPIO1 and GPIO0 as the IN1 to IN4 outputs
  • Creates motorA(speed) and motorB(speed) with a speed from -255 to 255
  • Drives the car forward, stops, then drives backward
  • Turns left by running the left wheel back and the right wheel forward
  • Turns right by doing the opposite
  • Prints every action and both speed values to the Serial Monitor
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-drv8833-dc-motor-driver */ /* * ESP32 C3 Super Mini - DRV8833 DC Motor Driver (two motors) * * A tiny two-wheel robot car test: * motor A (left wheel) -> DRV8833 OUT1 / OUT2, controlled by IN1 / IN2 * motor B (right wheel) -> DRV8833 OUT3 / OUT4, controlled by IN3 / IN4 * * Each motor gets one helper function with a signed speed: * +1 to +255 -> forward, -1 to -255 -> reverse, 0 -> stop (coast) */ #define IN1_PIN 4 // GPIO4 -> DRV8833 IN1 (motor A) #define IN2_PIN 3 // GPIO3 -> DRV8833 IN2 (motor A) #define IN3_PIN 1 // GPIO1 -> DRV8833 IN3 (motor B) #define IN4_PIN 0 // GPIO0 -> DRV8833 IN4 (motor B) // The DRV8833 EEP (sleep) pin is tied to 3.3V, so the driver is always awake. #define DRIVE_SPEED 200 // speed used for driving straight (0 to 255) #define TURN_SPEED 160 // a bit slower for turning, so the car does not spin too fast // Drive one DRV8833 channel with a signed speed (-255 to 255). // pinA / pinB are the two IN pins of that channel. void driveChannel(int pinA, int pinB, int speed) { speed = constrain(speed, -255, 255); // keep the value inside the PWM range if (speed > 0) { // forward: PWM on the first pin, second pin LOW analogWrite(pinB, 0); analogWrite(pinA, speed); } else if (speed < 0) { // reverse: first pin LOW, PWM on the second pin analogWrite(pinA, 0); analogWrite(pinB, -speed); // make the number positive for analogWrite() } else { // zero: both pins LOW = coast analogWrite(pinA, 0); analogWrite(pinB, 0); } } void motorA(int speed) { driveChannel(IN1_PIN, IN2_PIN, speed); } // left wheel void motorB(int speed) { driveChannel(IN3_PIN, IN4_PIN, speed); } // right wheel // Small helper: print the action, set both motors, then wait void doAction(const char* name, int speedA, int speedB, int ms) { Serial.print(name); Serial.print(" (A: "); Serial.print(speedA); Serial.print(", B: "); Serial.print(speedB); Serial.println(")"); motorA(speedA); // set the left wheel motorB(speedB); // set the right wheel delay(ms); // keep doing this for "ms" milliseconds } void setup() { Serial.begin(115200); // start the Serial Monitor at 115200 baud pinMode(IN1_PIN, OUTPUT); // all four IN pins are outputs pinMode(IN2_PIN, OUTPUT); pinMode(IN3_PIN, OUTPUT); pinMode(IN4_PIN, OUTPUT); motorA(0); // both motors start stopped motorB(0); Serial.println("DRV8833 two motors (robot car) test is ready"); } void loop() { doAction("Forward", DRIVE_SPEED, DRIVE_SPEED, 2000); // both wheels forward doAction("Stop", 0, 0, 1000); // short pause doAction("Backward", -DRIVE_SPEED, -DRIVE_SPEED, 2000); // both wheels in reverse doAction("Stop", 0, 0, 1000); doAction("Turn left", -TURN_SPEED, TURN_SPEED, 1000); // left wheel back, right wheel forward doAction("Turn right", TURN_SPEED, -TURN_SPEED, 1000); // left wheel forward, right wheel back doAction("Stop", 0, 0, 2000); // rest before the next round }

Detailed Instructions

  • Wire the second motor: Add motor B and the IN3/IN4 wires as in the two-motor diagram.
  • Lift the wheels: If the motors are already on a car, put it on a box so it cannot drive off the desk.
  • Upload the code: Paste the two-motor code into Arduino IDE and upload it.
  • Power the motors: Plug in the 5V adapter or the battery pack.
  • Open Serial Monitor: 115200 baud.
  • Check each move: Make sure "Forward" turns both wheels forward. If one wheel turns backward, swap the two wires of that motor.
  • Pro Tip: Two motors of the same type often run at slightly different speeds. If the car drifts to one side, lower the speed of the faster wheel by 5 to 15 points.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
DRV8833 two motors (robot car) test is ready Forward (A: 200, B: 200) Stop (A: 0, B: 0) Backward (A: -200, B: -200) Stop (A: 0, B: 0) Turn left (A: -160, B: 160) Turn right (A: 160, B: -160) Stop (A: 0, B: 0) Forward (A: 200, B: 200)
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Line-by-line Code Explanation

The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!

Applications and Project Ideas

The ESP32 C3 Super Mini and DRV8833 make a light, low-power motor pair. Try them in:

  • A palm-sized two-wheel robot car powered by 4 x AA batteries
  • A WiFi or Bluetooth remote-controlled car, using the built-in radio of the C3
  • A small fan with a speed you can set from your phone
  • A tiny conveyor belt that moves parts in a craft project
  • A motorized window blind or curtain puller with a low-voltage gear motor
  • A line-following robot with two IR sensors

Video Tutorial

Watch the video below for a visual walkthrough of this project.

Challenge Yourself

Try these ideas to go further with the DRV8833 and ESP32 C3 Super Mini:

  • Easy: Change the reverse speed in the one-motor code from 180 to 120 and see how slow the motor can go before it stalls
  • Easy: Add a "Spin in place" action to the two-motor code: both wheels at full speed in opposite directions
  • Medium: Read a potentiometer and use its value to set the motor speed
  • Medium: Connect the ULT (fault) pin to a GPIO with a pull-up and print a warning when it goes LOW
  • Advanced: Control the car with keys sent from the Serial Monitor (W, A, S, D and space to stop)
  • Advanced: Drive EEP from a GPIO and put the driver to sleep when the car is idle to save battery

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!