The Direct Answer: What's a Servo Motor in Embedded Systems?

A servo motor is a closed-loop rotary actuator that uses internal feedback to precisely control angular position, velocity, or acceleration. Unlike a standard brushed DC motor that spins freely when voltage is applied, a servo contains a DC motor, a gear reduction train, and a feedback sensor (usually a potentiometer or magnetic encoder) packaged into a single unit. An internal error amplifier constantly compares your target position signal against the actual shaft position and adjusts the motor drive to eliminate the error.

In the embedded and maker space, when someone asks "what's a servo motor," they are almost always referring to hobby RC servos controlled by a 50Hz Pulse Width Modulation (PWM) signal. However, the underlying closed-loop principle scales all the way up to multi-kilowatt industrial AC servos used in CNC mills. For Arduino, ESP32, and Raspberry Pi projects, we focus on the 5V to 8.4V PWM and serial bus variants.

Callout: The Closed-Loop Advantage
Because a servo continuously corrects its position, it will actively fight external forces trying to move its output shaft. A stepper motor, by contrast, is open-loop; if a stepper misses steps due to a mechanical jam, the controller has no idea it lost position.

Motor Type Comparison: Servo vs. Stepper vs. Brushed DC

Choosing the right actuator dictates your entire control architecture. Steppers and servos are fundamentally different and should never be treated as interchangeable. Here is how they stack up for embedded load profiles.

Motor Type Torque Curve Control Needs Relative Cost Best Load Profile
Hobby Servo (PWM) High holding torque at zero speed; drops off at high RPM. 50Hz PWM (1-2ms pulse). Simple GPIO or I2C driver. $4 - $25 Robotic arms, pan/tilt cameras, RC steering.
Stepper (e.g., NEMA 17) High holding torque; severe torque drop-off above 1000 RPM. Step/Direction pulses via dedicated driver (A4988, TMC2209). $12 - $40 3D printers, CNC routers, linear actuators.
Brushed DC (Gearmotor) Peak torque at stall; linear drop to zero at no-load speed. H-Bridge for direction/speed. Requires external encoder for position. $8 - $30 Drive wheels, conveyors, continuous rotation.
Industrial AC Servo Flat, continuous torque curve up to rated RPM; high peak overload. Complex multi-axis drive, real-time fieldbus (EtherCAT, CANopen). $300+ High-speed pick-and-place, industrial automation.

Sizing Rule of Thumb and Worked Load Example

Servo torque is rated in kg-cm or oz-in. This is a measure of rotational force, not linear weight. The fundamental sizing rule of thumb is:

Required Torque = (Load Mass × Distance from Pivot) + Friction Margin

Always apply a 50% dynamic safety margin to your static calculation. Accelerating a mass requires significantly more torque than simply holding it still. Furthermore, servo manufacturers test stall torque under ideal laboratory conditions with perfect voltage; real-world voltage sag will reduce your available torque.

Worked Load Example: Robotic Arm Gripper

Imagine you are building a robotic arm segment that is 12 cm long. The payload at the end of the arm is 400 grams (0.4 kg), and the arm itself weighs 150 grams (0.15 kg, center of mass at 6 cm).

  1. Payload Torque: 0.4 kg × 12 cm = 4.8 kg-cm
  2. Arm Weight Torque: 0.15 kg × 6 cm = 0.9 kg-cm
  3. Total Static Torque: 4.8 + 0.9 = 5.7 kg-cm
  4. Add 50% Safety Margin: 5.7 × 1.5 = 8.55 kg-cm minimum required

The Selection: A standard 9g micro servo (rated ~1.8 kg-cm) will instantly strip its plastic gears. A TowerPro MG996R (rated ~13 kg-cm, typically $5-$8) or a DS3218 (rated 20 kg-cm, ~$15) is the correct choice here. You would select the DS3218 if the arm is subject to shock loads or rapid acceleration.

Wiring, Terminals, and Controller Demands

Standard hobby servos use a 3-wire interface. The color coding is generally standardized, but you must verify the datasheet for your specific brand.

  • Signal (PWM): Orange or White wire. Connects to a microcontroller GPIO pin.
  • VCC (Power): Red wire. Connects to a 5.0V to 6.0V power supply.
  • GND (Ground): Brown or Black wire. Connects to power supply ground AND microcontroller ground.
Warning: The 5V Pin Trap
Never power a standard or high-torque servo directly from the 5V pin of an Arduino Uno or ESP32 DevKit. An MG996R can draw 2.5 Amps at stall. The onboard linear regulator of a microcontroller is typically rated for 500mA to 800mA. Attempting this will cause a brownout, resetting your code, or permanently fry the MCU's voltage regulator. Always use a dedicated Buck Converter (like an LM2596 module) fed from a 7V-12V battery or wall supply, and ensure the buck converter's ground is tied directly to the MCU's ground.

Controller Demands: PWM vs. Serial Bus

For PWM servos, the control signal is a 50Hz square wave where a 1.0ms pulse commands 0°, 1.5ms commands 90°, and 2.0ms commands 180°.

  • Arduino: Use the native Servo library. Note that on the Uno, this library hijacks Timer1, which disables hardware PWM on pins 9 and 10.
  • ESP32: The ESP32 does not use traditional timers for PWM; it uses the LEDC (LED Control) peripheral. Use the ESP32Servo library, which maps the servo commands to the LEDC hardware channels.
  • Scaling Up: If you need to drive more than 4 servos, do not use direct GPIO pins. Use a PCA9685 I2C PWM driver board (~$3). It offloads the precise timing generation from your MCU and handles up to 16 servos on a single I2C bus.

For complex multi-joint robots, consider Serial Bus Servos (like the LewanSoul or Feetech SCS series). These use a half-duplex UART bus (TTL serial) over the power wires, allowing you to daisy-chain dozens of servos on a single TX/RX pin, read back internal temperature, and monitor exact load currents in real-time.

Failure Signatures: Hum, Overheat, and Stall

Servos fail in predictable ways. Recognizing these signatures early will save your hardware.

1. Jitter and Humming

Symptom: The servo shaft vibrates rapidly back and forth by 1-2 degrees, accompanied by a high-pitched hum.
Cause: This is almost always a power integrity or signal issue. If the power supply has high ripple, or if the ground wire is too thin (causing ground bounce when the motor draws current), the internal error amplifier sees a fluctuating target voltage. It can also indicate a worn carbon-track potentiometer inside an older servo.
Fix: Add a 470µF electrolytic capacitor across the VCC and GND terminals at the servo. Upgrade your ground wire to at least 22 AWG. If using long PWM signal wires, add a 1kΩ pull-down resistor at the servo end to prevent floating noise.

2. Overheating and Smell of Ozone

Symptom: The servo casing is too hot to touch, and it may emit a burning plastic smell.
Cause: Stall condition. When a servo is commanded to a position it cannot physically reach (e.g., hitting a mechanical hard stop at 180° when the internal pot only reads 175°), the internal H-bridge applies maximum stall current continuously. A 20kg-cm servo can pull 3+ Amps at 6V, dissipating 18 Watts of heat inside a sealed plastic box.
Fix: Implement software limits in your code. Never command a standard servo to exactly 0 or 180 degrees; command 5 to 175 degrees instead to keep the internal wiper off the extreme ends of the potentiometer track.

3. Stripped Output Spline

Symptom: The motor hums and you hear gears turning, but the external output horn does not move.
Cause: Shock loading. If a servo-driven arm drops a heavy weight, the kinetic energy transfers back through the gears, shearing the teeth off the final output gear.
Fix: Upgrade to metal-gear servos (denoted by 'MG' in part numbers, like MG996R). However, be aware that metal gears do not absorb shock; they transfer it to the motor shaft bearings or your 3D-printed mounting brackets. Add mechanical dampening or spring-loaded end-stops to your physical design.

Frequently Asked Questions

What's a servo motor's difference from a stepper motor in 3D printing?

Stepper motors are the standard for 3D printers because they excel at continuous, high-speed rotation with precise open-loop step counting, and they hold position rigidly without needing a feedback sensor. Servos are generally poor choices for continuous rotation drive axes because their internal potentiometers limit them to a ~270° physical rotation, and their control loops are optimized for rapid point-to-point positioning, not smooth continuous velocity tracking. Use steppers for linear/continuous axes, and servos for robotic joints or camera gimbals.

Can I run a 12V industrial servo directly from an ESP32 GPIO pin?

No, for two reasons. First, an ESP32 GPIO pin outputs 3.3V logic and can only source about 40mA; it cannot physically drive a 12V motor coil. Second, industrial 12V/24V DC servos typically require complex analog voltage inputs (e.g., ±10V command signals) or digital fieldbus protocols (RS-485/CAN), not simple 50Hz PWM. You must use an intermediate motor driver or a dedicated industrial servo drive that accepts step/direction or serial commands from your microcontroller.

Why does my servo jitter when I connect an I2C sensor to the same breadboard?

Breadboards have high contact resistance and long, unshielded jumper wires. When your I2C sensor (like an MPU6050 or BME280) communicates, it pulls current in high-frequency bursts. On a shared breadboard power rail, this creates voltage sags and high-frequency noise that couples into the servo's PWM signal line or its internal potentiometer reference voltage. Move the servo power entirely off the breadboard using a dedicated buck converter, and keep the PWM signal wire as short and physically separated from I2C data lines as possible.