Help setting up libs/dependencies?

I’m having trouble resolving a bunch of #include errors in a project that uses the Azure IoT C SDK.
I followed the instructions here, let PlatformIO do its thing, even a full clean and rebuild but I get the same errors as before:

Processing pico32 (framework: espidf; platform: espressif32; board: pico32)
---------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing azure/Azure SDK for C @ ^1.1.6
Unpacking  [####################################]  100%
Library Manager: Azure SDK for C@1.1.6 has been installed!
Library Manager: Installing mbed-azureiotclient/azure_c_shared_utility
Unpacking  [####################################]  100%
Library Manager: azure_c_shared_utility@0.0.0+sha.6bb8b9a66642 has been installed!
Library Manager: Installing mbed-azureiotclient/iothub_amqp_transport
Unpacking  [####################################]  100%
Library Manager: iothub_amqp_transport@0.0.0+sha.56ac1346c70d has been installed!
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (6.3.2) > ESP32 Pico Kit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-espidf @ 3.50002.230601 (5.0.2)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
 - toolchain-xtensa-esp32 @ 11.2.0+2022r1
Reading CMake configuration...
Generating assembly for certificate bundle...
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain+, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\pico32\src\AzureIoT.o
Compiling .pio\build\pico32\src\AzureIoTAMQP.o
In file included from src/AzureIoT.cpp:4:
include/AzureIoT.h:22:10: fatal error: az_core.h: No such file or directory

* Looking for az_core.h dependency? Check our library registry!
* CLI  > platformio lib search "header:az_core.h"
* Web  >

   22 | #include <az_core.h>
      |          ^~~~~~~~~~~
compilation terminated.
src/AzureIoTAMQP.cpp:14:10: fatal error: azure_c_shared_utility/platform.h: No such file or directory
   14 | #include "azure_c_shared_utility/platform.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\pico32\src\IoTGatewayESP32_RFM69HCW.o
src/IoTGatewayESP32_RFM69HCW.cpp:13:10: fatal error: Arduino.h: No such file or directory

* Looking for Arduino.h dependency? Check our library registry!
* CLI  > platformio lib search "header:Arduino.h"
* Web  >

   13 | #include <Arduino.h>                //Req'd: ESP32 xTaskCreate, TaskHandle_t, etc. for multicore ops
      |          ^~~~~~~~~~~
compilation terminated.
Compiling .pio\build\pico32\src\main.o
Generating LD script .pio\build\pico32\memory.ld
Compiling .pio\build\pico32\app_trace\app_trace.o
Compiling .pio\build\pico32\app_trace\app_trace_util.o
Compiling .pio\build\pico32\app_trace\host_file_io.o
Compiling .pio\build\pico32\app_trace\gcov\gcov_rtio.o
Compiling .pio\build\pico32\app_trace\port\port_uart.o
Compiling .pio\build\pico32\app_update\esp_ota_ops.o
Compiling .pio\build\pico32\app_update\esp_ota_app_desc.o
src/main.cpp:46:10: fatal error: WiFi.h: No such file or directory

* Looking for WiFi.h dependency? Check our library registry!
* CLI  > platformio lib search "header:WiFi.h"
* Web  >

So you’re using pure ESP-IDF while the library you referenced says

Azure SDK for C library for Arduino

I’m assuming you don’t want to use Arduino (or ESP-IDF with Arduino as a component) and go the harder ESP-IDF route instead.

With ESP-IDF projects, it’s better to not use lib_deps. The library format in ESP-IDF projects are ESP-IDF components (see documentation).

You can still include the Azure IoT C SDK as an ESP-IDF component, analogous to how the AWS IoT example is setup.That is, you create a components folder and clone / copy the needed ESP-IDF components in there.

There used to be espressif/esp-azure but that’s outdated now, instead pointing at azure/azure-sdk-for-c as a base with Azure/azure-iot-middleware-freertos on top. Since ESP-IDF includes FreeRTOS, it’s a natural choice. In fact, let’s just use the sample project they posted at

I created a blank ESP-IDF project and copy-pasted the files from main/ into src/, the CMakeLists.txt and sdkconfig.defaults in the root 1:1, as well as the components folder.

Now the folder structure that the CMakeLists.txt in the components/ folder wants is very restricted to the way that demo folder lies within the iot-middleware-freertos-samples repository – so I took the liberty of adapting the paths in those files to not look for libraries at ${CMAKE_CURRENT_LIST_DIR}/../../../../../.. but instead redirect them to a new espidf_libs/ folder in the root of the project, where all the actual component code can be stored (i.e., a clone of and copies of the demo components).

Another small caveat is that their CMake files use file(REAL_PATH), but that’s only available in higher CMake version than what PlatformIO is currently using with ESP-IDF, so I had to bumb that up using platform_packages to the latest.

With all that taken care of, one can finally start the menuconfig as documented.

Not forgetting to navigate this menu with the J/K keys, I can go in there and setup the sample project as needed with the WiFi SSID / Password and Azure IoT connection details…


Since I don’t actually have any Azure IoT credentials or an even account for it, I left everything as the default / dummy values.

And the project builds normally.

RAM:   [=         ]  11.4% (used 37508 bytes from 327680 bytes)
Flash: [========= ]  88.1% (used 923625 bytes from 1048576 bytes)
Building .pio\build\esp32dev\firmware.bin v4.5.1
Creating esp32 image...
Merged 25 ELF sections
Successfully created esp32 image.
========== [SUCCESS] Took 74.15 seconds ==========

(You can of course change the partition table in both menuconfig and platformio.ini to get more headroom in available app flash size.)

And of course when uploaded, the project tries to boot up normally in the serial monitor


I uploaded this reference project at

And of course, if you were in fact looking for the Azure IoT C for Arduino library and example, your azure/Azure SDK for C@^1.1.6 would have been completely correct, but you would have needed to create an Arduino project, not a ESP-IDF project.

Copying the example files from azure-sdk-for-c-arduino/examples/Azure_IoT_Hub_ESP32 at 1.1.6 · Azure/azure-sdk-for-c-arduino · GitHub into the src/ folder of such a newly created project with the addition of the above lib_deps (and a monitor_speed = 115200 to setup the serial monitor baud) is a thing of 3 minutes.

I’ve uploaded a reference project for that at

So you’re using pure ESP-IDF while the library you referenced says

Azure SDK for C library for Arduino

I’m not using an Arduino library. I’m using non-arduino code directly from Microsoft. I’m just trying to find a set of instructions that actually work, for ESP32 build target, preferably in VSCode.

Also, the “SDK for C” link you posted is not the C SDK I’m using. Their naming can be confusing sometimes, but that’s the “for Embedded C” SDK. None of the instructions I find for the standard C99 SDK seem to work so far in ESP-IDF.

Why not use the Azure SDK that’s explicitly supported for ESP32 and has official examples with them?

Because it’s the wrong SDK. It doesn’t do all the same things. I’ve had that one running months ago, but it lacks all of the critical features that we need, like AMQP, multiplexing, etc. It’s MQTT only for extremely constrained devices, which the ESP is not. Arduino is also notoriously baby’s-first-IDE for good reason.

If you have a different solution for single-connection, device multiplexing (e.g. publishing telemetry on behalf of multiple device_ids using a single physical device), I’d be happy to try it. This one isn’t capable of it.

You can read about the restrictions here: C SDK and Embedded C SDK usage scenarios | Microsoft Learn

As I read their CMake files, the “Azure IoT C SDK” is only compilable for Windows, Linux and Mac, no embedded devices in mind. Let me know when you successfully get it to compile and use it.

It is compatible with other platforms. They just do not officially support it. I’ll check back here if we resume this project.