PWM problem with GPIO25 on ESP32-WROOM-32D

Hi,
I use one PWM servo motor MG90S (0-170 degrees) and if I turn on the ESP32-WROOM-32D, I will set 0 degrees without any problems, I will also set 170, but I always have to reset the GPIO25. The servo motor starts to rotate spontaneously. The GPIO25 is a PWM pin.
On ESP32 I use wifi for webserver, but it should connect to ADC2 and not to PWM, which should work.

I perform measurements only every 10 minutes and yet the 170 to 0 degree command did not work properly. It remained at 170 degrees.
I use this library: https://github.com/RoboticsBrno/ServoESP32

      // servo ON
      Serial.println("SERVO 170");
      servo1.attach(SERVO_PIN, Servo::CHANNEL_NOT_ATTACHED, 0, 170);
      for(int posDegrees = 0; posDegrees <= 170; posDegrees+=5) {         
          servo1.write(posDegrees);
          Serial.println(posDegrees);
          delay(10);
      }
      gpio_reset_pin(SERVO_PIN); // off PWM
      
// we measure 

      // servo OFF
      servo1.attach(SERVO_PIN, Servo::CHANNEL_NOT_ATTACHED, 0, 170);
      for(int posDegrees = 170; posDegrees >= 0; posDegrees-=5) {
          servo1.write(posDegrees);
          Serial.println(posDegrees);
          delay(10);
      }
      gpio_reset_pin(SERVO_PIN); // vypneme PWM

How is the servo powered ?

The whole code please. Snippets do not troubleshoot well.

Analog to Digital Converter (ADC) - ESP32 - — ESP-IDF Programming Guide latest documentation (espressif.com)

Power is 5V.

Video with problem:
https://youtu.be/MY3jy4v96HE?t=5

The code used, which is recorded on video:

#include <Servo.h>

static const int servoPin = 25;

Servo servo1;

void setup() {
    Serial.begin(115200);
    servo1.attach(servoPin);
}

void loop() {
    for(int posDegrees = 0; posDegrees <= 170; posDegrees++) {
        servo1.write(posDegrees);
        Serial.println(posDegrees);
        delay(20);
    }

    for(int posDegrees = 170; posDegrees >= 0; posDegrees--) {
        servo1.write(posDegrees);
        Serial.println(posDegrees);
        delay(20);
    }
}

post a pic of your project.

You are actually powering the servo through/from the ESP32 board via the USB? The ESP32's steering diode will be damaged.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.