Servo Control with NANO ESP32

Hi, I am trying to control a servo motor with the Nano ESP32. For some reason I don't understand, it is not working. I also tried connecting the motor to another Arduino to check if it was faulty, but it wasn't. I uploaded the sketch directly using the Arduino IDE instead of the cloud-based one for IoT projects (just to see if my networking code was the issue), but that didn’t help either. I also tried a different servo library specifically for the ESP32, but it's still not working—the servo doesn't move.

Here is the code I am trying to use:

#include <ESP32_Servo.h>

Servo mioServo;

void setup() {
  mioServo.attach(9, 500, 2400);
}

void loop() {
  mioServo.write(0);
  delay(1000);
  mioServo.write(90);
  delay(1000);
  mioServo.write(180);
  delay(1000);
}

How is the servo powered ?

What exactly do you mean by "not working"

Lack of knowlege and experience!

As reply #2, please post schematics showing all connections and powering.

Will you be leaving this topic unfinished like all your other topics? Maybe the servo or the MCU you are using "stopped working" four hears ago?

The servo is connected to pin nine of the arduino nano and its powered through the vusb of the arduino. By not working I mean that I can freely move the horn while it’s supposed to hold the selected position, it also doesn’t move at all when I send it commands and it looks like it’s not powered on.

I apologize for the delay in my answers, I only got a limited amount of time every day for these projects because of my pretty full time schedule. I will try to post the results obtained after trying your suggestions from now on.

As for the servo I bought it a few years ago but it’s completely fine (I tried it with another mcu and it moves according to the selected angles in the sketch).
And for the nano esp32 even though it’s not brand new and it’s been used before on other projects it has proven to correctly connect to my network and to perform basic tasks like controlling leds and to communicate over serial with other mcu.
However I never tried to use it with a servo but from what I read on the datasheet of the board it looked like it could be done like on every other arduino. As that turned out not to be true with my setup there must be an error somewhere.
I am asking for help as @Railroader said I am lacking experience in this instance.

I also just tried following this tutorial using an external breadboard power supply but it is still not responding

I found the solution: I had an outdated library. I simply downloaded the latest version of the ESP32 Servo Library, and it's now working perfectly with the same sketch and schematics posted earlier.

Thanks, everyone.