upload dht 11 data using esp8266 to azure

hi all

my name is Ling. I'm trying to do this project in Arduino IDE, its a really complex project for me, I found this existing code in the attachment but it wouldn't run successfully.

below is the error message, I don't really understand the error. I did some research then found out that multiple libraries aren't an error, also I deleted all the libraries and downloaded again anyway.

also, i used ArduinoJson 5.13.2 library, version 6 wouldn't work

so. can anyone please tell me what does the error mean

Arduino: 1.8.10 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+111 (191024), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266WiFi\src/WiFiClient.h:25:0,

                 from C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39,

                 from C:\Users\lsun\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.cpp:9:

c:\users\lsun\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::poisson_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

 #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

                      ^

c:\users\lsun\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::binomial_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

 #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

                      ^

C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

 #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

                      ^

Multiple libraries were found for "EEPROM.h"
 Used: C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\EEPROM
Multiple libraries were found for "Adafruit_Sensor.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\Adafruit_Unified_Sensor
Multiple libraries were found for "ArduinoJson.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\ArduinoJson
Multiple libraries were found for "DHT.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\DHT_sensor_library
Multiple libraries were found for "ESP8266WiFi.h"
 Used: C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266WiFi
Multiple libraries were found for "AzureIoTHub.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\AzureIoTHub
Multiple libraries were found for "AzureIoTUtility.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\AzureIoTUtility
Multiple libraries were found for "AzureIoTProtocol_MQTT.h"
 Used: C:\Users\lsun\Documents\Arduino\libraries\AzureIoTProtocol_MQTT
exit status 1
Error compiling for board Generic ESP8266 Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

modified code with json 5.13.1.zip (10.8 KB)

Here's the minimal demonstration of the bug:

#include <AzureIoTHub.h>
void setup() {}
void loop() {}

Unfortunately, I couldn't find the cause of it, or even the mechanism that would cause it. My suspicion is that there is a name conflict with the round() macro introduced in the AzureIoTHub library or one of the other files #included by that library, but I did a lot of searching without finding anything.

The (terrible) workaround is to comment out the definition of the round() macro:

Open C:\Users\lsun\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/Arduino.h in a text editor. Note that the AppData is hidden by Windows Explorer by default. You will need to change the preferences to not hide system folders to see it.

Change line 137 from:

#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

to:

//#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

Save the file.

This will allow your sketch to compile, but it will break any other code that uses the round() macro. It will also need to be redone every time you update to a new version of the ESP8266 core for Arduino. So it's very much not an ideal solution. Maybe someone else here will be able to offer a better fix.

the problem is in AzureIoTUtility library
the compilation fails in Arduino.h included in ESP8266WiFi.h included in sslClient_arduino.cpp

In file included from /home/duro/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/WiFiClient.h:25:0,
                 from /home/duro/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39,
                 from /home/duro/eclipse/arduinoPlugin/libraries/AzureIoTUtility/1.0.45/src/adapters/sslClient_arduino.cpp:9:

the problem is #include in AzureIoTUtility/src/azure_c_shared_utility/crt_abstractions.h included in sslClient_arduino.cpp over:
AzureIoTUtility/src/azure_c_shared_utility/xlogging.h
AzureIoTUtility/src/esp8266/azcpgmspace.h

moving #include "azure_c_shared_utility/xlogging.h" in sslClient_arduino.cpp after the ifdefs for sslClient variable solves the problem

thank you so much, the problem is solved !!!

Juraj:
the problem is in AzureIoTUtility library
the compilation fails in Arduino.h included in ESP8266WiFi.h included in sslClient_arduino.cpp

In file included from /home/duro/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/WiFiClient.h:25:0,

from /home/duro/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39,
                from /home/duro/eclipse/arduinoPlugin/libraries/AzureIoTUtility/1.0.45/src/adapters/sslClient_arduino.cpp:9:




the problem is #include <cmath> in AzureIoTUtility/src/azure_c_shared_utility/crt_abstractions.h included in **sslClient_arduino**.cpp over:
AzureIoTUtility/src/azure_c_shared_utility/xlogging.h
AzureIoTUtility/src/esp8266/azcpgmspace.h

moving #include "azure_c_shared_utility/xlogging.h" in **sslClient_arduino**.cpp after the ifdefs for sslClient variable solves the problem