ESP32 S3 - DRV8833 DC Motor Driver

The DRV8833 is a tiny dual H-bridge that lets the ESP32 S3 spin small DC motors forward, backward, fast or slow, straight from its 3.3V GPIO pins. In this project you start with a single motor, then add a second one and turn the pair into the drive system of a small robot car.

What you'll build in this tutorial:

  1. An understanding of what the DRV8833 does and how its four input pins set direction and speed
  2. A single-motor circuit that ramps up, coasts, reverses and brakes on command
  3. A two-motor circuit that drives forward, backward, and turns left and right
  4. Serial Monitor messages that tell you which action is running at every moment
ESP32 S3 - DRV8833 DC Motor Driver

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×Alternatively, ESP32 S3 SuperMini Dev Module
1×Alternatively, ESP32 S3 Uno-form Board
1×Alternatively, ESP32 S3 Camera Board
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
1×5V DC Motor (2 for Part 2)
1×5V Power Adapter
1×DC Power Jack
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
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 .

Overview of DRV8833 Motor Driver

A GPIO pin of the ESP32 S3 can only give a few milliamps, but a hobby DC motor wants hundreds. The DRV8833 from Texas Instruments sits in the middle: the ESP32 S3 sends it small logic signals, and the chip switches the motor current from a separate battery or adapter. It has two independent channels, so one module runs two brushed DC motors (or, if you need it later, one bipolar stepper motor). Inside, it uses MOSFET switches with very low resistance, so it wastes much less voltage and makes much less heat than an older L298N. That is a big plus for robots that run on 3 to 9V batteries.

Key Specifications

The motor supply (the VCC pin on the module) accepts 2.7V to 10.8V. There is no separate logic supply pin — the chip makes its own internal logic voltage, so the 3.3V signals from the ESP32 S3 work without a level shifter. Each channel can deliver about 1.5A continuously and 2A peak with good cooling, and the two channels can be joined for about 3A if one bigger motor needs it. PWM frequencies up to 50kHz are supported. Built-in protection covers under-voltage, over-current and over-temperature, and the fault pin goes LOW when any of them trips.

Feature Value
Motor channels 2 (A and B)
Motor supply voltage (VCC) 2.7V to 10.8V
Logic level 3.3V or 5V (no logic supply pin needed)
Current per channel about 1.5A RMS, 2A peak
Max PWM frequency 50kHz
Protection Under-voltage, over-current, thermal shutdown

DRV8833 Pinout

The common red or blue DRV8833 breakout board has the pins below. Labels vary between makers — some boards print AIN1/AIN2/BIN1/BIN2, AOUT1/AOUT2/BOUT1/BOUT2, SLP and FLT instead — but the jobs are the same.

DRV8833 motor driver pinout
  1. VCC — motor power input, 2.7V to 10.8V from an external supply
  2. GND — ground; must be shared with the ESP32 S3 and the motor supply
  3. IN1 / IN2 — control inputs for motor A, driven by two ESP32 S3 GPIO pins
  4. IN3 / IN4 — control inputs for motor B, driven by two more GPIO pins
  5. OUT1 / OUT2 — outputs to the two wires of motor A
  6. OUT3 / OUT4 — outputs to the two wires of motor B
  7. EEP (nSLEEP) — enable pin; HIGH turns the driver on, LOW puts it to sleep. Tie it to the ESP32 S3 3.3V pin
  8. ULT (nFAULT) — open-drain fault output, LOW on a fault; optional, you can leave it unconnected

How the Inputs Control a Motor

Unlike the L298N, the DRV8833 has no ENA/ENB speed pin. Each channel is controlled only by its two input pins, as shown in this truth table (motor A shown; motor B works the same with IN3/IN4):

IN1 IN2 Motor A
LOW LOW Coast (motor free-runs to a stop)
HIGH LOW Forward
LOW HIGH Reverse
HIGH HIGH Brake (fast stop)

To change speed, the ESP32 S3 sends a PWM signal to one input and holds the other one LOW: PWM on IN1 for forward, PWM on IN2 for reverse. A duty value of 255 is full speed, and smaller values run the motor slower. Because either input may carry PWM, both pins of a channel must be PWM-capable. On the ESP32 S3 this is easy: almost every GPIO can output PWM through analogWrite().

PART 1: Control One DC Motor

Wiring Diagram between DRV8833 and ESP32 S3 - One Motor

Motor A is connected to OUT1 and OUT2, and its two control inputs come from GPIO11 (IN1) and GPIO10 (IN2) of the ESP32 S3. These are free general-purpose pins that support PWM and are not strapping pins. The motor gets its power from a 5V adapter through a DC power jack, and the EEP pin is pulled HIGH by the board's 3.3V pin so the driver stays awake.

Safety Notes

Never feed the motor from the 3.3V or 5V pin of the ESP32 S3; a motor can pull a large current spike at start-up and cause the board to reset or get damaged, so always use a separate supply on the VCC pin of the module. Connect the ground of the adapter, the DRV8833 and the ESP32 S3 together, otherwise the control signals have no common reference and the motor will behave strangely. Keep the supply below 10.8V, and unplug the adapter before you change any wire.

The wiring diagram between ESP32 S3 DRV8833 one DC motor

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Connect To
IN1 ESP32 S3 GPIO11
IN2 ESP32 S3 GPIO10
EEP ESP32 S3 3.3V
GND ESP32 S3 GND and power supply (-)
VCC 5V power supply (+)
OUT1 DC motor wire 1
OUT2 DC motor wire 2

ESP32 S3 Code - One DC Motor

The sketch wraps the truth table into one helper, motorA(speed), which takes a signed number from -255 to 255: positive values spin the motor forward, negative values spin it in reverse, and 0 lets it coast. A second helper, motorABrake(), sets both inputs HIGH for a quick stop. The main loop ramps the motor up step by step, holds full speed, coasts, runs in reverse at about 70% and finally brakes, printing each stage to the Serial Monitor.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-drv8833-dc-motor-driver */ // ESP32 S3 pins wired to the DRV8833 inputs of channel A (motor A) // Any ESP32 S3 GPIO can output PWM, so both pins can control speed. #define PIN_AIN1 11 // ESP32 S3 GPIO11 connected to IN1 of the DRV8833 module #define PIN_AIN2 10 // ESP32 S3 GPIO10 connected to IN2 of the DRV8833 module // Set the motor speed and direction. // speed: -255 (full reverse) ... 0 (coast) ... 255 (full forward) // We only use analogWrite() on these pins. 0 means LOW and 255 means HIGH. void motorA(int speed) { speed = constrain(speed, -255, 255); if (speed > 0) { // forward: PWM on IN1, IN2 stays LOW analogWrite(PIN_AIN1, speed); analogWrite(PIN_AIN2, 0); } else if (speed < 0) { // reverse: IN1 stays LOW, PWM on IN2 analogWrite(PIN_AIN1, 0); analogWrite(PIN_AIN2, -speed); } else { // coast: both inputs LOW, motor spins down freely analogWrite(PIN_AIN1, 0); analogWrite(PIN_AIN2, 0); } } // Brake: both inputs HIGH, the driver shorts the motor and it stops fast void motorABrake() { analogWrite(PIN_AIN1, 255); analogWrite(PIN_AIN2, 255); } void setup() { Serial.begin(115200); pinMode(PIN_AIN1, OUTPUT); pinMode(PIN_AIN2, OUTPUT); motorA(0); // start with the motor stopped Serial.println("DRV8833 one-motor test started"); } void loop() { // 1. Forward: ramp the speed up slowly from 0 to full Serial.println("Forward: speeding up"); for (int speed = 0; speed <= 255; speed += 5) { motorA(speed); delay(40); } // 2. Hold full speed for 2 seconds Serial.println("Forward: full speed"); delay(2000); // 3. Coast: let the motor slow down by itself Serial.println("Coast: motor free-runs to a stop"); motorA(0); delay(2000); // 4. Reverse at about 70% speed Serial.println("Reverse: 70% speed"); motorA(-180); delay(2000); // 5. Brake: stop quickly Serial.println("Brake: fast stop"); motorABrake(); delay(1000); motorA(0); // release the brake (coast) before the next cycle Serial.println("----- cycle done -----"); delay(1000); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Build the circuit: Wire the DRV8833, the motor and the 5V adapter as shown in the one-motor diagram. Leave the adapter unplugged for now.
  3. Connect the board: Plug the ESP32 S3 into your PC with the USB Type-C cable.
  4. Prepare Arduino IDE: Open Arduino IDE, then pick the ESP32 S3 board and its COM port.
  5. Load the sketch: Copy the code above into a new sketch. No extra library is needed.
  6. Upload: Click the Upload button.
  7. Power the motor: Plug in the 5V adapter.
  8. Watch it run: The motor speeds up, holds, coasts, spins in reverse, then brakes.
  9. Check the messages: Open the Serial Monitor at 115200 baud.
  10. Pro Tip: If the motor turns the "wrong" way, you don't need to change the code — just swap the two motor wires on OUT1 and OUT2.

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
DRV8833 one-motor test started Forward: speeding up Forward: full speed Coast: motor free-runs to a stop Reverse: 70% speed Brake: fast stop ----- cycle done ----- Forward: speeding up Forward: full speed
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

PART 2: Control Two DC Motors

Wiring Diagram between DRV8833 and ESP32 S3 - Two Motors

The second motor goes on OUT3 and OUT4, and its inputs IN3 and IN4 come from GPIO18 and GPIO17. Everything else stays the same as in Part 1, so you only need to add four wires.

Safety Notes

Two motors starting at the same time can draw a lot of current, so choose an adapter or battery pack that can supply at least 1A, and keep it within the 2.7V to 10.8V range. Keep the shared ground in place, and if the DRV8833 chip gets hot to the touch during long runs, give it a short rest or add a small heatsink.

The wiring diagram between ESP32 S3 DRV8833 two DC motors

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Connect To
IN1 ESP32 S3 GPIO11
IN2 ESP32 S3 GPIO10
IN3 ESP32 S3 GPIO18
IN4 ESP32 S3 GPIO17
EEP ESP32 S3 3.3V
GND ESP32 S3 GND and power supply (-)
VCC 5V power supply (+)
OUT1, OUT2 Left DC motor (motor A)
OUT3, OUT4 Right DC motor (motor B)

ESP32 S3 Code - Two DC Motors

This time, think of the two motors as the left and right wheels of a robot car. A shared function, setChannel(), drives one channel from a signed speed, and the small helpers forward(), backward(), turnLeft(), turnRight() and stopAll() combine both channels into car moves. To turn left, the left wheel runs backward while the right wheel runs forward, so the car spins in place.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-drv8833-dc-motor-driver */ // ESP32 S3 pins wired to the DRV8833 module // Motor A = left wheel, Motor B = right wheel (like a small robot car) #define PIN_AIN1 11 // ESP32 S3 GPIO11 connected to IN1 (motor A) #define PIN_AIN2 10 // ESP32 S3 GPIO10 connected to IN2 (motor A) #define PIN_BIN1 18 // ESP32 S3 GPIO18 connected to IN3 (motor B) #define PIN_BIN2 17 // ESP32 S3 GPIO17 connected to IN4 (motor B) #define DRIVE_SPEED 200 // 0..255, speed used for driving #define TURN_SPEED 160 // 0..255, speed used for turning // Drive one channel of the DRV8833. // speed: -255 (full reverse) ... 0 (coast) ... 255 (full forward) void setChannel(int pin1, int pin2, int speed) { speed = constrain(speed, -255, 255); if (speed >= 0) { analogWrite(pin1, speed); // forward: PWM on pin1 analogWrite(pin2, 0); // pin2 LOW } else { analogWrite(pin1, 0); // pin1 LOW analogWrite(pin2, -speed); // reverse: PWM on pin2 } } void motorA(int speed) { setChannel(PIN_AIN1, PIN_AIN2, speed); } void motorB(int speed) { setChannel(PIN_BIN1, PIN_BIN2, speed); } // Robot car actions built from the two motors void forward() { motorA(DRIVE_SPEED); motorB(DRIVE_SPEED); } void backward() { motorA(-DRIVE_SPEED); motorB(-DRIVE_SPEED); } void turnLeft() { motorA(-TURN_SPEED); motorB(TURN_SPEED); } // left wheel back, right wheel forward void turnRight() { motorA(TURN_SPEED); motorB(-TURN_SPEED); } // left wheel forward, right wheel back void stopAll() { motorA(0); motorB(0); } // both channels coast void setup() { Serial.begin(115200); pinMode(PIN_AIN1, OUTPUT); pinMode(PIN_AIN2, OUTPUT); pinMode(PIN_BIN1, OUTPUT); pinMode(PIN_BIN2, OUTPUT); stopAll(); Serial.println("DRV8833 two-motor test started"); } void loop() { Serial.println("Action: FORWARD"); forward(); delay(2000); Serial.println("Action: STOP"); stopAll(); delay(800); Serial.println("Action: BACKWARD"); backward(); delay(2000); Serial.println("Action: STOP"); stopAll(); delay(800); Serial.println("Action: TURN LEFT"); turnLeft(); delay(1200); Serial.println("Action: TURN RIGHT"); turnRight(); delay(1200); Serial.println("Action: STOP"); stopAll(); delay(2000); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Add the second motor: Extend the Part 1 circuit by following the two-motor diagram.
  3. Open the new sketch: Paste the two-motor code into Arduino IDE.
  4. Upload: Make sure the ESP32 S3 board and COM port are selected, then click Upload.
  5. Power on: Plug in the motor supply.
  6. Observe the pattern: Both motors go forward, stop, go backward, stop, then spin in opposite directions to turn left and right.
  7. Follow along: Open the Serial Monitor at 115200 baud to see each action name.
  8. Pro Tip: If the car turns right when it should turn left, one motor is wired in reverse — swap that motor's two wires instead of editing the code.

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
DRV8833 two-motor test started Action: FORWARD Action: STOP Action: BACKWARD Action: STOP Action: TURN LEFT Action: TURN RIGHT Action: STOP Action: FORWARD
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

With two motor channels and support for low-voltage batteries, the DRV8833 and ESP32 S3 are a natural base for small moving projects.

  1. WiFi robot car: Host a web page on the ESP32 S3 with arrow buttons that call the forward, backward and turn functions.
  2. Line-following robot: Add two IR sensors and steer by slowing one wheel when the line drifts to one side.
  3. Mini conveyor belt: Move small parts at an adjustable speed and reverse it with a button.
  4. Motorized blinds: Roll a blind up or down at a slow, quiet speed using one channel.
  5. Desk fan with speed levels: Set the fan speed from a potentiometer or a touch sensor.
  6. Camera pan base: Rotate a phone or camera slowly for smooth panorama shots.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenge Yourself

After both motors run well, try these ideas to grow your skills step by step.

  1. Beginner: Change DRIVE_SPEED and TURN_SPEED and see how slow the motors can go before they stall.
  2. Beginner: Add a brakeAll() helper that sets all four inputs HIGH and compare its stop with the coast stop.
  3. Intermediate: Connect the ULT (nFAULT) pin to a GPIO with INPUT_PULLUP and print a warning when it goes LOW.
  4. Intermediate: Use a joystick module to drive the two motors like a remote-controlled car.
  5. Advanced: Add an ultrasonic sensor so the car backs up and turns when an obstacle is closer than 20 cm.
  6. Advanced: Build a web interface on the ESP32 S3 with a speed slider and direction buttons for both motors.

※ 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!