ESP8266 - BTS7960 Motor Driver
A garage door opener is a good example of a heavy motor job. One strong 12V or 24V DC gear motor pulls the door up, waits, and later lets it down again. The ESP8266 has Wi-Fi on board, so a NodeMCU could one day open that door from your phone. The problem: a NodeMCU pin can only give a tiny current, and a door motor can need many amps. The BTS7960 motor driver module sits in the middle and does the heavy work. This tutorial instructs you how to use ESP8266 NodeMCU to run a 12V DC motor through the BTS7960, in both directions and at any speed. In detail, we will learn:
- What the parts on the BTS7960 board do, and where each of its eight header pins must go
- How to run six jumper wires from the NodeMCU pins (VIN, GND, D5, D6, D7, D8) straight to the module
- How the 12V adapter and the motor connect to the screw terminal, far away from the ESP8266
- How to program ESP8266 to ramp the motor up and down, brake it, reverse it and let it coast

We suggest:
- Checking out the ESP8266 - DRV8833 DC Motor Driver tutorial if your motor is a small one, such as a wheel of a toy robot. That tiny board runs two small motors.
- Checking out the ESP8266 - DC Motor tutorial for the basics of speed and direction with a small 5V motor and the DRV8833.
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 BTS7960 Motor Driver

The DIYables BTS7960 43A Motor Driver Module is the same board that many shops sell as "IBT-2" or "HW-039". On the top side of the PCB, you find two Infineon BTS7960B chips, one 74HC14 chip and the 8-pin control header. A big heat sink is bolted under the board to take the heat away. Each BTS7960B is a half-bridge, and two half-bridges make one full H-bridge. So the module drives one brushed DC motor, forward or backward, with the speed set by PWM. Next to small drivers like the L298N or the DRV8833, it is the big brother: it is made for large gear motors, wiper motors, winches, scooters and garage door motors.
| BTS7960 Motor Driver Module | |
|---|---|
| Driver type | one full H-bridge, made of two BTS7960B half-bridges |
| Motors it can drive | 1 brushed DC motor, both directions |
| Motor supply on B+ / B- | 5.5V to 27V DC (for 6V, 12V or 24V motors) |
| Current | up to 43A (the current-limit level of the chips, a peak value) |
| PWM on RPWM / LPWM | up to 25 kHz |
| Input side | a 74HC14 buffer chip, fed from VCC |
| Built-in safety | over-temperature protection and current limiting |
How It Works in a Few Words
Each half-bridge looks after one motor wire and links it either to B+ or to B-. When one half links its wire to B+ and the other half links its wire to B-, current flows through the motor in one direction. Let the two halves trade jobs, and the current, and so the motor, go the other way. The speed comes from PWM: the ESP8266 switches the RPWM or LPWM pin on and off many times a second. The bigger the "on" part of each cycle (the duty cycle), the faster the motor runs. The 74HC14 chip sits between the ESP8266 and the big chips and passes the control signals on.
The BTS7960 Motor Driver Pinout
The control header has 2 x 4 male pins. Its top row is VCC, R_IS, R_EN, RPWM. The bottom row is GND, L_IS, L_EN, LPWM. The four large screw terminals on the other edge are for the power supply and the motor.
- RPWM pin: must be connected to a PWM-capable pin of the ESP8266. A PWM signal here spins the motor forward (right half-bridge).
- LPWM pin: must be connected to another PWM-capable pin. A PWM signal here spins the motor in reverse (left half-bridge).
- R_EN pin: must be connected to a digital output pin. HIGH turns the right half-bridge on.
- L_EN pin: must be connected to a digital output pin. HIGH turns the left half-bridge on.
- R_IS and L_IS pins: they report the current and any fault. This tutorial does not need them, so they stay free.
- VCC pin: must be connected to the VIN pin of the NodeMCU (5V from USB). It feeds only the 74HC14 logic chip and the power LED, never the motor.
- GND pin: must be connected to a GND pin of the NodeMCU. On the module, this pin and B- are joined.
- B+ and B- terminals: the plus and the minus of the 12V motor supply.
- M+ and M- terminals: the two wires of the DC motor.
※ NOTE THAT:
Read the printed text, not the pin position. Look for "R_S" and "L_S" on the DIYables board: these are R_IS and L_IS. Other IBT-2 style boards may print the labels a little differently. Check your own module before you plug in any wire.
Which Pin Levels Move the Motor
When R_EN and L_EN are both HIGH, the two PWM pins choose what the motor does:
| RPWM | LPWM | Result |
|---|---|---|
| PWM (0 to 255) | 0 | forward, a higher value gives more speed |
| 0 | PWM (0 to 255) | reverse, a higher value gives more speed |
| 0 | 0 | brake, the driver joins M+ and M-, so the motor stops fast |
When R_EN and L_EN are both LOW, both half-bridges turn off. Nothing drives or holds the motor now, so it coasts: it keeps rolling and slows down by itself. A brake stops a heavy load in a short time. A coast is softer, but it takes longer.
One rule never changes: at least one of RPWM and LPWM must be 0. Do not send PWM to both of them at the same time.
Two Power Sides: Logic and 12V Motor
- Logic side: VCC goes to the VIN pin of the NodeMCU, which carries 5V from the USB cable. VCC powers only the 74HC14 buffer chip, and 5V is the value the module maker gives for it. The buffer still accepts the 3.3V signals of the ESP8266, so D5 to D8 can drive it with no extra parts. Its inputs have pull-down resistors, so no 5V gets back into a NodeMCU pin.
- Motor side: the 12V power adapter feeds B+ and B- through a DC power jack, plus to B+ and minus to B-. The adapter has to supply more current than the garage door motor draws. Keep B+ away from the NodeMCU: no pin of the board may ever get 12V.
- Ground: GND and B- are already joined on the module. So the single GND wire from the NodeMCU to the header is enough to give the board and the 12V adapter one common ground.
- No way back: R_IS and L_IS stay free, so no signal comes back from the module to the ESP8266. No high voltage can reach its 3.3V pins.
What does "43A" mean for you? It is the level where the current limit of the chips steps in, a peak value. A motor that runs for a long time should draw much less than that. For a motor that runs a long time, the heat sink sets the real limit.
Wiring Diagram
In the picture, six jumper wires run straight from the VIN, GND, D5, D6, D7 and D8 pins of the NodeMCU to the header of the BTS7960. No breadboard is used. The motor and the DC power jack of the 12V adapter are screwed into the big terminal block of the module.

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.
| BTS7960 Module | ESP8266 NodeMCU / 12V Side |
|---|---|
| VCC | VIN (5V from USB) |
| GND | GND |
| R_EN | D5 (GPIO14) |
| L_EN | D6 (GPIO12) |
| LPWM | D7 (GPIO13) |
| RPWM | D8 (GPIO15) |
| R_IS, L_IS | not used, no wire |
| B+ | + of the 12V power adapter (via the DC power jack) |
| B- | - of the 12V power adapter (via the DC power jack) |
| M+, M- | the 12V DC motor (one wire on each) |
WARNING
Plug in the 12V adapter last, after every wire is in place. Before you do it, check that + goes to B+ and - goes to B-. Swapped polarity can damage the module.
Why These Six NodeMCU Pins?
On the NodeMCU, GND, D5, D6, D7 and D8 sit side by side in one row. Their order is the same as the order of the wires on the header of the module, so these five jumper wires run next to each other and do not cross. VIN is on the other side of the board. It gives 5V when the NodeMCU runs on USB, so its wire goes to VCC on its own. All of D5 to D8 can make PWM with analogWrite(), and RPWM (D8) and LPWM (D7) need that.
D8 (GPIO15) is a boot pin that must be LOW at start-up, but the NodeMCU pulls it LOW and the BTS7960 input does not pull it HIGH, so it is fine here.
Some other pins are kept free on purpose:
- D0 (GPIO16) cannot make PWM.
- D3 (GPIO0) and D4 (GPIO2) must be HIGH at start-up, so it is better not to hang a driver input on them.
- D1 and D2 stay free for an I2C screen or sensor later, for example a small display that shows if the door is open.
How To Program For BTS7960 Motor Driver
No library is needed. Two built-in functions do all the work: analogWrite() sets the speed, and digitalWrite() switches the enable pins.
- Give each NodeMCU pin a name. D5 to D8 are the names printed on the board, and the ESP8266 core knows them:
- In setup(), make the four pins outputs and fix the PWM range at 0 to 255. New ESP8266 cores already use this range, but old 2.x cores used 0 to 1023. With this line, 255 is full speed on both:
- Put 0 on both PWM pins first. Only then wake the driver up with both enable pins HIGH:
- For forward, set LPWM to 0 and put the speed (0 to 255) on RPWM. For reverse, swap the two pins:
- For a brake, write 0 to RPWM and LPWM and leave the enable pins HIGH.
- For a coast, write 0 to both PWM pins and pull R_EN and L_EN LOW. Set them HIGH again before the motor should run.
ESP8266 NodeMCU Code for BTS7960 Motor Driver
The sketch below puts those lines into small functions: motorForward(), motorReverse(), motorBrake(), motorCoast(), and enableDriver() for the two enable pins. Then loop() repeats one test run, again and again:
- Forward: speed up from 0 to 255 in small steps, hold full speed for 2 seconds, then slow down to 0
- Brake for 1 second
- Reverse for 2 seconds at a value of 128, which is about half speed
- Coast for 2 seconds with the driver off, then switch the driver on again
At the start of each step, the NodeMCU sends a short line over USB, so you can follow along in the Serial Monitor.
Detailed Instructions
- New to the ESP8266? Follow the how to setup environment for ESP8266 on Arduino IDE tutorial first.
- Make the six jumper-wire connections from the table, straight from the NodeMCU pins to the module header. Screw the motor wires to M+ and M-, and the DC power jack to B+ and B-. Keep the 12V adapter unplugged.
- Connect the ESP8266 board to your computer using a USB cable.
- Open Arduino IDE on your computer.
- Choose the board NodeMCU 1.0 (ESP-12E Module) and the COM port it uses.
- Paste the code into the Arduino IDE and click Upload. Leave the 12V side without power during the upload.
- As soon as the IDE says the upload is finished, connect the 12V adapter to the jack. Now the motor side has power.
- Open the Serial Monitor at 9600 baud, and watch the motor and the messages together:
Listen to the two kinds of stop. After "BRAKE", the motor stops almost at once. After "COAST", it spins down slowly.
A few things you may notice:
- The motor turns the wrong way during "FORWARD"? Unplug the 12V adapter and swap the M+ and M- wires. The code stays the same.
- A soft hum or whine at low speed is normal. The ESP8266 makes its PWM at about 1 kHz, and people can hear that sound.
- Some strange characters at the top of the Serial Monitor are normal too. The ESP8266 prints its start-up messages at another speed (74880 baud).
Additional Knowledge
BTS7960, L298N or DRV8833?
Two of these drivers have ESP8266 tutorials on this site: the BTS7960 on this page and the DRV8833, which the ESP8266 - DC Motor tutorial uses too. Here is a quick look at how all three differ:
| BTS7960 | L298N | DRV8833 | |
|---|---|---|---|
| Motors per module | 1 | 2 | 2 |
| Current | up to 43A (peak) | about 2A per motor | about 1.5A per motor |
| Voltage lost inside the driver | very little | about 2V | very little |
| ESP8266 pins per motor (in these tutorials) | 4 | 3 | 2 |
It is evident that the BTS7960 is the right pick when one motor needs a lot of current, like a garage door or a winch. When you only need to spin two little motors, the tiny DRV8833 board does the job with fewer wires.
From Test Bench to a Wi-Fi Garage Door
This page only runs a fixed test. But the ESP8266 has Wi-Fi, so the next steps are not far away:
- Open and close from your phone: put two buttons on a web page, like in the ESP8266 - Web Server tutorial, and call motorForward() or motorReverse() when one of them is pressed.
- Stop at the ends: a real door must stop when it is fully open or fully closed. The ESP8266 - DC Motor Limit Switch tutorial shows how a limit switch stops a motor.
- Join a smart home: send "open" and "close" commands to the NodeMCU through MQTT from a home dashboard.
A real garage door also needs safety parts, such as a sensor that stops the door when something is in its way. Do not connect your test setup to a real door before those parts are in place.