Servos via ESP32 Suddenly Stopped Working

Is it possible that some kind of update may have affected servos from working with Nano ESP32 modules? I'm going nuts trying to figure out why all my servos suddenly stopped working. I tested the servos with Raspberry Pi 5, which work fine, but no batter what I try, they will no longer with any of the Arduino Nano ESP32 modules I have (I tried 3). I also tried a couple of other ESP32 servo libraries just to be sure that a code change in the library I was using (ESP32Servo by Kevin Harrington) wasn't causing the problem, but the other ESP32 servo libraries I tried did not work either. I am testing the modules in the simplest way on a breadboard, and have tested all the connections and voltages with a VOM. I also tried using different pins for the PWM signal, to no avail. And the servo is getting the proper voltage from a power supply, the grounds between power supply, Nano, and servo are connected together, and the Nano is powered via USB-C from Windows computer. I'm on v2.3.6 of the Arduino IDE. Here is one basic sketch I'm using. I've also tried esp32-hal-ledc. If you have any thoughts, please mention them as I am going out of my mind why this stopped working! Thanks much for any help!

#include <ESP32Servo.h>
 
 Servo myservo;
 int pos = 0;
 int servoPin = 4;
 
 void setup() {
  // Allow allocation of all timers
  ESP32PWM::allocateTimer(0);
  ESP32PWM::allocateTimer(1);
  ESP32PWM::allocateTimer(2);
  ESP32PWM::allocateTimer(3);
  myservo.setPeriodHertz(50);    // standard 50 hz servo
  myservo.attach(servoPin, 1000, 2000);
}
 
void loop() {
  myservo.write(0);
  delay(1000);
  myservo.write(45);
  delay(1000);
  myservo.write(90);
  delay(1000);
}

When did it work, when did it stop working, and what did you do in between?

Not long ago, the Espressif Corp updated the Arduino core and some libraries, which broke a lot of existing code.

If you updated your setup and recompiled the code, that may explain the problem.

Otherwise, suspect a problem with the wiring or servo power supply, which you did not adequately describe. Please post a wiring diagram, with all pins, parts and connections clearly identified and labeled. Hand drawn is fine.

Thanks much for the response. Since a picture means a thousand words...

Hot from power supply goes directly to positive lead of servo motor.
Ground from power supply goes both to Nano ground and servo motor negative lead.
A GPIO (currently pin 4) goes to PWM lead of servo.

Keep in mind that if I connect the same ground and PWM leads to a Raspberry Pi, everything works fine. I have been testing other areas of my project, so haven't tried the servo part of it for at least one week. I did notice that there were some updates to some Arduino libraries and possibly other components of the IDE in between. As far as what I did in between, I don't believe I used the specific Nano module for any other testing other than for the servo part, and I've since uploaded many times just to try to determine why the servos don't work anymore. As I mentioned already, I have three Arduino Nano ESP32's that I all tried, which all fail. I also ordered another Nano ESP32, another brand ESP32, and a Nano Uno, to see if it may be an issue with all my ESP32 modules, or with the ESP32 implementation, which is why I ordered an Uno for testing.

Not in this case, I am afraid as you cannot see how the components are connected and powered

A wiring diagram would be clearer. A 'photo of a hand drawn circuit is good enough

If parts, pins and connections are clearly labeled.

Alligator clips are not known for their reliability. Use your multimeter to determine whether the servo is being powered, and at what voltage.

OK, here you go. About as simple as it gets.

I assure you that the connections via the alligator clips are fine. As I originally stated, I made sure connections are good and tested voltage to a conducting metal piece inside the plastic connector further toward the servo. I also tested continuity of every wire, and even replaced all wires just to be sure. I also tested two other servo motors (and two other Nano ESP32's) for completeness. Just so you understand, I have a fair amount of experience with electronics and software development, so do understand a thing or two. I also want to reiterate that if I keep everything exactly as it is and pull the ground and PWM leads from the breadboard and attach them to my Raspberry Pi, it works fine.

Thank you!

Also for completeness, I had Serial.println statements in the code to verify that the code was getting uploaded properly. I also tried two different computers both running Windows 11 as I continued to scratch my head trying to figure out what went wrong.

Thanks for the assurance that the alligator clips are making excellent connections.

See post #2 regarding the ESP32 problem and please answer the first question.

I apologize, but I don't see another question. If you are referring to this: "When did it work, when did it stop working, and what did you do in between?", I thought I answered that already.

I'll try to clarify:

When did it work, when did it stop working, and what did you do in between?

It worked fine until about a week to two ago. I was working on another part of my overall project, and did not touch or do anything with that Arduino or servo until a couple of days ago, where I started to work on the servo part of the project again. I noticed that there were some updates via the Arduino IDE, at which point it stopped working. I do not know if the updates had anything to do with the issue or not, but I tried uploading the same code to three Arduino ESP32 modules, all which do not work. Other than that, I did not do anything else in between except try to figure out this issue. By the way, for the same of being anal, I once again popped a Raspberry Pi in place without touching anything else, which worked fine.

Not long ago, the Espressif Corp updated the Arduino core and some libraries, which broke a lot of existing code.

If you updated your setup and recompiled the code, that may explain the problem.

I did nothing with the setup, but have uploaded code (as in the example I provided earlier) many times to try to figure out the issue. If there is an Espressif issue, how do I verify that, and is there a way to revert to a previous version of that code? I honestly don't know anything about Espressif.

Otherwise, suspect a problem with the wiring or servo power supply, which you did not adequately describe. Please post a wiring diagram, with all pins, parts and connections clearly identified and labeled. Hand drawn is fine.

I certainly don't belief that there an a wiring, servo, or power supply issue, as it worked before and works fine with a Raspberry Pi. I've also verified voltage, continuity, and have used multiple servos, and have changed wires just to be sure.

You can install old versions of the libraries and board definitions. Or perhaps you need to update some libraries to match the new board definitions.

I haven't worked with ESP32 recently, or encountered the ESP32 update problem so don't know exactly how to do that, but there are a number of posts on this forum and others that document the problems and describe what they did to solve it.

I was able to get it working again.

First I tried reverting to the previous version of the Arduino Nano ESP32 board, which made no difference.

Then I removed several libraries which I was no longer using, and reverted to the previous version of the ESP32Servo library which DID solve the problem.

I then updated the board back to the current version: still works.
Lastly I updated the ESP32Servo library to the current version: still works.

What I should have done is to remove one unused library at a time and not revert the ESP32Servo library at the same time, but I was getting frustrated and impatient!

My guess is that either something from one of the unused libraries was interfering in some way, or the ESP32Servo library become corrupted.

Anyway, I truly appreciate the help! I now understand how easy it is to manage versions of boards and libraries, so will have that in my basket of tools going forward.

Thanks much!

Actually, it appears I misspoke. It does appear to be an issue with the latest version of ESP32Servo. When I first uploaded the code with the latest version it worked, but then failed once the Nano ESP32 module was restarted. I'm not sure I understand why that happens, but it does in the two times I tried. That does not happen with the previous version.

And it doesn't explain why I could not get two other ESP32 servo libraries to work.