Can't make a servo to work on the XIAO ESP32S3

Hi! I’m trying to control a countinuous servo (FEETECH FS90R) with the XIAO ESP32S3.

The wiring is simply GND to servo -, 3.3v to servo +, D10 / GPIO9 to servo pwm. Convenient because it’s aligned with the servo connector.

This particular servo works without issues on an Arduino UNO board (on 3.3v too), but I can’t make it to work on the XIAO ESP32S3.

I tried the ESP32 Servo library with the following code :

#include <ESP32Servo.h>

Servo servo;

void setup() {
  servo.attach(9);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  servo.write(700);
  delay(2000);

  digitalWrite(LED_BUILTIN, LOW);
  servo.write(1500);
  delay(2000);

  digitalWrite(LED_BUILTIN, HIGH);
  servo.write(2300);
  delay(2000);

  digitalWrite(LED_BUILTIN, LOW);
  servo.write(1500);
  delay(2000);
}

And the ESP32 PWM, Servo, Easing and Tone Library with the following code:

#include <Servo.h>

Servo servo = Servo();
int pin = 9;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  servo.write(pin, 700);
  delay(2000);

  digitalWrite(LED_BUILTIN, LOW);
  servo.write(pin, 1500);
  delay(2000);

  digitalWrite(LED_BUILTIN, HIGH);
  servo.write(pin, 2300);
  delay(2000);

  digitalWrite(LED_BUILTIN, LOW);
  servo.write(pin, 1500);
  delay(2000);
}

But nothing happens, am I missing something?

I tried another GPIO, and powering it from the 5v output but no luck.

Thanks for your help.

Hi there,
try pin (2) D1, GPIO 2
Whoa, AFAIK the most they can sync is 45.ma for the GPIO’s for ESP32’s
Can you try it with JUST the PIN number of the Xiao also, which BSP package are you using?
First & 2nd line of the compiler output?
LMK
HTH
GL :slight_smile: PJ :v:

Note; on Servo LIB
All pin numbers are allowed,
but only pins 2,4,12-19,21-23,25-27,32-33 are recommended.

Any update on this? I’m having an issue with my C3

Try to use GPIO5, GPIO6, or GPIO10 instead.

servo.attach(5); // Use GPIO5 instead of GPIO9

Unlike Arduino, the ESP32 requires specifying the correct PWM properties.
Modify your ESP32Servo library code as follows:

#include <ESP32Servo.h>

Servo servo;

void setup() {
  servo.attach(5, 500, 2500); // GPIO5, min 500us, max 2500us
}

void loop() {
  servo.writeMicroseconds(700); // Slow reverse
  delay(2000);

  servo.writeMicroseconds(1500); // Stop
  delay(2000);

  servo.writeMicroseconds(2300); // Fast forward
  delay(2000);

  servo.writeMicroseconds(1500); // Stop
  delay(2000);
}

The FEETECH FS90R is rated for 4.8V–6V operation. It is better to use a separate power supply.
For your convenience, you can make a XIAO carrier PCB.