I'm working with Visual Studio Code, Platformio extension, Arduino framework. Have NodeMCU v3 board with ESP8266. I wrote some simple program, which gets data from sensor and blinks some LED. Everythink went fine, code compiled and worked on the nodeMCU. Great, so as a next step I wanted to connect it to Azure. So as multiple examples were showing, I included some libraries and wrote/copied simple code. After removing some first compilation errors:
- missing blob.h -> https://github.com/Azure/azure-iot-arduino/issues/101
- error in Arduino.h, round(x) -> https://github.com/Azure/azure-iot-arduino#simple-sample-instructions
- MQTT_Protocol' was not declared -> https://github.com/Azure/azure-iot-arduino/issues/108
I've stucked with another error. After cutting code down, you can see a very easy code here:
#include <Arduino.h>
#include "config.h"
#include <ESP8266WiFi.h>
#include <AzureIoTHub.h>
#include <AzureIoTProtocol_MQTT.h>
#include <AzureIoTUtility.h>
#include <ArduinoJson.h>
#include "iothubtransportmqtt.h"
static IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle;
void setup() {
pinMode(PIN_GREEN_LED, OUTPUT);
digitalWrite(PIN_GREEN_LED, LOW);
static IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol = MQTT_Protocol;
iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString("connectionString", protocol);
}
void loop() {
digitalWrite(PIN_GREEN_LED, LOW);
}
Without calling IoTHubClient_LL_CreateFromConnectionString function, which I guess can't be skipped to make connection to Azure IoT Hub, code builds. I had to add iothubtransportmqtt.h, so the MQTT_Protocol is available.
My platformio.ini file (changing the board to esp12e makes no difference):
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
DHT
AzureIoTHub
ArduinoJson
This is how the build starts:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 2.5.1 > NodeMCU 1.0 (ESP-12E Module) [or Espressif ESP8266 ESP-12E for esp12e board]
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
- framework-arduinoespressif8266 3.20701.0 (2.7.1)
- tool-esptool 1.413.0 (4.13)
- tool-esptoolpy 1.20800.0 (2.8.0)
- toolchain-xtensa 2.40802.200502 (4.8.2)
Dependency:
Dependency Graph
DHT 1.0.0
AzureIoTHub 1.3.8
AzureIoTUtility 1.3.8.1
ESP8266WiFi 1.0
ArduinoJson 6.15.2
AzureIoTProtocol_MQTT 1.3.8
Here the terminal output with dozens of warnings before:
Linking .pio\build\nodemcuv2\firmware.elf
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothub_client_core_ll.c.o):(.text.initialize_iothub_client+0x6c): undefined reference to IoTHubClient_LL_UploadToBlob_Destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothub_client_core_ll.c.o):(.text.initialize_iothub_client+0x78): undefined reference to
IoTHubClient_LL_UploadToBlob_Create'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothub_client_core_ll.c.o): in function initialize_iothub_client':
iothub_client_core_ll.c:(.text.initialize_iothub_client+0x1de): undefined reference to
IoTHubClient_LL_UploadToBlob_Destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: iothub_client_core_ll.c:(.text.initialize_iothub_client+0x3ea): undefined reference to IoTHubClient_LL_UploadToBlob_Create'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: iothub_client_core_ll.c:(.text.initialize_iothub_client+0x486): undefined reference to
IoTHubClient_LL_UploadToBlob_Destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: iothub_client_core_ll.c:(.text.initialize_iothub_client+0x547): undefined reference to IoTHubClient_LL_UploadToBlob_Destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.mqtt_operation_complete_callback+0x20): undefined
reference to
retry_control_reset'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o): in function mqtt_operation_complete_callback':
iothubtransport_mqtt_common.c:(.text.mqtt_operation_complete_callback+0xd3): undefined reference to
retry_control_reset'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.free_transport_handle_data+0x0): undefined reference to retry_control_destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.free_transport_handle_data+0x1f): undefined reference to
retry_control_destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.IoTHubTransport_MQTT_Common_SetRetryPolicy+0x8): undefined reference to retry_control_create'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o): in function
IoTHubTransport_MQTT_Common_SetRetryPolicy':
iothubtransport_mqtt_common.c:(.text.IoTHubTransport_MQTT_Common_SetRetryPolicy+0x37): undefined reference to retry_control_create'
retry_control_destroy'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: iothubtransport_mqtt_common.c:(.text.IoTHubTransport_MQTT_Common_SetRetryPolicy+0x60): undefined reference to
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o): in function IoTHubTransport_MQTT_Common_Create':
retry_control_create'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.IoTHubTransport_MQTT_Common_DoWork+0x64): undefined reference to
iothubtransport_mqtt_common.c:(.text.IoTHubTransport_MQTT_Common_Create+0x1ae): undefined reference toretry_control_should_retry'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.IoTHubTransport_MQTT_Common_DoWork+0xca): undefined reference to
retry_control_should_retry'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o):(.text.IoTHubTransport_MQTT_Common_SetOption+0x50): undefined reference to retry_control_set_option'
c:/users/mmielnic/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\nodemcuv2\lib1b2\libAzureIoTHub_ID480.a(iothubtransport_mqtt_common.c.o): in function
IoTHubTransport_MQTT_Common_SetOption':
iothubtransport_mqtt_common.c:(.text.IoTHubTransport_MQTT_Common_SetOption+0x192): undefined reference to `retry_control_set_option'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nodemcuv2\firmware.elf] Error 1