ESP8266 - Feedback Actuator
In a prior tutorial, we discussed the linear actuator without feedback. This tutorial instructs you the feedback linear actuator (also known as the feedback linear actuator). This type of linear actuator provides information to identify the position of its stroke and control it. Specifically, we will be learning:
- The functioning of a feedback linear actuator
- How to determine the position of the feedback linear actuator (in millimeters)
- How to control the position of a linear actuator

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 Feedback Linear Actuator
A linear actuator with feedback is one that has a signal to identify its location and manage it. A potentiometer is used to generate the voltage value in relation to the stroke's position as the feedback.
Feedback Linear Actuator Pinout
A Feedback Linear Actuator has 5 wires:
- Actuator Positive wire: This wire is used to control the linear actuator by applying high voltage (12V, 24V, 48V...).
- Actuator Negative wire: This wire is used to control the linear actuator by applying high voltage (12V, 24V, 48V...).
- 5V wire: this wire is used for the feedback potentiometer. It should be connected to 5V or 3.3V. With the NodeMCU, use the 3.3V pin, so the feedback voltage stays in the range of the A0 pin.
- GND wire: this wire is used for the feedback potentiometer. It should be connected to GND
- Potentiometer wire: (also referred to as feedback wire, or output wire) this wire outputs the voltage value in accordance with the stroke's position.

How It Works
If we supply high voltage to the positive and negative wires, the stroke of the actuator will be extended or retracted. Specifically:
- If 12V (12V, 24V, 48V...) is connected to the positive wire and GND to the negative wire, the linear actuator will extend at full speed until it reaches the limit.
- If 12V (12V, 24V, 48V...) is connected to the negative wire and GND to the positive wire, the linear actuator will retract at full speed until it reaches the limit.
- If power is cut off to the actuator (GND to both positive and negative wire), the actuator will cease extending/retracting.
※ NOTE THAT:
- The voltage required to operate the actuator is determined by its specifications. To find out the exact voltage, consult the datasheet or manual.
- Even when the power is turned off, the actuator can maintain its position while carrying a load.
The voltage in the potentiometer wire is directly related to the stroke position of the actuator. By measuring this voltage, we can ascertain the stroke's location.
BTS7960 Driver Pinout

A BTS7960 module moves the actuator. It is one H-bridge, made of two BTS7960B chips, and it can pass a high current for a short time, which an actuator needs when it starts and when it hits its end stop.
- RPWM and LPWM: PWM on RPWM extends the actuator, PWM on LPWM retracts it. Keep one of them at 0 at all times.
- R_EN and L_EN: HIGH switches the driver outputs on, LOW switches them off.
- R_IS and L_IS: current sense, not used here.
- VCC: 5V for the small logic chip on the module, from the VIN pin of the NodeMCU.
- GND: common ground with the NodeMCU.
- B+ and B-: the 12V supply. M+ and M-: the two power wires of the actuator.
The control inputs work with the 3.3V signals of the ESP8266, and their pull-down resistors keep 5V away from the NodeMCU pins.
Wiring Diagram
All wires go directly from the NodeMCU pins to the BTS7960 header and to the actuator.

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.
| Wire | Connect To |
|---|---|
| BTS7960 RPWM | ESP8266 D8 (GPIO15) |
| BTS7960 LPWM | ESP8266 D7 (GPIO13) |
| BTS7960 R_EN | ESP8266 D5 (GPIO14) |
| BTS7960 L_EN | ESP8266 D6 (GPIO12) |
| BTS7960 VCC | ESP8266 VIN (5V from USB) |
| BTS7960 GND | ESP8266 GND |
| BTS7960 B+, B- | (+) and (-) of the 12V adapter, via the DC power jack |
| BTS7960 M+, M- | actuator positive and negative wires |
| Actuator 5V wire | ESP8266 3.3V |
| Actuator GND wire | ESP8266 GND |
| Actuator potentiometer wire | ESP8266 A0 |
D8 (GPIO15) is a boot pin that must be LOW at power-up. The pull-down resistor on the RPWM input of the BTS7960 keeps it LOW, so the NodeMCU boots as usual.
How to control extend/retract a linear actuator
Check out the ESP8266 - Actuator tutorial.
How to find the position of the linear actuator
This is an illustration of how to locate the stroke on a linear actuator.
Calibration
- Determine the length of the actuator's stroke (in millimeters) by either measuring with a ruler or consulting the datasheet.
- To ascertain the output values when the linear actuator is fully extended and fully retracted, execute the code below.
- You will observe the log on Serial Monitor, as demonstrated in the example below
Note down the three values in the code below. If the minimum and maximum values are reversed, swap the two actuator wires on M+ and M- (or swap RPWM_PIN and LPWM_PIN in the code).
ESP8266 code that calculate the position of the actuator
- Update the code with the three calibrated values.
- Upload the code to ESP8266.
- Check out the result on the Serial Monitor.
How to control a linear actuator to a specific position
The code below moves the stroke to 50 mm and holds it there. When the position is within 5 mm of the target, both RPWM and LPWM get 0, and the BTS7960 brakes the actuator.