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?
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.
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
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:
Open the file at the following path on your computer in any text editor:
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
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