Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

SG90 servo with Seeed XIAO ESP32S3 — ESP32Servo

Sweep an SG90 servo from D0 of a Seeed XIAO ESP32S3 with ESP32Servo, powered from its own 5 V supply — e.g. for a Sense camera pan mount.

Arduino C++Verified — core esp32 3.3.12, ESP32Servo 3.2.1, 3 Nov 2026Compile-only

Community draft — report a mistake

An SG90 on a XIAO ESP32S3 — perhaps panning a Sense camera — needs only a signal wire from D0. Its power comes from a separate 5 V supply, with the ground shared.

The sketch sweeps the servo 0–180° and back in 30° steps.

Wiring

XIAO ESP32S3Only the pins used are shown · 3.3 V logic5 V 1 A supplySG90 micro servo (9 g)+5VGNDD0GNDSIGVCCGND
Also needed: 5 V 1 A supply, 470 µF capacitor across the servo supply.
Every connection
XIAO ESP32S3SG90 micro servo (9 g)WireNotes
D0SIGorange
5 V 1 A supply · +5VVCCred
5 V 1 A supply · GNDGNDbrown
GNDGNDblackCommon ground.

4.8–6 V (several hundred mA while moving or stalled) part, 3.3 V board. The signal input is happy with 3.3 V logic, so ESP32 and Pico drive it directly. On ESP32 use the ESP32Servo library — the standard Servo library is for AVR and RP2040.

Board quirks

  • D0 is GPIO1, boot-safe. Avoid D6 (TX — boot messages twitch the servo) and D2 (strapping).
  • A servo on the XIAO’s own 5V pin works only on USB and only unloaded; the Sense board’s camera adds to the load, so stall current resets the board. Use a separate supply.
  • ESP32Servo drives the S3’s LEDC PWM. Two servos on D0/D1 make a pan-tilt head for the Sense camera.

Code

servo-xiaos3.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// SG90 servo on a Seeed XIAO ESP32S3 with ESP32Servo.
// SIG → D0 (GPIO1). Servo VCC/GND → a separate 5 V supply; its GND → XIAO GND.
#include <ESP32Servo.h>

Servo servo;

void setup() {
  Serial.begin(115200);
  uint32_t t0 = millis();
  while (!Serial && millis() - t0 < 3000) {}
  servo.setPeriodHertz(50);
  servo.attach(D0, 500, 2400);
  Serial.println("Sweeping 0-180 degrees on D0");
}

void loop() {
  for (int a = 0; a <= 180; a += 30) {
    servo.write(a);
    Serial.printf("Angle %d\n", a);
    delay(500);
  }
  for (int a = 180; a >= 0; a -= 30) {
    servo.write(a);
    Serial.printf("Angle %d\n", a);
    delay(500);
  }
}

Library: Servo (Arduino) — compiled with ESP32Servo 3.2.1.

Expected serial output

Serial Monitor · 115200Output
Sweeping 0-180 degrees on D0
Angle 0
Angle 30
Angle 60

Common errors

Servo jitters

Supply noise. Full fix.

“Servo.h” architecture error

Use ESP32Servo. Full fix.

↑↓ to move · Enter to open