Servo
Controlling MG996R Servo with ESP32
What is the MG996R?
A metal-gear servo offering significantly more torque than the SG90, favored in robotic arms and RC vehicle steering.
Specifications
| Operating voltage | 4.8V - 7.2V DC (6V typical) |
| Torque | ~9.4 kg·cm at 4.8V, ~11 kg·cm at 6V |
| Rotation | ~120° on most units (some rebadged versions claim 180° — verify with your specific unit) |
| Speed | ~0.17 sec/60° at 4.8V, ~0.14 sec/60° at 6V |
| Control signal | PWM, 50Hz, ~1ms-2ms pulse width |
| Stall current | Up to ~2.5A — needs its own 5-6V supply, not the MCU board's 5V rail |
| Weight | ~55g |
MG996R Pinout
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground — usually the brown wire |
| 2 | VCC | Power, 4.8V-7.2V DC — usually the red wire |
| 3 | Signal | PWM control input — usually the orange wire |
A single MG996R under load can brown out an Arduino running from USB. Power it from a separate 5-6V supply and tie grounds together.
Setting Up MG996R with ESP32
Library
Servo by Arduino
Bundled with the Arduino IDE core
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| VCC | External 5-6V supply, not the ESP32's onboard 5V pin | MG996R can draw 500mA-1A+ under load -- the ESP32's regulator can't supply this reliably |
| GND | GND | Common ground between the ESP32 and the servo supply is required |
| Signal | GPIO18 | Any PWM-capable GPIO works |
Example code
MG996R needs its own 5-6V supply capable of at least 1A -- powering it from the ESP32's 5V/VIN pin can brown out the board under load. Share ground between both supplies.
Related Guides & Projects

ESP32-CAM Web Server: Stream Live Video in 5 Minutes
A complete, no-guesswork walkthrough for flashing an AI-Thinker ESP32-CAM as a live MJPEG video stream -- wiring, Arduino IDE setup, the CameraWebServer sketch, and every failure mode that actually causes problems.

ESP32 MQTT Tutorial: Publish and Subscribe with Arduino IDE
A complete, broker-agnostic ESP32 MQTT tutorial -- topics, QoS, retained messages, Last Will and Testament, TLS security for production, and a working publish/subscribe example with PubSubClient.

Installing ESP8266 in Arduino IDE: NodeMCU (ESP-12E) Complete Setup Guide for Windows
From driver headaches to a blinking LED — the full Windows walkthrough for getting NodeMCU ESP8266 boards running in Arduino IDE, plus notes for Mac and the bare ESP-01 module.

ESP32 Pinout Guide: Every GPIO, ADC, PWM, and Restricted Pin Explained
Complete ESP32 pinout guide covering all GPIOs, input-only pins, strapping pins, flash-reserved pins, dual ADC channels, PWM via LEDC, I2C, SPI, UART, and deep sleep wake pins.