Overview
The DRV8871 module is a single H-bridge driver for one brushed DC motor. Two logic inputs set the direction, and a PWM signal on either input sets the speed. It handles motor supplies from 6.5 V to 45 V and up to 3.6 A peak, with built-in current limiting and thermal protection.
It is a compact, efficient choice for robots, pumps, fans, linear actuators and other motors that need more voltage or current than small drivers can give. The inputs accept 3.3 V and 5 V logic, so it works directly with Arduino, ESP32, Raspberry Pi and Pico boards. The control header comes pre-soldered.
At a Glance
Specifications
| Parameter | Value |
| Driver IC | DRV8871, single H-bridge |
| Motor supply | 6.5 V to 45 V on POWER + and POWER − |
| Peak output current | 3.6 A |
| Current limit | Set by a resistor on the board: limit in A = 64 / R in k ohm. Supplied set to about 2 A |
| Logic inputs | IN1 and IN2, 3.3 V and 5 V compatible (5.5 V maximum) |
| Logic supply | None needed: the chip powers itself from the motor supply |
| PWM frequency | Up to 200 kHz |
| Load | One brushed DC motor, in both directions |
| Protection | Under-voltage lockout, over-current, thermal shutdown |
| Connections | Pads: POWER −, POWER +, OUT1, OUT2. Header: GND, VM, IN1, IN2 |
Pinout Diagram
The large pads on one side are the power side: POWER − and POWER + for the motor supply, OUT1 and OUT2 for the motor. The four-pin header on the other side is the control side: GND, VM, IN1 and IN2. VM on the header is joined to POWER +, so it carries the full motor voltage. Do not connect it to a 5 V or 3.3 V pin.
Wiring Guide
Wire the power side first: motor supply to POWER + and POWER −, motor to OUT1 and OUT2. Then connect IN1, IN2 and GND to your controller. The controller and the motor supply must share a ground. The driver needs no logic supply, so nothing goes to your board's 5 V or 3.3 V pin.
Arduino Uno / Nano Wiring
| Driver Pin | Arduino Pin | Function |
|---|---|---|
| IN1 | D9 | PWM / direction |
| IN2 | D10 | PWM / direction |
| GND | GND | Common ground |
| VM | Not connected | Motor voltage |
ESP32 Wiring
| Driver Pin | ESP32 Pin | Function |
|---|---|---|
| IN1 | GPIO 25 | PWM / direction |
| IN2 | GPIO 26 | PWM / direction |
| GND | GND | Common ground |
| VM | Not connected | Motor voltage |
Raspberry Pi Wiring
| Driver Pin | Pi Pin | Function |
|---|---|---|
| IN1 | GPIO 17 (Pin 11) | PWM / direction |
| IN2 | GPIO 27 (Pin 13) | PWM / direction |
| GND | GND (Pin 6) | Common ground |
| VM | Not connected | Motor voltage |
Raspberry Pi Pico Wiring
| Driver Pin | Pico Pin | Function |
|---|---|---|
| IN1 | GP14 (Pin 19) | PWM / direction |
| IN2 | GP15 (Pin 20) | PWM / direction |
| GND | GND (Pin 18) | Common ground |
| VM | Not connected | Motor voltage |
Code Examples
View or download this product's example code on GitHub.
Each example runs the motor forward, stops or brakes it, then runs it in reverse. Speed is set by PWM on one input while the other input stays low.
Arduino and ESP32 — Ramp Forward, Brake, Reverse
// DRV8871 motor driver - ramp a DC motor forward, brake, then ramp it in reverse
// Arduino Uno/Nano: IN1 = D9, IN2 = D10, GND = GND. ESP32: IN1 = GPIO 25, IN2 = GPIO 26, GND = GND.
// The motor supply (6.5 V to 45 V) goes to POWER + and POWER -. Leave the header VM pin unconnected.
#if defined(ESP32)
const int PIN_IN1 = 25;
const int PIN_IN2 = 26;
#else
const int PIN_IN1 = 9;
const int PIN_IN2 = 10;
#endif
void drive(int speed) { // speed: -255 (full reverse) to 255 (full forward)
if (speed >= 0) {
analogWrite(PIN_IN1, speed);
analogWrite(PIN_IN2, 0);
} else {
analogWrite(PIN_IN1, 0);
analogWrite(PIN_IN2, -speed);
}
}
void brake() { // both inputs HIGH = brake
analogWrite(PIN_IN1, 255);
analogWrite(PIN_IN2, 255);
}
void setup() {
pinMode(PIN_IN1, OUTPUT);
pinMode(PIN_IN2, OUTPUT);
drive(0); // both inputs LOW = coast
}
void loop() {
for (int s = 0; s <= 255; s += 5) { drive(s); delay(20); } // speed up forward
delay(1000);
brake();
delay(500);
for (int s = 0; s >= -255; s -= 5) { drive(s); delay(20); } // speed up in reverse
delay(1000);
drive(0); // coast to a stop
delay(2000);
}
Raspberry Pi — Forward and Reverse (Python)
#!/usr/bin/env python3
# DRV8871 motor driver on Raspberry Pi - forward, stop, reverse with gpiozero
# Wiring: IN1 = GPIO 17 (pin 11), IN2 = GPIO 27 (pin 13), GND = pin 6
# The motor supply (6.5 V to 45 V) goes to POWER + and POWER -. Leave the header VM pin unconnected.
from gpiozero import Motor
from time import sleep
motor = Motor(forward=17, backward=27) # PWM speed control on both inputs
while True:
motor.forward(0.5) # half speed forward
sleep(2)
motor.forward(1.0) # full speed forward
sleep(2)
motor.stop() # both inputs low = coast
sleep(1)
motor.backward(0.5) # half speed in reverse
sleep(2)
motor.stop()
sleep(2)
Raspberry Pi Pico — Forward, Brake, Reverse (MicroPython)
# DRV8871 motor driver on Raspberry Pi Pico (MicroPython) - forward, brake, reverse
# Wiring: IN1 = GP14, IN2 = GP15, GND = GND
# The motor supply (6.5 V to 45 V) goes to POWER + and POWER -. Leave the header VM pin unconnected.
from machine import Pin, PWM
import time
in1 = PWM(Pin(14))
in2 = PWM(Pin(15))
in1.freq(20000) # 20 kHz, above the audible range
in2.freq(20000)
def drive(speed): # speed: -1.0 (full reverse) to 1.0 (full forward)
duty = int(min(abs(speed), 1.0) * 65535)
if speed >= 0:
in1.duty_u16(duty)
in2.duty_u16(0)
else:
in1.duty_u16(0)
in2.duty_u16(duty)
def brake(): # both inputs high = brake
in1.duty_u16(65535)
in2.duty_u16(65535)
while True:
drive(0.5)
time.sleep(2)
drive(1.0)
time.sleep(2)
brake()
time.sleep(1)
drive(-0.5)
time.sleep(2)
drive(0) # both inputs low = coast
time.sleep(2)



