The standard Arduino Servo library was written for AVR boards. On an ESP32 use the ESP32Servo library.
What the message means
The ESP32 makes PWM with its own LEDC hardware, so the timer tricks of the AVR library do not apply.
Fix it in this order
- Install ESP32Servo from the Library Manager and include ESP32Servo.h.
- Call attach(pin, minUs, maxUs) with the pulse range of your servo.
- Use an output-capable GPIO. GPIO 34 to 39 are input only.
- Power the servo from its own 5 V supply and join the grounds.
- Allocate timers before attaching several servos, if the library asks you to.
Why it happens
The Arduino Servo library is written for AVR boards and may fail to compile or work on the ESP32. The ESP32Servo library gives the same style of calls using the ESP32 PWM hardware.
Install ESP32Servo from the Library Manager, replace the include with ESP32Servo.h, and attach the servo to an output-capable pin.
#include <ESP32Servo.h>
Servo s;
void setup() { s.attach(18); } // choose an output-capable pin
void loop() { s.write(90); }
Example sketch: change pins and values for your own wiring. It has not been bench-tested on your hardware.
If you see this, do this
| You see | Do this |
|---|---|
| Fails to compile | Wrong library. |
| Compiles, no movement | Pin or power. See the servo page. |
Related
servo does not move on ESP32, input-only pins.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.