MG996R Servo · Straight Horn with an ESP32 DevKit V1
TowerPro's metal-gear servo, 11 kg·cm at 6V from a standard 50Hz servo pulse, fitted with a single straight arm.

On the ESP32 DevKit V1 the MG996R shares only its signal and its ground with the board: SIG goes to GPIO13 and GND to a GND pin, while VCC takes a 4.8 V to 6.6 V supply of its own whose minus joins that ground. The ESP32's 3.3 V pulse drives the signal input directly, and the ESP32Servo library replaces the Servo library, which the ESP32 core does not have.
Wiring the MG996R Servo · Straight Horn to the ESP32 DevKit V1
Pin by pin.
| MG996R Servo · Straight Horn | ESP32 DevKit V1 | Note |
|---|---|---|
| GND | GND | and to the separate supply's −: the servo, its supply and the board share one ground |
| SIG | GPIO13 (D13) | |
| VCC | a separate 4.8 to 6.6 V supply (4 × AA), never the board's 5V pin | the MG996R draws about 1.4 A at stall |
What to know on the ESP32 DevKit V1
- The GND row joins the servo supply's minus to the DevKit's GND. Keep that wire: the pulse is measured against ground, and without it the servo jitters or ignores the signal.The page's sketch, supply comment
- Never feed the MG996R from VIN or 3V3: it draws 170 mA running unloaded and 1,400 mA at stall, far more than the DevKit's USB supply can give alongside the ESP32's own Wi-Fi bursts.TowerPro MG996R spec page; Espressif ESP32 Series Datasheet v5.3, p. 52
- ESP32Servo makes the 50 Hz pulse on the ESP32's LED PWM controller, which can be routed to any GPIO; the sketch's attach(13, 500, 2400) uses most of the servo's travel. Avoid GPIO34 to GPIO39, which are input-only.Espressif ESP32 Series Datasheet v5.3, p. 39; Espressif ESP32 Series Datasheet v5.3, p. 61
MG996R Servo · Straight Horn code for the ESP32 DevKit V1
Compiled for esp32:esp32:esp32 on 2026-10-30.
// MG996R Servo · Straight Horn on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/servo-mg996r-straight/esp32
#include <ESP32Servo.h>
// The MG996R draws up to about 1.4 A at stall: power it from its own 5 to 6 V supply,
// never from the board's 5V pin, and join that supply's GND to the board's GND.
const int SERVO_PIN = 13;
Servo servo;
void setup() {
servo.attach(SERVO_PIN, 500, 2400);
}
void loop() {
for (int angle = 0; angle <= 180; angle += 2) {
servo.write(angle);
delay(15);
}
for (int angle = 180; angle >= 0; angle -= 2) {
servo.write(angle);
delay(15);
}
}
MG996R Servo · Straight Horn on the ESP32 DevKit V1: questions
Can an ESP32 control an MG996R servo?
Yes. The 3.3 V pulse from GPIO13 drives the signal input; the servo gets 4.8 V to 6.6 V and up to 1,400 mA at stall from its own supply (TowerPro spec page), with grounds joined.
Why does my ESP32 reset when the MG996R moves?
The servo is sharing the board's supply. At stall it draws 1,400 mA (TowerPro spec page); give it a separate 5 V to 6 V supply and connect only SIG and GND to the DevKit.
Which library drives a servo on the ESP32?
ESP32Servo (madhephaestus/ESP32Servo), included as ESP32Servo.h. The standard Servo library targets the AVR and does not build for the ESP32 core.
Keep going
This guide as plain Markdown. /components/servo-mg996r-straight/esp32.md