Arduino IDE error unexpected

anyone knows what happen to arduino ide, because in morning it still oke to compile, but why right now i got this problem? i dont even have any variabel i named it ledcDetach. im sorry if my question confusing, but im beginner

Please post your code (don't forget the code tags).
Please post the complete error message (using code tags as well).

I'm not an ESP32 user and more than likely can't help you further.

Not a variable, it's a function in a library.

Note:
As I suspect a code issue and not an IDE issue, your topic has been moved to a moren suitable location on the forum.

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6X6VUX9jm"
#define BLYNK_TEMPLATE_NAME "Smart livestock turtle dove"
#define BLYNK_AUTH_TOKEN "(redacted)"

#include <WiFi.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <HX711.h>
#include <ESP32Servo.h>

//roof
#define s2pin 19
//minum
#define WATER_LEVEL_PIN 34
#define r1pin 16
//pakan
#define DOUT 33 
#define SCK 32
#define s1pin 21
//suhu
#define r2pin 17

char ssid[] = "X";
char pass[] = "2010314047";
//roof
const int sensorPin = 35;
Servo s2;
WiFiUDP wip;
const long utcOffsetInSeconds = 25200; 
NTPClient timeClient(wip, "pool.ntp.org", utcOffsetInSeconds, 60000);
//suhu
DHT d(4, DHT22);
//pakan
HX711 s;
Servo s1;
float cf = 2380; //Hasil Kalibrasi
int w;
//minum
float ps = 4.0 ;

void rlc(void*pvParameters);//load cell
void rwl(void*pvParameters);//water level
void rds(void*pvParameters);//dht22
void rrs(void*pvParameters);//raindrop

void setup()
{
  // Debug console
  Serial.begin(9600);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  timeClient.begin();
  //suhu
  d.begin();
  pinMode(r2pin, OUTPUT);
  //pakan
  s1.attach(s1pin);
  s.begin(DOUT, SCK);
  s.set_scale();
  s.tare();  //Reset the scale to 0
  long zf = s.read_average(); //Get a baseline reading
  //roof
  s2.attach(s2pin);
  //minum
  pinMode(r1pin, OUTPUT);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  digitalWrite(r1pin, HIGH);
  digitalWrite(r2pin, HIGH);
  xTaskCreate(rlc, "PAKAN", 10000, NULL, 1, NULL);
  xTaskCreate(rds, "SUHU&KELEMBABAN", 10000, NULL, 1, NULL);
  xTaskCreate(rrs, "ATAP", 10000, NULL, 1, NULL);
  xTaskCreate(rwl, "MINUM", 10000, NULL, 1, NULL);
}

void loop()
{
  Blynk.run();
  timeClient.update();
}
void rlc(void *pvParameters){
  for(;;){
    //Pakan
  s.set_scale(cf); // Adjust to this calibration factor
  float w = s.get_units(10); // Get average of 10 readings
  if (w < 0) {
    w = 0.0;
  }
  //for load cell with servo s1
  Serial.print("Weight: ");
  Serial.print(w); // Print weight with two decimal places
  Serial.println(" grams");
  // Check if the weight is below the target weight
  Blynk.virtualWrite(V2, w);
  if (w < 200.0) {
    s1.write(90); // Open the dispenser
    Serial.println("Dispensing food...");
    delay(5000); // Keep the servo open for 5 seconds
    s1.write(0); // Close the dispenser
    Serial.println("Stopping dispenser.");
  }
  vTaskDelay(10000 / portTICK_PERIOD_MS);
  }
}
void rwl(void *pvParameters){
  for(;;){
  //Minum
  int sv = analogRead(WATER_LEVEL_PIN);
  float svp = sv*ps/4095;
  Serial.print("Water Level: ");
  Serial.print(svp);
  Serial.println(" Cm");
  Blynk.virtualWrite(V3, svp);
    if (svp>2){
    digitalWrite(r1pin, LOW);
    delay(5000);
    digitalWrite(r1pin, HIGH);
  }
  vTaskDelay(10000 / portTICK_PERIOD_MS);
  }
} 
void rds(void *pvParameters){
  for(;;){
  //Suhu dan Humidity
  float t=d.readTemperature();
  float h=d.readHumidity();
  //for temperature and humidity with solenoid valve r2
  if (isnan(h)|| isnan(t)){
    delay(1000);
    Serial.println("FAIL to READ");
  }
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
  Serial.print("\n");
  Serial.print("Humidity: "+ String(h)+"%");
  Serial.print("\n");
  Serial.print("Temperature: "+ String(t)+"c");
  Serial.print("\n");
  if(t>=33){
    digitalWrite(r2pin, LOW);
    delay(5000);
    digitalWrite(r2pin, HIGH);
  }
  if(h<=50){
    digitalWrite(r2pin, LOW);
    delay(5000);
    digitalWrite(r2pin, HIGH);
  }
  vTaskDelay(1800000 / portTICK_PERIOD_MS);
  }
}
void rrs(void *pvParameters){
  for(;;){
  //ROOF
  int cH = timeClient.getHours();
  int sva = analogRead(sensorPin);
  int threshold = 2500;
  Blynk.virtualWrite(V4,sva);
  //for raindrop sensor with servo s2
  if (sva < threshold) {
    s2.write(0); // Close the roof if raining
  } else if (cH >= 7 && cH <= 11) {
    s2.write(180); // Open the roof between 7 AM and 11 AM if not raining
  } else {
    s2.write(0); // Close the roof outside this time range
  }
  vTaskDelay(5000 / portTICK_PERIOD_MS);
  }
}

this is my code.

c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In destructor 'virtual ESP32PWM::~ESP32PWM()':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:53:17: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
   53 |                 ledcDetachPin(pin);
      |                 ^~~~~~~~~~~~~
      |                 ledcDetach
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In static member function 'static double ESP32PWM::_ledcSetupTimerFreq(uint8_t, double, uint8_t)':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:60:16: error: 'ledcSetup' was not declared in this scope
   60 |         return ledcSetup(chan, freq, bit_num);
      |                ^~~~~~~~~
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In member function 'double ESP32PWM::setup(double, uint8_t)':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:150:17: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
  150 |                 ledcDetachPin(pin);
      |                 ^~~~~~~~~~~~~
      |                 ledcDetach
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:151:30: error: 'ledcSetup' was not declared in this scope
  151 |                 double val = ledcSetup(getChannel(), freq, resolution_bits);
      |                              ^~~~~~~~~
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:155:16: error: 'ledcSetup' was not declared in this scope
  155 |         return ledcSetup(getChannel(), freq, resolution_bits);
      |                ^~~~~~~~~
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In member function 'void ESP32PWM::adjustFrequencyLocal(double, double)':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:172:17: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
  172 |                 ledcDetachPin(pin);
      |                 ^~~~~~~~~~~~~
      |                 ledcDetach
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:176:17: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
  176 |                 ledcAttachPin(pin, getChannel()); // re-attach the pin after frequency adjust
      |                 ^~~~~~~~~~~~~
      |                 ledcAttach
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In member function 'void ESP32PWM::attachPin(uint8_t)':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:237:17: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
  237 |                 ledcAttachPin(pin, getChannel());
      |                 ^~~~~~~~~~~~~
      |                 ledcAttach
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp: In member function 'void ESP32PWM::detachPin(int)':
c:\Users\Diyni\OneDrive\Dokumen\Arduino\libraries\ESP32Servo\src\ESP32PWM.cpp:264:9: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
  264 |         ledcDetachPin(pin);
      |         ^~~~~~~~~~~~~
      |         ledcDetach

exit status 1

Compilation error: exit status 1

and this is my error
ohh and when i want to test my servo with the another sketch, the same error is pop up to
Uploading: image.png…

thankyou

The only thing I can advise is to check if one of the ESP32Servo examples still compiles.

I was wondering about that, but wasn't sure so didn't say anything. Great catch!

Hi @qornainina.

Explanation

There are significant breaking changes in the recently released version 3.0.0 of the "esp32" boards platform.

Some of these breaking changes caused a loss of compatibility with the "ESP32Servo" library:

https://github.com/espressif/arduino-esp32/blob/master/docs/en/migration_guides/2.x_to_3.0.rst#ledc

LEDC

The LEDC API has been changed in order to support the Peripheral Manager and make it easier to use, as LEDC channels are now automatically assigned to pins. For more information about the new API, check /api/ledc.

Removed APIs

  • ledcSetup
  • ledcAttachPin

The breakage is being tracked by the library developer here:

I see that some work has been done already on a fix for the breakage, but unfortunately has not been completed:

Resolution

The easiest solution will be to use a version of the "esp32" boards platform that is compatible with the ESP32Servo library.

The breaking changes in the "esp32" boards platform were introduced in the 3.0.0 release, so you won't have these problems compiling the library if you install an older version of the "esp32" platform.

  1. Select Tools > Board > Boards Manager... from the Arduino IDE menus.
    The "Boards Manager" dialog will open.
  2. Wait for the updates to finish, as shown by the messages printed at the bottom of the "Boards Manager" dialog.
  3. Scroll down through the list of boards platforms until you find the "esp32" entry. Click on it.
    A "Select version" dropdown will appear in the entry.
  4. Click on the "Select version" dropdown.
    It will expand.
  5. Select "2.0.17" from the menu.
  6. Click the "Install" button in the "esp32" entry.
  7. Wait for the installation to finish.
  8. Click the "Close" button on the "Boards Manager" dialog.
    The "Boards Manager" dialog will close.

Now compile your sketch again. Hopefully this time the error will not occur and the library will work as expected.


Arduino IDE will occasionally notify you that a new version of the boards platform is available, you'll need to refrain from accepting the offer that will cause an update back to the problematic version of the platform. If you find these notifications annoying, you can disable them via the IDE preferences.

I'll provide instructions you can follow to do that:

  1. Select File > Preferences... (or Arduino > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to "Check for updates on startup" in the "Preferences" dialog.
  3. Click the "OK" button.
    The "Preferences" dialog will close.

If you disable the automatic update check, make sure to periodically do a manual check for newer versions of the installed boards platforms and libraries that you want to keep updated. You can check for new versions of Arduino IDE by selecting Help > Check for Arduino IDE Updates from the Arduino IDE menus. You can check for new versions of boards platforms and libraries by selecting "Updatable" from the "Type" menu in the Boards Manager and Library Manager views.

2 Likes

thankyou very much

thankyou very much its really helpfull

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

is this a pun? :grinning: :crazy_face:

No. It is a standard term commonly used by software engineers:

https://en.wiktionary.org/wiki/breaking_change

An update on this statement. The fix I mentioned in my previous reply has since been completed and released in version 3.0.0 of the "ESP32Servo" library.

So you can now update to the latest version of the "esp32" boards platform and latest version of the "ESP32Servo" library and they will be compatible with each other.

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