Code works on free account, but not my paid account

OK, great. That provided the information I needed.

Background

When you compile a sketch, the build system searches through all the installed libraries to find the one that provides the header file from each of the #include directives in the sketch program (which includes #include directives in each of the libraries used by the sketch in addition to in the sketch code itself).

In some cases, multiple installed libraries contain a header file with filename matching the one specified by the #include directive. In this case, the sketch build system uses a sophisticated algorithm to determine which of the multiple matching libraries is the best choice. Libraries you have imported to your Arduino Cloud account are given priority in this case based on the assumption that you imported the library because you want the build system to use that library.

Explanation

Your sketch uses the ArduinoIoTCloud" library, which handles the communication between an Arduino Cloud IoT Device and the Arduino Cloud server. We can see that the preinstalled version 2.0.3 of that library is being used when compiling the sketch:

The ArduinoIoTCloud library's code contains an #include directive for a header file named ArduinoHttpClient.h.

You imported version 0.5.0 of the "ArduinoHttpClient" library to your paid Arduino Cloud account. This library contains a header file named ArduinoHttpClient.h. So when the sketch build system searches for the installed library to compile for that #include directive, it chooses the version 0.5.0 of the ArduinoHttpClient library you imported instead of the preinstalled version 0.6.0 of the library (which also contains a header file of that name):

The ArduinoIoTCloud library also contains an #include directive for a header file named UrlParser.h. A header file of that name is present in the ArduinoHttpClient library:

However, the header file was added to the library in version 0.6.0, and so is not present in the version 0.5.0 of the library you imported. For this reason, version 0.6.0 of the ArduinoHttpClient library is compiled.

So now you have two different copies of the same library being compiled into the same program:

That results in the "multiple definition of ..." errors that caused the sketch compilation to fail.


The reason the compilation didn't fail on your free Arduino Cloud account is likely that you didn't import version 0.5.0 of the ArduinoHttpClient library to that account, so only version 0.6.0 of the ArduinoHttpClient library is used when compiling the sketch in that account's environment.

Resolution

There are a several different possible solutions to this problem. The question of which one is appropriate hinges on the question of why you imported the ArduinoHttpClient library to your paid Arduino Cloud account.

If you don't know why you did it, or did it without any real reason, then the solution will be to simply remove the problematic imported library from your account.

If you had a specific reason for importing the library to your account (e.g., you needed to use a modified version of the library), then there are a couple of options:

  • Configure Arduino Cloud to use the version of the ArduinoIoTCloud library that is compatible with version 0.5.0 of the ArduinoHttpClient library.
  • Port the modifications to version 0.6.0 of the ArduinoHttpClient library.

So please provide an explanation for why you imported the ArduinoHttpClient library to your paid Arduino Cloud account. Once I have that information, I'll provide detailed instructions for the appropriate solution.