ESP8266 - DRV8833 DC Motor Driver
This tutorial instructs you how to use ESP8266 together with the small DRV8833 driver to spin DC motors forward and backward at any speed. In detail, we will learn:
- What the DRV8833 module is and what each of its pins does
- How to connect ESP8266 NodeMCU to the DRV8833 and one DC motor
- How to program ESP8266 to change the speed, direction, coast and brake of that motor
- How to extend the same setup to two DC motors, like the two wheels of a robot car
We suggest:
- Reading the ESP8266 - DC Motor tutorial if you want the L298N version or a basic explanation of how a DC motor works.
- Using the DRV8833 if your project runs from batteries between 3V and 9V, since it wastes far less power than the L298N.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of DRV8833 Motor Driver
The DRV8833 is a tiny dual H-bridge chip made by Texas Instruments. One module can run two brushed DC motors on their own (it can also run one bipolar stepper motor, but that is not covered here). Its outputs are MOSFETs with a low on-resistance of about 360 mΩ, so the motor gets almost all of the supply voltage and the chip stays cool. This is a big step up from the old L298N, which loses around 2V inside itself.
Key facts:
| DRV8833 | |
|---|---|
| Motor supply (VCC pin) | 2.7V to 10.8V |
| Output current | about 1.5A RMS per channel, 2A peak (with good cooling) |
| Number of motors | 2 DC motors (or 1 bipolar stepper) |
| Logic input level | 3.3V or 5V (no separate logic supply needed) |
| PWM frequency | up to 50 kHz |
| Protection | under-voltage lockout, over-current, thermal shutdown |
The chip makes its own internal logic voltage from the motor supply. Because of this, the 3.3V signals of the ESP8266 can drive it directly, with no level shifter. If you need more current for one big motor, the two channels can be wired in parallel for about 3A, but this is optional.
The DRV8833 Motor Driver Pinout

The common red or blue DRV8833 breakout board has 12 pins:
- VCC pin: must be connected to the motor power supply (2.7V to 10.8V). This is NOT the ESP8266 3.3V pin.
- GND pin: must be connected to the ground of the motor supply AND to the GND of the ESP8266
- IN1, IN2 pins: control inputs for motor A, must be connected to two PWM pins of the ESP8266
- IN3, IN4 pins: control inputs for motor B, must be connected to two other PWM pins
- OUT1, OUT2 pins: outputs to motor A
- OUT3, OUT4 pins: outputs to motor B
- EEP pin: the sleep pin (nSLEEP). It must be HIGH to turn the driver on. Connect it to 3.3V of the ESP8266. If it is LOW, the chip sleeps and the motors do not move.
- ULT pin: the fault pin (nFAULT). It goes LOW when the chip detects a problem (over-current, overheating, low voltage). It is optional and can be left unconnected.
※ NOTE THAT:
The pin labels change from one maker to another. Some boards print AIN1/AIN2/BIN1/BIN2, AOUT1/AOUT2/BOUT1/BOUT2, SLP and FLT instead of the names above. The job of each pin is the same. Always follow the labels printed on your own module.
How the DRV8833 Controls a Motor
Unlike the L298N, the DRV8833 has no ENA/ENB speed pin. Each motor is controlled only by its two input pins. The table below is for motor A (IN1, IN2). Motor B works the same way with IN3 and IN4.
| IN1 | IN2 | Motor A |
|---|---|---|
| LOW | LOW | Coast (motor is released and free-runs to a stop) |
| HIGH | LOW | Spins forward |
| LOW | HIGH | Spins in reverse |
| HIGH | HIGH | Brake (motor stops quickly) |
To control the speed, we send a PWM signal to one input and keep the other one LOW:
- Forward with speed: PWM on IN1, IN2 = LOW
- Reverse with speed: IN1 = LOW, PWM on IN2
Because of this, both input pins of each channel must be PWM-capable pins of the ESP8266.
Choosing the ESP8266 Pins
Almost every NodeMCU GPIO can output PWM with analogWrite(), but some pins are a bad choice for a motor driver:
- D0 (GPIO16) cannot output PWM.
- D3 (GPIO0), D4 (GPIO2) and D8 (GPIO15) are boot-mode pins. A device pulling them the wrong way at power-up can stop the ESP8266 from booting.
So in this tutorial we use D5 and D6 for motor A. For motor B we use D1 and D2. D1 and D2 are the default I2C pins, but they are free here because no I2C device is connected. If you add an I2C module later, move motor B to D7 and another free pin.
About the PWM range: since ESP8266 Arduino core 3.0, analogWrite() takes a value from 0 to 255 by default. The older core 2.x used 0 to 1023. The code below calls analogWriteRange(255) in setup(), so 255 always means full speed, no matter which core version you have installed.
How To Program For DRV8833
- The first step is to define the ESP8266 pins that are connected to IN1 and IN2:
- Set both pins as outputs and fix the PWM range to 0 - 255:
- Spin forward at a given speed (0 to 255):
- Spin in reverse at a given speed:
- Coast (let the motor roll to a stop):
- Brake (stop quickly):
Part 1 - ESP8266 Controls One DC Motor via DRV8833
Wiring Diagram
The motor is powered by an external 5V adapter through the DC power jack. The ESP8266 only sends the control signals.

This image is created using Fritzing. Click to enlarge image
| DRV8833 Module | ESP8266 NodeMCU / Other |
|---|---|
| IN1 | D5 |
| IN2 | D6 |
| EEP | 3.3V |
| GND | GND (ESP8266) and negative (-) of the 5V supply |
| VCC | positive (+) of the 5V supply |
| OUT1, OUT2 | the two wires of the DC motor |
| ULT | not connected |
※ NOTE THAT:
- Never power the motor from the 3.3V or VIN pin of the ESP8266. Motors draw high current and make electrical noise that can reset the board.
- The GND of the motor supply, the DRV8833 and the ESP8266 must all be connected together. Without a common ground the motor will not respond.
ESP8266 Code for DRV8833 - One Motor
This code speeds the motor up in the forward direction, holds full speed, lets it coast, spins it in reverse at about 70% speed, then brakes. Each step is printed to the Serial Monitor.
Detailed Instructions
To get started with ESP8266 on Arduino IDE, follow these steps:
- Check out the how to setup environment for ESP8266 on Arduino IDE tutorial if this is your first time using ESP8266.
- Wire the components as shown in the diagram. Keep the 5V adapter unplugged for now.
- Connect the ESP8266 board to your computer using a USB cable.
- Open Arduino IDE on your computer.
- Choose the correct ESP8266 board, such as (e.g. NodeMCU 1.0 (ESP-12E Module)), and its respective COM port.
- Copy the code above and paste it into the Arduino IDE. No extra library is needed.
- Click the Upload button on the Arduino IDE to compile and upload the code to the ESP8266.
- Plug in the 5V adapter to power the motor.
- Open the Serial Monitor and watch the motor:
- It slowly speeds up, then runs at full speed for 2 seconds.
- It is released and rolls to a stop.
- It turns the other way at a lower speed.
- It stops sharply when the brake is applied.
※ NOTE THAT:
If the motor turns the "wrong" way, just swap the two motor wires on OUT1 and OUT2. No code change is needed.
Part 2 - ESP8266 Controls Two DC Motors via DRV8833
Now let's use both channels of the DRV8833. Think of motor A as the left wheel and motor B as the right wheel of a small robot car.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
See more in ESP8266's pinout and how to supply power to the ESP8266 and other components.
| DRV8833 Module | ESP8266 NodeMCU / Other |
|---|---|
| IN1 | D5 |
| IN2 | D6 |
| IN3 | D1 |
| IN4 | D2 |
| EEP | 3.3V |
| GND | GND (ESP8266) and negative (-) of the 5V supply |
| VCC | positive (+) of the 5V supply |
| OUT1, OUT2 | motor A (left wheel) |
| OUT3, OUT4 | motor B (right wheel) |
ESP8266 Code for DRV8833 - Two Motors
To keep loop() short, the code uses two helper functions, motorA(speed) and motorB(speed). The speed is a signed number from -255 to 255:
- A positive value spins the motor forward
- A negative value spins it in reverse
- 0 makes it coast
The car drives forward, backward, turns left (left wheel back, right wheel forward), turns right, and then stops.
Detailed Instructions
- Wire the second motor to OUT3 and OUT4, and connect IN3 and IN4 to D1 and D2, as shown in the diagram.
- Connect the ESP8266 to your PC with the USB cable.
- Copy the code above into the Arduino IDE.
- Click the Upload button to upload it to the ESP8266.
- Plug in the 5V adapter.
- Open the Serial Monitor. The output looks like this:
- If one wheel turns the opposite way during "Car: forward", swap that motor's two wires.
Video Tutorial
Additional Knowledge
Let's compare the DRV8833 with the L298N driver used in the ESP8266 - DC Motor tutorial.
| DRV8833 | L298N | |
|---|---|---|
| Motor voltage | 2.7V to 10.8V | 5V to 35V |
| Current per channel | about 1.5A (2A peak) | about 2A |
| Switch type | MOSFET (low loss) | BJT (about 2V loss) |
| Speed control | PWM on IN pins | PWM on ENA/ENB pins |
| Pins needed per motor | 2 | 3 |
| Size | very small | large, with heatsink |
It is evident that the DRV8833 is the better choice for small 3V to 9V battery robots, while the L298N is still useful when the motors need 12V or more.