i'm trying to connect a servomotor with esp8266MOD 12-f and the "ESP32Servo.h" library but i get error codes that i dont know how to solve.
this is the code:
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
// Recommended PWM GPIO pins on the ESP32 include 2,4,12-19,21-23,25-27, 32
int servoPin = 13;
void setup() {
myservo.setPeriodHertz(50);
myservo.attach(servoPin);
}
void loop() {
myservo.write(0);
delay(2000);
myservo.write(180);
delay(2000);
}
and the error message i am getting:
Sketch uses 257245 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 21580 bytes (6%) of dynamic memory, leaving 306100 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM5
A serial exception error occurred: Cannot configure port, something went wrong. Original message: PermissionError(13, 'Un p�riph�rique attach� au syst�me ne fonctionne pas correctement.', None, 31)
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool.py latest documentation
Failed uploading: uploading error: exit status 1
The code is not the problem, the problem is the communication with the ESP.
Try pressing the "flash" or "ioi" button on the board (if it has one) before uploading the .
Can you upload the blink example sketch successfully? If not, that proves the problem is not your code (although there could be problems with your code, but right now they are irrelevant!)
WARNING: library ESP8266_ISR_Servo claims to run on esp8266 architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
In file included from c:\Users\eytan kars\OneDrive\Documents\Arduino\libraries\ESP8266_ISR_Servo\src/ESP8266_ISR_Servo.h:48,
from C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:13:
c:\Users\eytan kars\OneDrive\Documents\Arduino\libraries\ESP8266_ISR_Servo\src/ESP8266_ISR_Servo.hpp:49:4: error: #error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
^~~~~
In file included from c:\Users\eytan kars\OneDrive\Documents\Arduino\libraries\ESP8266_ISR_Servo\src/ESP8266_ISR_Servo.hpp:86,
from c:\Users\eytan kars\OneDrive\Documents\Arduino\libraries\ESP8266_ISR_Servo\src/ESP8266_ISR_Servo.h:48,
from C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:13:
c:\Users\eytan kars\OneDrive\Documents\Arduino\libraries\ESP8266_ISR_Servo\src/ESP8266FastTimerInterrupt.h:46:4: error: #error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
^~~~~
exit status 1
Compilation error: exit status 1
thanks got it. Got one step further, not i got another problem
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:15:1: error: 'Servo' does not name a type
15 | Servo myservo; // create servo object to control a servo
| ^~~~~
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino: In function 'void setup()':
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:20:3: error: 'myservo' was not declared in this scope
20 | myservo.attach(2); // attaches the servo on GIO2 to the servo object
| ^~~~~~~
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino: In function 'void loop()':
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:28:5: error: 'myservo' was not declared in this scope
28 | myservo.write(180); // tell servo to go to position in variable 'pos'
| ^~~~~~~
C:\Users\eytan kars\AppData\Local\Temp\.arduinoIDE-unsaved20231012-22812-cefv25.31cnu\sketch_nov12a\sketch_nov12a.ino:32:5: error: 'myservo' was not declared in this scope
32 | myservo.write(360); // tell servo to go to position in variable 'pos'
| ^~~~~~~
exit status 1
Compilation error: 'Servo' does not name a type