# Esp 32s servo not working correctly

**URL:** <https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820>\
**Category:** Programming\
**Created:** [September 25, 2023, 12:30am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820 "2023-09-25T00:30:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arduino\_1123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/arduino_1123/32/1002958_2.png) [@arduino\_1123](https://forum.arduino.cc/u/arduino_1123)\
**Post date:** [September 25, 2023, 12:30am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/1 "2023-09-25T00:30:31Z")

</div>

Hi im trying to use the servo with my esp32s but it does not work and the error code im getting is the following:

```arduino
In file included from C:\Users\hacke\AppData\Local\Temp\.arduinoIDE-unsaved2023824-24352-n4hf7f.uateh\01-SimpleServo\01-SimpleServo.ino:1:
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:68:81: error: call to non-'constexpr' function 'const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]'
     static const int TIMER_RESOLUTION = std::min(16, SOC_LEDC_TIMER_BIT_WIDE_NUM);
                                                                                 ^
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h: In member function 'T ServoTemplate<T>::mapTemplate(T, T, T, T, T) const':
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:28: error: 'is_floating_point_v' is not a member of 'std'
         if constexpr (std::is_floating_point_v<T>) {
                            ^ ~~~~~~~~~~~~~~~~~~
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:28: note: suggested alternative: 'is_floating_point'
         if constexpr (std::is_floating_point_v<T>) {
                            ^ ~~~~~~~~~~~~~~~~~~
                            is_floating_point
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:49: error: expected primary-expression before '>' token
         if constexpr (std::is_floating_point_v<T>) {
                                                 ^
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:50: error: expected primary-expression before ')' token
         if constexpr (std::is_floating_point_v<T>) {
                                                  ^

exit status 1

Compilation error: exit status 1

```

I do not know the reason for this and any help or suggestion would be major. Thank you and hope you guys are having a good day.

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [September 25, 2023, 12:49am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/2 "2023-09-25T00:49:16Z")

</div>

> [@arduino\_1123](#):
>
> Hi im trying to use the servo with my esp32s but it does not work

Of course not as You have not gotten the code downloaded.

You need to use a correct syntax. More....

Please read and use this topic: [How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966)

---

<div class="post-metadata">

**Author:** ![arduino\_1123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/arduino_1123/32/1002958_2.png) [@arduino\_1123](https://forum.arduino.cc/u/arduino_1123)\
**Post date:** [September 25, 2023, 12:54am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/3 "2023-09-25T00:54:52Z")

</div>

i do have the library downloaded and the code i used was part as the example.

```arduino
#include <Servo.h>

static const int servoPin = 13;

Servo servo1;

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

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

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

```

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [September 25, 2023, 1:35am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/4 "2023-09-25T01:35:34Z")

</div>

> [@arduino\_1123](#):
>
> I do have the library downloaded and the code i used was part as the example.

Why don't You follow and respond to the last line advice in reply #2?  
You need to read the full reply, not only one line.

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [September 25, 2023, 3:30am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/5 "2023-09-25T03:30:06Z")

</div>

Servo.h Library is not supported by ESP32.

Include the attached Libray with the IDE and then upload the following example taken from IDE's Examples. Report the result. I attached a very old SG90 Servo, but it turns intermittently. Use seperate 5V power supply as the Servo takes about 100 - 250 mA during movement with load; whereas, ESP32's pin can supply max 40 mA (recommended use is 20 mA).

```arduino
#include <ESP32Servo.h>

Servo myservo; // create servo object to control a servo
int pos = 0;

int servoPin = 13;

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); // attaches the servo on pin 18 to the servo object
}

void loop() 
{
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(15); // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(15); // waits 15ms for the servo to reach the position
  }
}

```

[ESP32Servo-0.13.0.zip](https://forum.arduino.cc/uploads/short-url/sGD6yztkNnQoJeCxYoBj7zroz6E.zip) (52.6 KB)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 23, 2024, 3:30am UTC](https://forum.arduino.cc/t/esp-32s-servo-not-working-correctly/1171820/6 "2024-03-23T03:30:39Z")

</div>

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