Arduino IOT Cloud. Compiling errors in Arduino IDE. 'ArduinoIoTCloudTCP::_mqttClient' to be of abstract type 'MqttClient'

Hello
I'm new to the forum. I apologize in advance for my poor English.
I have a problem compiling code from Arduino IoT Cloud to Arduino IDE.
The code is clean without modifications. While compiling, there are constant errors as below. I uninstalled the Arduino IDE and the libraries but the errors are still there. Please give me some advice on how to improve it.

I use a ESP32 DEV MODULE.

I tested the code on many different ESP32 modules. Unfortunately, the same errors are everywhere.

In file included from c:\Users\weles\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloud.h:167,
                 from H:\IOT_ARDUINO\Weles\Weles\thingProperties.h:3,
                 from H:\IOT_ARDUINO\Weles\Weles\Weles.ino:20:
c:\Users\weles\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloudTCP.h:142:16: error: cannot declare field 'ArduinoIoTCloudTCP::_mqttClient' to be of abstract type 'MqttClient'
  142 |     MqttClient _mqttClient;
      |                ^~~~~~~~~~~
In file included from c:\Users\weles\Documents\Arduino\libraries\ArduinoMqttClient\src/ArduinoMqttClient.h:23,
                 from c:\Users\weles\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloudTCP.h:27:
c:\Users\weles\Documents\Arduino\libraries\ArduinoMqttClient\src/MqttClient.h:42:7: note:   because the following virtual functions are pure within 'MqttClient':
   42 | class MqttClient : public Client {
      |       ^~~~~~~~~~
In file included from C:\Users\weles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0-RC3\cores\esp32/Arduino.h:197,
                 from C:\Users\weles\AppData\Local\arduino\sketches\E93321053340A96E0FF440733028DB0E\sketch\Weles.ino.cpp:1:
C:\Users\weles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0-RC3\cores\esp32/Client.h:29:15: note:     'virtual int Client::connect(IPAddress, uint16_t, int32_t)'
   29 |   virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
C:\Users\weles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0-RC3\cores\esp32/Client.h:31:15: note:     'virtual int Client::connect(const char*, uint16_t, int32_t)'
   31 |   virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
Multiple libraries were found for "WiFi.h"
  Used: C:\Users\weles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0-RC3\libraries\WiFi
  Not used: C:\Users\weles\Documents\Arduino\libraries\WiFiNINA
exit status 1

Compilation error: exit status 1

Weles.zip (5.7 KB)

Kod programu:

#include "arduino_secrets.h"
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/3d149b89-b467-4d9b-9e3f-c57f1f43607a 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int lED_1_VALUE;
  int lED_2_VALUE;
  bool lED_1_STATUS;
  bool lED_2_STATUS;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(115200);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}


/*
  Since LED1STATUS is READ_WRITE variable, onLED1STATUSChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLED1STATUSChange()  {
  // Add your code here to act upon LED1STATUS change
}

/*
  Since LED2STATUS is READ_WRITE variable, onLED2STATUSChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLED2STATUSChange()  {
  // Add your code here to act upon LED2STATUS change
}

/*
  Since LED1VALUE is READ_WRITE variable, onLED1VALUEChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLED1VALUEChange()  {
  // Add your code here to act upon LED1VALUE change
}

/*
  Since LED2VALUE is READ_WRITE variable, onLED2VALUEChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLED2VALUEChange()  {
  // Add your code here to act upon LED2VALUE change
}

Does it compile clean using the IoT cloud editor?

In Arduino IOT Cloud compiles correctly. The error occurs when I download the code and compile it in the Arduino IDE.

But it cannot be loaded from ESP32 DEV BOARD. I have Arduino Agent installed but it does not detect the module.....

Check the version of the board package on both the cloud and your local PC.

Easiest is to enable verbose output and compile; the first few lines should tell you.

FQBN: esp32:esp32:esp32
Using board 'esp32' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7
Using core 'esp32' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7

In above, the second and third line refer to version 3.0.7 of the board package.

PS
I can't show you for and ESP32 in the cloud.

1 Like

The installed version of the board package is buried in the error log

Arduino15\packages\esp32\hardware\esp32\3.1.0-RC3\

How did you install a Release Candidate? For the "esp32" board, the latest version offered to me in the IDE is 3.0.7. Version 3.1.0 added the two pure virtual functions mentioned in the error (the ones with timeout)

  virtual int connect(IPAddress ip, uint16_t port) = 0;
  virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
  virtual int connect(const char *host, uint16_t port) = 0;
  virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;

While in "ArduinoMqttClient" up to the current version 0.1.8, MqttClient has only ever implemented the older two

  // from Client
  virtual int connect(IPAddress ip, uint16_t port = 1883);
  virtual int connect(const char *host, uint16_t port = 1883);

That makes MqttClient an abstract class, and you can't have one as a plain variable/member like

MqttClient _mqttClient;

It would have to be a pointer

MqttClient *_mqttClient;

to an object that would actually be some subclass that does implement those functions. But the likely fix would be an updated version of the "ArduinoMqttClient" library.

Until then, install the 3.0.7 version of the "esp32" board.

2 Likes

Missed that one :frowning:

1 Like

There is a screenshot:

Installing version 3.0.7 fixed all errors.
I was convinced that the problem was the ArduinoMqttClient library.
Thank you very much my masters :smiley:

A post was split to a new topic: How to modify library?

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