Pre-soldered DRV8871 brushed DC motor driver board with green terminal blocks

DRV8871 Pre-Soldered H-Bridge Brushed DC Motor Driver Module | ShillehTek Product Manual

ArduinoESP32Raspberry PiPicomanual-product-10645386232095
$6.99 USD Only 3 left · Order by 3pm ET, ships today

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

Type
H-bridge brushed DC motor driver
Driver IC
DRV8871
Motor Supply
6.5 V to 45 V
Output Current
3.6 A peak
Logic Inputs
3.3 V and 5 V compatible
Control
IN1 and IN2, PWM capable

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.

DRV8871 H-bridge motor driver module pinout diagram showing POWER, OUT1, OUT2 terminals and GND, VM, IN1, IN2 header pins

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
VM pin: Leave the header VM pin unconnected. It carries the full motor supply voltage, which would damage a 5 V or 3.3 V pin.

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
Other pins: Almost any ESP32 output pin can produce PWM. If you use other pins, change the two numbers at the top of the sketch.

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
Motor supply: The motor needs its own 6.5 V to 45 V supply on POWER + and POWER −. Join the negative side of that supply to a Pi GND pin.

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
Motor supply: The motor needs its own 6.5 V to 45 V supply on POWER + and POWER −. Join the negative side of that supply to a Pico GND pin.

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.ino
// 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)

drv8871_motor.py
#!/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_pico.py
# 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)

Frequently Asked Questions

How do I control direction and speed?
Use the two inputs. IN1 high with IN2 low drives the motor one way, and IN1 low with IN2 high drives it the other way. Both low lets the motor coast, and both high brakes it. For speed control, send PWM to the input that would be high and keep the other one low.
Why does my motor not move?
Check the motor supply first: the DRV8871 needs at least 6.5 V on POWER + and will not run from 5 V. Then check that the supply ground and your controller ground are joined, and that IN1 and IN2 are not both low or both high. A supply that sags under load can also trip the under-voltage lockout.
What do I connect to the VM pin on the header?
Normally nothing. VM on the header is joined to POWER +, so it carries the motor supply voltage. It is a convenient tap for that voltage, not a logic supply input. Connecting it to a 5 V or 3.3 V pin while a higher motor supply is attached will damage your controller.
Does it need a 5 V or 3.3 V logic supply?
No. The chip powers its own logic from the motor supply. Your controller only provides the IN1 and IN2 signals and a ground connection. The inputs accept both 3.3 V and 5 V logic levels.
How much current can it deliver?
Up to 3.6 A peak. The driver limits the current to a level set by a resistor on the board, using limit = 64 / R with R in k ohm, and the module is supplied set to about 2 A. At high currents the chip heats up and shuts down to protect itself until it cools, so give it some airflow with heavy loads.
Can it drive two motors or a stepper motor?
One module drives one brushed DC motor in both directions. For two motors, as in a two-wheel robot, use two modules. A bipolar stepper motor needs two H-bridges and the right step sequence, so a dedicated stepper driver is the easier choice there.
What PWM frequency should I use?
Almost anything works, because the DRV8871 accepts PWM up to 200 kHz. The default Arduino Uno PWM on pins 9 and 10 is about 490 Hz, which is fine but can be heard as a whine in some motors. Frequencies around 20 kHz, as used in the Pico example, are above the range of hearing.

Related Tutorials