Skip to content
ESP32 sketch using direct GPIO pins with the ESP32Servo library

Direct GPIO

The simplest setup — connect servos directly to GPIO pins on the ESP32.

Hardware

  • ESP32 development board
  • Up to 3 servos
  • Servo power supply (5–6V recommended, separate from ESP32)

Wiring

ServoGPIO Pin
Servo 1GPIO 2
Servo 2GPIO 3
Servo 3GPIO 4

Connect each servo's signal wire to the corresponding GPIO pin. Power the servos from an external 5–6V supply — do not power servos directly from the ESP32's 3.3V or 5V pin, as they draw too much current.

Libraries

Install via Arduino Library Manager:

  • ESP32Servo — provides PWM-based servo control on ESP32 GPIO pins

Configuration

The sketch supports 3 servo channels (IDs 1–3). To change the GPIO pins, edit the pin definitions at the top of the sketch.

Source

servomote-esp32 on GitHub