Broken dependencies

Not 100% sure where to post this.
Using IDE 2.3.2
I have a program for an ESP32 that worked a week ago. Today various boards & software updates were available which I allowed to install.

Now I have a compiling error which I assume is a dependency issue?
The only declared library is this...
#include "EspMQTTClient.h"

Full error message here...

c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleWiFi()':
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:187:5: error: 'WiFi' was not declared in this scope
  187 |     WiFi.disconnect(true);
      |     ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:27: error: 'WiFi' was not declared in this scope
  194 |   bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
      |                           ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:44: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'MQTT_CONNECTED'?
  194 |   bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
      |                                            ^~~~~~~~~~~~
      |                                            MQTT_CONNECTED
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:215:27: error: 'WL_CONNECT_FAILED' was not declared in this scope; did you mean 'MQTT_CONNECT_FAILED'?
  215 |       if(WiFi.status() == WL_CONNECT_FAILED || millis() - _lastWifiConnectiomAttemptMillis >= _wifiReconnectionAttemptDelay)
      |                           ^~~~~~~~~~~~~~~~~
      |                           MQTT_CONNECT_FAILED
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleMQTT()':
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:325:9: error: 'WiFi' was not declared in this scope
  325 |         WiFi.disconnect(true);
      |         ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionEstablished()':
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:362:75: error: 'WiFi' was not declared in this scope
  362 |       Serial.printf("WiFi: Connected (%fs), ip : %s \n", millis()/1000.0, WiFi.localIP().toString().c_str());
      |                                                                           ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionLost()':
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:388:5: error: 'WiFi' was not declared in this scope
  388 |     WiFi.disconnect(true);
      |     ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::connectToWifi()':
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:3: error: 'WiFi' was not declared in this scope
  555 |   WiFi.mode(WIFI_STA);
      |   ^~~~
c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:13: error: 'WIFI_STA' was not declared in this scope; did you mean 'WIFI_IF_STA'?
  555 |   WiFi.mode(WIFI_STA);
      |             ^~~~~~~~
      |             WIFI_IF_STA
Multiple libraries were found for "WiFiClient.h"
  Used: C:\Users\richard\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.0\libraries\WiFi
  Not used: C:\Users\richard\Documents\Arduino\libraries\WiFiEspAT
  Not used: C:\Users\richard\Documents\Arduino\libraries\WiFi101
  Not used: C:\Users\richard\Documents\Arduino\libraries\WiFi
  Not used: C:\Users\richard\Documents\Arduino\libraries\WiFi101_Generic
exit status 1

Compilation error: exit status 1

===end copy error message===

I am not sure where to look or what has happened, any suggestions?

Yes.

Test it with IDE <2.x.

Is it possible to install more than one version of the IDE?

It is possible to install both versions; but they will use the same cores and libraries so I have serious doubts that it will solve the issue.

You can create a portable install of IDE 1.x which is independent of any other install. You will have to install the board package and libraries again.

Personally, I don't update for the sake of updating. I would roll back the changes. WiFi is (I think) something in the board package so I would roll that back first and test; you probably only have to go one version back if you have been consistently updating.

Note:
No experience with your board.

Thank you both for your help.
I think I have made a mess.
My laptop is Windows based.
Going to try a Ubuntu Live USB and alternate boot and downgrade to 1.8.x (maybe 19)
It's back to basics for me, very sad

Downgrading the board package is a small excercise.
Installing a portable install of IDE 1.x on your Windows system is also a small exercise.

  1. Download the zip version of the IDE.
  2. Unzip.
  3. Create a directory portable in the unzipped directory.
  4. Start the IDE.

But it's your call :wink:

Thanks, this sounds more attractive actually.
Will try :slight_smile:

Hi @little_rich. Don't waste your time installing Arduino IDE 1.x. The problem has nothing to do with the Arduino IDE version. You will get the same error with Arduino IDE 1.x as you did with 2.3.2.


The developers of the "esp32" boards platform made some significant changes in the 3.0.0 release. One of these caused an incompatibility with the "EspMQTTClient" library.

Fortunately the fix for the bug in the library is quite minimal so you can make the necessary change to the library source code yourself.

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

  1. Open the file at the following path on your computer in any text editor:
    c:\Users\richard\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.h
    
  2. In that file, you will see that lines 20-22 look like this:
    #else // for ESP32
    
      #include <WiFiClient.h>
    
    Add an #include directive for the WiFi.h header there, so the code now looks like this:
    #else // for ESP32
    
      #include <WiFi.h>
      #include <WiFiClient.h>
    
  3. Save the file.

Now compile your sketch again. This time it should compile without any errors.

I have now submitted a fix for the bug in the "EspMQTTClient" library:

Thank you so much for your help.
I wasted the whole weekend trying to come up with a fix.
An hour ago I downgraded the ESP32 boards library to 2.0.17 and that also allowed things to compile.

I prefer your approach and thank you very much for taking the time to share your fix with the community.

I do hope others find this helpful as I am sure I am not the only one with not quite enough knowledge to fix something like this.
Cheers
little-rich

You are welcome. I'm glad you were able to find a solution.

Regards,
Per

Thanks, everyone.
I had the exact problem, and it was quickly resolved because of this post.

Happy!!

Good answer it work !!

Thank you ptillisch, I saved precious hours with your help!

Just to keep this open for a bit longer - EXACTLY my problem - thanks for the fix!

@ptillisch Thank you so much for the solution!

The original library does not appear to being maintained.
This fork has the fix in it
espmqttclientfork
It is available through the arduino IDE Tools;Manage Libraries