Servo
Controlling MG996R Servo with ESP32
What is the MG996R?
MG996R practical reference
A metal-gear servo offering significantly more torque than the SG90, favored in robotic arms and RC vehicle steering.
Key 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
Pinout and connection notes
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.
- GND: Ground — usually the brown wire
- VCC: Power, 4.8V-7.2V DC — usually the red wire
- Signal: PWM control input — usually the orange wire
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
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 |
Swipe sideways to see every column →
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 Components
Active Buzzer
Self-oscillating buzzer that beeps with just a single HIGH signal — no PWM required.
BLDC ESC
High-speed brushless motor and electronic speed controller combo.
Continuous Servo
Modified servo that spins continuously like a geared motor.
SG90
The classic 9g micro servo — small, cheap, and perfect for any hobby mechanism.
Related Guides & Projects
MicroPython vs Arduino on ESP32: Which Should You Learn First?
An honest comparison for beginners: where MicroPython is easier, where Arduino C++ is faster, how libraries and memory differ, and how to choose based on your project instead of hype.
MicroPython ESP32 Web Server: Control an LED or Relay from Your Browser
Create a working web server with the socket module, parse requests, serve a responsive control page for an LED or a relay, keep the displayed state truthful, choose a safe relay startup state and make the server survive bad or repeated requests.
MicroPython on ESP32 and Raspberry Pi Pico W: The Complete Guide
A structured MicroPython learning path for ESP32 and Pico W. Set up your tools, control GPIO, read sensors, connect to WiFi, build web servers, publish MQTT data and make projects reliable. Start here, then follow the links by level.
boot.py vs main.py in MicroPython: What Runs, When and Why
Understand the difference between boot.py and main.py in MicroPython, startup order, Wi-Fi setup, project structure, and recovery from boot errors.