Servo control on ESP32 S2

I am trying to interface Servo motor with ESP32 S2 and ending up with this error:
[Error] Exit with code=1.

How can I resolve this error? Is this because of the library used?

The library I’m using is ESP32Servo. Is there a different library that I need to use for ESP32 S2 If so where can I find it? Please help me with your answers.

Thank you

Why not post more of the error message? There are many things that cause the error code you posted.

ESP32Servo is an ESP32 servo library that you can use to connect with and control servos.

1 Like

Hi, @enthusiastsr
Welcome to the forum.

Please read the post at the start of any forum , entitled “How to use this Forum”.

To add code please click this link;

Have you looked at t his site, the first example code they give should be relevant.

Tom… :grinning: :+1: :coffee: :australia:

1 Like

There is a problem with ESP32S2, which may affect you, if your using the latest ESP32S2 code, PWM does not work properly;

1 Like

Better check out something with your servo voltage supply and code with the libraries of servo and the esp board that you are using. Even check out the compatibility

1 Like

That issue is with the ledc API. The ESP32’s MCPWM API does not have that issue.

1 Like

I am able to make it work for Arduino IDE but when I use the same program for VS Code I again get the same error. Output window exits with the error that looks like below:

DEBUG StatusLogger Stopping LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@b6ffe0]

DEBUG StatusLogger Stopping LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@b6ffe0]…

TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868]

TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=StatusLogger]

TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=ContextSelector]

TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=Loggers,name=]

TRACE StatusLogger Unregistering 2 MBeans: [org.apache.logging.log4j2:type=af3868,component=Appenders,name=RollingFile, org.apache.logging.log4j2:type=af3868,component=Appenders,name=Console]

TRACE StatusLogger Unregistering but no MBeans found matching ‘org.apache.logging.log4j2:type=af3868,component=AsyncAppenders,name=*’

TRACE StatusLogger Unregistering but no MBeans found matching ‘org.apache.logging.log4j2:type=af3868,component=AsyncLoggerRingBuffer’

TRACE StatusLogger Unregistering but no MBeans found matching ‘org.apache.logging.log4j2:type=af3868,component=Loggers,name=*,subtype=RingBuffer’

TRACE StatusLogger Stopping XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/Arduino/lib/pde.jar!/log4j2.xml]…

TRACE StatusLogger XmlConfiguration notified 2 ReliabilityStrategies that config will be stopped.

TRACE StatusLogger XmlConfiguration stopping 1 LoggerConfigs.

TRACE StatusLogger XmlConfiguration stopping root LoggerConfig.

TRACE StatusLogger XmlConfiguration notifying ReliabilityStrategies that appenders will be stopped.

TRACE StatusLogger XmlConfiguration stopping remaining Appenders.

DEBUG StatusLogger Shutting down RollingFileManager C:\Users\rud311\AppData\Local\Arduino15/logs/application.log

DEBUG StatusLogger Shutting down RollingFileManager C:\Users\rud311\AppData\Local\Arduino15/logs/application.log

DEBUG StatusLogger All asynchronous threads have terminated

DEBUG StatusLogger RollingFileManager shutdown completed with status true

DEBUG StatusLogger Shut down RollingFileManager C:\Users\rud311\AppData\Local\Arduino15/logs/application.log, all resources released: true

DEBUG StatusLogger Appender RollingFile stopped with status true

DEBUG StatusLogger Shutting down OutputStreamManager SYSTEM_ERR.false.false

DEBUG StatusLogger Shut down OutputStreamManager SYSTEM_ERR.false.false, all resources released: true

DEBUG StatusLogger Appender Console stopped with status true

TRACE StatusLogger XmlConfiguration stopped 2 remaining Appenders.

TRACE StatusLogger XmlConfiguration cleaning Appenders from 2 LoggerConfigs.

DEBUG StatusLogger Stopped XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/Arduino/lib/pde.jar!/log4j2.xml] OK

DEBUG StatusLogger Stopped LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@b6ffe0] with status true

[Error] Exit with code=1

Servo Supply oltage is 5V (generally given 4V to 7V). The compatibility seems to be fine because the program and hardware are both working in Arduino IDE. I get the error only in VS Code and still not sure why is this happening.

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose “copy for forum”
  3. paste clipboard into write-window of a posting

best regards Stefan