To run a servo motor on a Raspberry Pi, you cannot connect it directly to the GPIO pins. You must use a dedicated hardware PWM driver like the NXP PCA9685 and an independent 5V/6V power supply. The Raspberry Pi’s Linux-based operating system is not a real-time environment; generating software-based PWM signals on the GPIO pins results in severe timing jitter, causing the servo to vibrate, overheat, and eventually fail. Furthermore, a standard RC servo can draw upwards of 2.5 amps at stall, which will instantly brownout the Pi’s 3.3V logic regulator if wired directly.

This guide walks through selecting the correct motor topology for your load profile, sizing the torque requirements using real-world physics, wiring the mandatory I2C driver board, and diagnosing the three most common servo failure modes on the bench.

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

Before sizing a specific component, you must match the motor topology to your mechanical load profile. Hobbyists often treat steppers and servos as interchangeable, but their torque curves and control architectures are fundamentally different. A stepper motor excels at holding a static position with high precision but loses torque rapidly at higher RPMs. A servo motor provides massive torque at low speeds and self-corrects for external physical disturbances via its internal potentiometer, but it cannot easily spin multiple continuous revolutions without modification.

Below is a data-dense comparison of the four most common motor types used in Raspberry Pi embedded projects. Use this matrix to determine which motor type fits your specific load profile.

Motor Type Torque Curve Profile Control Needs & Feedback Holding Torque / Stall Torque Typical Cost (USD)
Standard Analog Servo
(e.g., TowerPro MG996R)
High torque at 0 RPM, drops off sharply past 60 RPM. Excellent for heavy, slow-moving articulation. 50Hz PWM signal (1-2ms pulse). Internal pot for closed-loop position feedback. Requires PCA9685 driver. 13 kg·cm (1.27 N·m) stall torque. Draws ~2.5A at stall. $8 - $15
High-Torque Digital Servo
(e.g., DS3218 20kg)
Flatter torque curve than analog. Faster transient response to load changes due to high-frequency internal PWM. 50Hz PWM signal. Digital MCU inside handles deadband and PID loop. Requires PCA9685 driver. 20 kg·cm (1.96 N·m) stall torque. Draws ~3.0A at stall. $18 - $28
Bipolar Stepper Motor
(e.g., NEMA 17 42BYGH)
Maximum holding torque at 0 RPM. Torque inversely proportional to speed; requires microstepping for smooth low-speed operation. Step/Direction pulses. Open-loop (no position feedback). Requires dedicated stepper driver (A4988, TMC2209). 4.5 kg·cm (0.44 N·m) holding torque. Draws 1.2A to 1.7A per phase continuously. $12 - $25
Brushed DC Gear Motor
(e.g., Pololu 100:1 Micro Metal)
Linear torque-speed curve. Maximum current and torque at stall, dropping to zero torque at no-load max RPM. H-Bridge for direction/speed (L298N, DRV8833). Open-loop unless external encoder is added. 2.5 kg·cm (0.24 N·m) stall torque. Draws ~1.2A at stall. $15 - $30
Driver Selection Rule: If your application requires the motor to push against a variable physical resistance (like a robotic gripper crushing an object or a steering mechanism hitting a bump), choose a servo. Its internal closed-loop feedback will automatically increase current to fight the disturbance. If your application requires exact open-loop rotational counting (like a 3D printer extruder), choose a stepper.

Sizing Your Raspberry Pi Servo Motor for the Load

The most common mistake in embedded motor selection is sizing the servo based on its peak stall torque. Manufacturers advertise stall torque (the maximum force the motor can exert right before it stops moving), but operating a servo continuously near its stall point will melt the internal plastic gears and burn out the DC motor windings.

The 3x Continuous Load Rule: Always select a servo whose rated stall torque is at least three to five times greater than your calculated continuous operating torque. This safety margin accounts for dynamic acceleration forces, friction in the mechanical linkages, and voltage drops under load.

Worked Load Example: Robotic Arm Payload

Let’s calculate the required servo size for a Raspberry Pi-controlled robotic arm that needs to lift a 200-gram payload. The servo is mounted at the shoulder joint, and the center of mass of the payload is located 10 cm (0.1 meters) away from the servo’s output shaft.

  1. Calculate the Force: Force = mass × gravity.
    F = 0.2 kg × 9.81 m/s² = 1.96 Newtons
  2. Calculate the Base Torque: Torque = Force × Distance.
    T = 1.96 N × 0.1 m = 0.196 N·m
  3. Convert to Hobbyist Units (kg·cm):
    0.196 N·m / 0.0980665 = 2.0 kg·cm
  4. Apply the 3x Safety Factor:
    2.0 kg·cm × 3 = 6.0 kg·cm minimum required stall torque.

Based on this calculation, a standard micro servo like the SG90 (rated at 1.8 kg·cm) will instantly stall and overheat. The TowerPro MG996R (13 kg·cm) will handle the load easily with plenty of headroom for the weight of the arm itself. If the arm needs to move rapidly (high acceleration), bump up to a 5x safety factor (10 kg·cm required) and select the DS3218 digital servo for its superior transient torque response.

Wiring and Terminal Identification: The PCA9685 Breakout

Because the Raspberry Pi lacks sufficient hardware PWM channels and operates at 3.3V logic, you must use an I2C PWM driver. The NXP PCA9685 is the industry standard for this task. It takes I2C commands from the Pi and generates rock-solid, jitter-free 12-bit PWM signals for up to 16 servos independently.

When wiring the PCA9685 breakout board (commonly sold by Adafruit and generic clone manufacturers), you must pay strict attention to the terminal identification. Mixing up the logic power and the motor power is the fastest way to destroy your Raspberry Pi.

Logic Side Wiring (Raspberry Pi to PCA9685)

  • VCC: Connect to Raspberry Pi Pin 1 (3.3V). This powers the I2C logic chip on the breakout board.
  • GND: Connect to Raspberry Pi Pin 6 (Ground).
  • SDA: Connect to Raspberry Pi Pin 3 (GPIO 2 / I2C SDA).
  • SCL: Connect to Raspberry Pi Pin 5 (GPIO 3 / I2C SCL).

Power Side Wiring (External PSU to PCA9685 Servo Terminals)

The large green screw terminals on the left side of the board are strictly for motor power. They are not electrically connected to the Pi’s power rails.

  • V+ (Motor Power): Connect to the positive terminal of an external 5V or 6V DC power supply. A 5V 10A switching power supply is ideal for driving multiple high-torque servos.
  • GND (Motor Ground): Connect to the negative terminal of the external power supply. Critical: You must also run a jumper wire from this external GND to the Raspberry Pi’s GND to establish a common ground reference for the PWM signals.
Back-EMF Warning: Never connect the servo power V+ terminal to the Raspberry Pi’s 5V GPIO pin (Pin 2 or 4). When a servo motor decelerates or stalls, it generates back-electromotive force (Back-EMF) voltage spikes that can exceed 6V. Feeding this back into the Pi’s 5V rail will bypass the onboard polyfuse and permanently destroy the Pi’s power management IC.

Failure Signatures: Diagnosing Hum, Overheat, and Stall

Even with correct wiring and sizing, servos exhibit distinct failure signatures when pushed outside their operational envelopes. Recognizing these symptoms on the bench will save you from burning out expensive hardware. For deeper integration and wiring diagrams, the Adafruit PCA9685 Assembly and Usage Guide remains the definitive reference for I2C setup and Python library implementation.

1. Jitter and Audible Humming

Symptom: The servo shaft vibrates rapidly at a standstill, emitting a high-pitched hum, even when the Pi is sending a static PWM position command.

Root Cause: This is almost always caused by power supply ripple or missing decoupling capacitance, rather than software jitter (assuming you are using the PCA9685). High-torque servos draw current in sharp, microsecond spikes as the internal DC motor commutates.

The Fix: Solder a large electrolytic capacitor (1000µF, 10V or higher) directly across the V+ and GND screw terminals on the PCA9685 board. This acts as a local energy reservoir, smoothing out the voltage dips. If the hum persists, measure the voltage at the servo plug with an oscilloscope; if you see >0.2V ripple, upgrade to a higher-amperage power supply.

2. Overheating and Gear Stripping

Symptom: The servo casing becomes too hot to touch (>60°C) within minutes, and the motor eventually stops responding or makes a grinding noise.

Root Cause: The servo is being commanded to a position that is mechanically blocked (a hard stop). When an analog servo cannot reach its target position, the internal error amplifier drives the DC motor at 100% duty cycle continuously. It draws maximum stall current (e.g., 2.5A for an MG996R) indefinitely, melting the plastic output gears and burning the motor windings.

The Fix: Implement software limits in your Python/C++ control loop to prevent the servo from being commanded past its physical mechanical boundaries. If the application requires holding against a constant physical force, switch to a stepper motor with a TMC2209 driver, which can reduce holding current via software configuration to prevent overheating.

3. Stalling and Clicking Under Load

Symptom: The servo moves fine with no load, but clicks loudly and fails to move when the mechanical payload is attached.

Root Cause: Severe voltage sag. The power supply cannot deliver the transient current required to overcome the payload's inertia. According to Pololu’s RC servo specifications, a standard high-torque servo requires a minimum of 4.8V at the terminal to achieve its rated torque.

The Fix: Measure the DC voltage directly at the servo’s PWM plug while it is under load. If the voltage drops below 4.8V, your power supply is undersized, or your wiring is too thin. Upgrade the power wires feeding the PCA9685 screw terminals to at least 18 AWG silicone wire to minimize voltage drop, and ensure your power supply can deliver at least 2.5 amps per connected high-torque servo.