Azure-Samples / iot-hub-feather-huzzah-client-app

Application collects weather data from a DHT22 sensor and sends it to IoT hub, also take actions according to cloud-to-device message.
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-arduino-huzzah-esp8266-get-started
MIT License
35 stars 31 forks source link

Errors Everywhere, the code doesn't work. #33

Open Alberto-Vega opened 5 years ago

Alberto-Vega commented 5 years ago

@JhaNishant Migrating issue from the documentation to the sample application repo

https://github.com/MicrosoftDocs/azure-docs/issues/26176

In file included from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/lock.h:17:0,

             from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src/AzureIoTUtility.h:7,

             from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTHub\src/AzureIoTHub.h:7,

             from C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\app.ino:12:

C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/macro_utils.h:222:0: warning: "DEC" redefined [enabled by default]

define DEC(x) C2(DEC,x)

^

In file included from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Stream.h:26:0,

             from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/HardwareSerial.h:32,

             from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:263,

             from sketch\app.ino.cpp:1:

C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Print.h:29:0: note: this is the location of the previous definition

define DEC 10

^

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino: In function 'void readCredentials()':

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino:26:64: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

 readFromSerial("Input your Wi-Fi SSID: ", ssid, SSID_LEN, 0);

                                                            ^

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino:29:68: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

 readFromSerial("Input your Wi-Fi password: ", pass, PASS_LEN, 0);

                                                                ^

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino:32:117: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

 readFromSerial("Input your Azure IoT hub device connection string: ", connectionString, CONNECTION_STRING_LEN, 0);

                                                                                                                 ^

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino: In function 'bool needEraseEEPROM()':

C:\Users\bpnis\Desktop\iot-hub-feather-huzzah-client-app-master\app\credentials.ino:39:126: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

 readFromSerial("Do you need re-input your credential information?(Auto skip this after 5 seconds)[Y/n]", &result, 1, 5000);

                                                                                                                          ^

In file included from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Stream.h:26:0,

             from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/HardwareSerial.h:32,

             from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:263,

             from C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/WiFiClient.h:25,

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

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

C:\Users\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Print.h:29:0: warning: "DEC" redefined [enabled by default]

define DEC 10

^

In file included from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/umock_c_prod.h:23:0,

             from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.h:16,

             from C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.cpp:5:

C:\Users\bpnis\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/macro_utils.h:222:0: note: this is the location of the previous definition

define DEC(x) C2(DEC,x)

^

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

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

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

c:\users\bpnis\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\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\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\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\bpnis\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\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\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\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\bpnis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\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))

                  ^

exit status 1 Error compiling for board Adafruit Feather HUZZAH ESP8266.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

zooda56 commented 5 years ago

When changing ESP board library to 2.4.2 or lower, the code compiles and starts (tried with nodemcu esp12E, which is basically esp8266) Also the ArduinoJson needs to be 5.x as the syntax has changed.

This code needs to be updated to work with latest libraries.

Yatheesha1 commented 5 years ago

I am getting the following error in esp8266 arduino framework


TLS failed to start the connection process. Error: io_open failed failure connecting to address [HostName].azure-devices.net


the connecting string is correct and is working fine with esp32 please help me with this issue

pmossel commented 5 years ago

I have the same issue. I ran the standalone temp measurement and Wi-Fi test code successfully on the DHT22. This is what I used to build

Commented out the round() macro in Arduino.h since it gave an error

** When using VSCode in conjunction with arduino IDE, I get the same results.

sandervandevelde commented 5 years ago

When changing ESP board library to 2.4.2 or lower, the code compiles and starts (tried with nodemcu esp12E, which is basically esp8266) Also the ArduinoJson needs to be 5.x as the syntax has changed.

This code needs to be updated to work with latest libraries.

Confirmed

martinrbowman commented 5 years ago

I can also confirm this issue.

I have forked the repo and modified the code to work with ArduinoJson 6.x

https://github.com/martinrbowman/iot-hub-feather-huzzah-client-app

The error with the round(x) function is reported on the esp8266 and is being investigated.

Tool Chain: Arduino - 1.8.9 ArduinoJson - 6.10.1 esp8266 tools - 2.4.2 Azure Libraries - 1.0.45

Board: Generic Wemos D1 R2 Generic Wemos D1 Mini

StefDS commented 5 years ago

I confirm the same problem. Same tool chain as martinrbowman, using Nodemcu esp12E.

martinrbowman commented 5 years ago

@stefds were you able to build the sample using the toolchain versions I used?

StefDS commented 5 years ago

@martinrbowman: it's indeed building using your forked repo & the listed tool chain. But get with warnings on "_macroutils.h" > #define DEC(x) C2(DEC,x) and "deprecated conversion from string constant to 'char*'"

ejri commented 5 years ago

Confirmed problem as many here. Tried @martinrbowman's fork, but it seems that I'm having the same issues as @StefDS .

For anyone checking for which versions are working: arduino 1.8.9. ESP8266 2.4.2 azureiothub, azureiotprotocol_mqtt, azureiotutility (latest versions 1.0.45) arduinoJson 5.13.4.

martinrbowman commented 5 years ago

@martinrbowman: it's indeed building using your forked repo & the listed tool chain. But get with warnings on "_macroutils.h" > #define DEC(x) C2(DEC,x) and "deprecated conversion from string constant to 'char*'"

I will take a look and see if I can figure out what the root cause of this is.

Elgaatoo commented 5 years ago

@Yatheesha1 did you get the error Messages which @Alberto-Vega-MSFT noted at the beginning? I just ignored the errors but then got the same error as you when I did the Serial monitor:

TLS failed to start the connection process. Error: io_open failed failure connecting to address [HostName].azure-devices.net

ejri commented 5 years ago

Elgaatoo, if I remember correctly from reading a number of threads, both errors (the DEC(X) error and the errors due to TLS) are because of the NodeMCU version. If you have updated it to anything above version 2.4.2, you'll likely going to get one of the errors.

Elgaatoo commented 5 years ago

Hello @ejri , thank you for your quick response!! :) The upload in VStudio was successful with the following settings: Board: ESP8266 Huzzah 2.4.0 Libraries:

However, I am still trying to get rid of the TLS problem. The first sensor message is transmitted but then the connection fails.

Sending message: {"deviceId":"Feather HUZZAH ESP8266 WiFi","messageId":1,"temperature":22.7,"humidity":42}. IoTHubClient accepted the message for delivery. TLS failed to start the connection process. Error: io_open failed failure connecting to address [X]IoTHub.azure-devices.net.