Arduino IDE: compile error in example ESP32.ino

Hi all.

On a Windows 10 PC I have installed: the latest version of Arduino IDE (2.3.2); thicker.io library 2.30.0; on board manager, Esp32 by Espressif Systems 3.0.1.
I selected the “ESP32 Dev Module” board.

I attempted to compile a sketch that I used with previous versions of Arduino and libraries, but I had compilation errors on the ThingerESP32.h file.
So I tried to compile an example Sketch (ESP32.ino) but it still gave me the same compilation errors (I attach them at the end of this message).

Having noticed that the errors are related to WiFi symbols, I tried to include the <WiFi.h> file before <ThingerESP32.h> in the sketch, which resolves these errors.

Then I tried to include the <WiFi.h> file in my Sketch; By doing this there are no compilation errors but the ESP32 module does not connect to the Cloud.
I assume that including <WiFi.h> is not the way to solve the problem, but that perhaps another file other than <WiFi.h> needs to be included or another solution needs to be implemented.

Thank you

Compilation errors on the example ESP32.ino:

In file included from c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerESP32.h:32,
from C:\Users\Quirino\AppData\Local\Temp.arduinoIDE-unsaved2024512-7228-15s2ui9.w921\ESP32\ESP32.ino:3:
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h: In member function ‘virtual bool ThingerWifiClient::network_connected()’:
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:44:17: error: ‘WiFi’ was not declared in this scope
44 | return (WiFi.status() == WL_CONNECTED) && !(WiFi.localIP() == (IPAddress)INADDR_NONE);
| ^~~~
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:44:34: error: ‘WL_CONNECTED’ was not declared in this scope; did you mean ‘NETWORK_CONNECTED’?
44 | return (WiFi.status() == WL_CONNECTED) && !(WiFi.localIP() == (IPAddress)INADDR_NONE);
| ^~~~~~~~~~~~
| NETWORK_CONNECTED
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h: In member function ‘virtual bool ThingerWifiClient::connect_network()’:
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:52:13: error: ‘WiFi’ was not declared in this scope
52 | WiFi.begin((char*)wifi_ssid_, (char*) wifi_password_);
| ^~~~
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:58:13: error: ‘WiFi’ was not declared in this scope
58 | WiFi.begin();
| ^~~~
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:67:16: error: ‘WiFi’ was not declared in this scope
67 | while( WiFi.status() != WL_CONNECTED) {
| ^~~~
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:67:33: error: ‘WL_CONNECTED’ was not declared in this scope; did you mean ‘NETWORK_CONNECTED’?
67 | while( WiFi.status() != WL_CONNECTED) {
| ^~~~~~~~~~~~
| NETWORK_CONNECTED
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:77:16: error: ‘WiFi’ was not declared in this scope
77 | while (WiFi.localIP() == (IPAddress)INADDR_NONE) {
| ^~~~
In file included from c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:27:
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerWifi.h:83:60: error: ‘WiFi’ was not declared in this scope
83 | THINGER_DEBUG_VALUE(“NETWORK”, “Got IP Address: “, WiFi.localIP());
| ^~~~
c:\Users\Quirino\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h:141:152: note: in definition of macro ‘THINGER_DEBUG_VALUE’
141 | #define THINGER_DEBUG_VALUE(type, text, value) Serial.print(”[”); Serial.print(F(type)); Serial.print("] "); Serial.print(F(text)); Serial.println(value);
| ^~~~~

exit status 1

Compilation error: exit status 1

Hello @qsegreti

I’m afraid we don’t currently support the recent esp32 3.x, you can however use the last 2.x version (currently 2.0.17) without needing to add #include <WiFi.h> in the sketch.
screen.20240612-161303

However, testing with a simple sketch and version 3.0.1 of esp32 and adding #include <WiFi.h> before the include of ThingerESP32.h as you mentioned I had no problems compiling and connecting to a Thinger instance and sending and receiving data. What issues is it reporting regarding the connection to the cloud?

We will fix this import issue for the next version of the library

1 Like

Thanks Jaimebs.
Using esp32 2.0.17 I solved the problems I had encountered, including the connection with the Cloud. If possible, I take this opportunity to ask a question: my client would like to have the possibility of changing the device_id of the ESP32 modules without reprogramming them with Arduino, but reading a value from Nvs; to override the device_id I can invoke the set_credentials(username, device_id, device_password) which is in the ThingerClient file?
Thank you!

Hi @qsegreti

Glad you got it working with 2.0.17 version.

Is is indeed possible to retrieve the id fom NVS (or other sources) and configure the device with the retrieved data, here are a couple of different approaches:

#define THINGER_SERIAL_DEBUG
#define THINGER_SERVER "***.aws.thinger.io"

#include <ThingerESP32.h>
#include <ThingerESP32OTA.h>

#define USERNAME "***"
#define DEVICE_CREDENTIAL "***"

#define SSID "***"
#define SSID_PASSWORD "***"

ThingerESP32 *thing;
ThingerESP32OTA *ota;

void setup() {

  const char* device_id = "esp32";

  thing = new ThingerESP32(USERNAME, device_id, DEVICE_CREDENTIAL);
  thing->add_wifi(SSID, SSID_PASSWORD);

  ota = new ThingerESP32OTA((*thing));

  // resource output example
  (*thing)["millis"] >> outputValue(millis());

}

void loop() {
  thing->handle();
}

#define THINGER_SERIAL_DEBUG
#define THINGER_SERVER "***.aws.thinger.io"

#include <ThingerESP32.h>
#include <ThingerESP32OTA.h>

#define USERNAME "***"
#define DEVICE_CREDENTIAL "***"

#define SSID "***"
#define SSID_PASSWORD "***"

ThingerESP32 thing("","","");
ThingerESP32OTA *ota;

void setup() {

  const char* device_id = "esp32";

  thing.set_credentials(USERNAME, device_id, DEVICE_CREDENTIAL);
  thing.add_wifi(SSID, SSID_PASSWORD);

  ota = new ThingerESP32OTA(thing);

  // resource output example
  thing["millis"] >> outputValue(millis());

}

void loop() {
  thing.handle();
}
1 Like

Hi @qsegreti, we have updated the Arduino Library to version 2.31.0, which should fix the compiling issues with the newer ESP32 Arduino framework. Take a look here.

Hope it helps!

1 Like

Hi Alvaro.
Ok! In the next few days I will also try one of the methods you recommended for changing the device_id.
Thank you!

1 Like