Why does my servo jitter or not move properly on ESP32?

Servos are “simple” until you power them wrong. On ESP32, servo jitter is almost always power or grounding, not the servo library.

The #1 fix: power the servo separately

  1. Use a dedicated 5V supply for the servo (not the ESP32 3.3V pin, and usually not the dev board's tiny regulator).
  2. Connect servo GND to ESP32 GND (shared ground).
  3. Only connect the signal wire to the ESP32 GPIO.

Quick test

If the servo jitters more when it's under load (or when WiFi turns on), that's a power sag/noise problem.

Other common causes

  • Bad breadboard rails (loose contacts = noisy power).
  • Long signal wires routed next to motor/LED power.
  • No bulk capacitor near the servo supply (try 470µF+ across 5V/GND near the servo).
  • Wrong pin choice or conflicting peripherals. Pick a normal GPIO and avoid boot-strapping pins until it works.

Minimal servo sweep (baseline)

This uses the ESP32Servo library style. If this jitters, your wiring/power is the issue.

esp32_servo_baseline.ino
cpp
#include <ESP32Servo.h>

Servo s;
const int servoPin = 18; // pick a normal GPIO

void setup() {
  s.setPeriodHertz(50);
  s.attach(servoPin, 500, 2500); // min/max pulse us
}

void loop() {
  for (int a = 0; a <= 180; a += 5) {
    s.write(a);
    delay(30);
  }
  for (int a = 180; a >= 0; a -= 5) {
    s.write(a);
    delay(30);
  }
}
Bottom line

Servo jitter on ESP32 is usually power and grounding. Use a dedicated 5V supply, share ground, add a capacitor near the servo, and keep wiring short.

Related: USB vs external power · External power safely · ESP32 brownout resets