%3CLINGO-SUB%20id%3D%22lingo-sub-1400406%22%20slang%3D%22en-US%22%3EAzure%20IoT%20releases%20a%20new%20SDK%20for%20constrained%20devices%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1400406%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20have%20ever%20struggled%20to%20fit%20your%20application%20into%20a%20constrained%20IoT%20device%2C%20we%20have%20great%20news%20for%20you!%20We%20released%20the%20new%20Embedded%20C%20SDK%2C%20built%20to%20support%20microcontrollers%2C%20optimized%20for%20memory%20usage%20with%20no%20dynamic%20memory%20allocation%2C%20fully%20embracing%20MQTT%20and%20providing%20access%20to%20a%20number%20of%20Azure%20Services.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CIFRAME%20src%3D%22https%3A%2F%2Faka.ms%2Fiotshow%2F213%2Fyoutube%2Fembed%22%20width%3D%22560%22%20height%3D%22315%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20allow%3D%22accelerometer%3B%20autoplay%3B%20encrypted-media%3B%20gyroscope%3B%20picture-in-picture%22%3E%3C%2FIFRAME%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1168361618%22%20id%3D%22toc-hId-1168361618%22%3EWhy%20do%20we%20need%20an%20Embedded%20C%20SDK%3F%3C%2FH3%3E%0A%3CP%3EAs%20the%20IoT%20industry%20evolves%2C%20companies%20and%20developers%20are%20identifying%20many%20more%20opportunities%20to%20create%20amazing%20solutions%20for%20real%20world%20problems.%3CBR%20%2F%3EWhen%20we%20look%20at%20the%20devices%20that%20are%20enabling%20these%20digital%20transformation%20scenarios%2C%20we%20can%20find%20all%20sorts%20of%20devices%20going%20from%20pretty%20powerful%20hardware%20running%20full%20OS%20(Windows%20%2F%20Linux)%2C%20like%20the%20Raspberry%20PI%2C%20all%20the%20way%20down%20to%20single%20core%20MCU%20(microcontrollers)%20%E2%80%93%20constrained%20devices%20like%20the%20ESP8266.%3CBR%20%2F%3EWhile%20you%20can%20easily%20fit%20any%20of%20the%20Azure%20SDKs%20into%20more%20powerful%20devices%2C%20doing%20the%20same%20with%20a%20constrained%20device%20has%20previously%20required%20an%20optimized%20version%20of%20the%20C%20SDK%2C%20along%20with%20specific%20compiling%20requirements%20to%20reduce%20its%20footprint%20for%20the%20limited%20resources%20available.%20%3CBR%20%2F%3EAdditionally%2C%20scenarios%20with%20constrained%20devices%20installed%20in%20remote%20locations%2C%20bring%20additional%20challenges.%20These%20devices%20may%20require%20limited%20power%20sources%20like%20solar%20power%20and%20battery-operation.%20Also%2C%20the%20lack%20of%20Wi-Fi%20will%20require%20network%20alternatives%20like%20cellular%2C%20mesh%20networks%2C%20or%20LoRa.%20%3CBR%20%2F%3EOverall%2C%20we%20recognized%20all%20of%20these%20challenges%20and%20the%20corresponding%20gaps%20in%20what%20our%20existing%20C%20SDK%20could%20provide%2C%20so%20we%20completely%20redesigned%20a%20new%20and%20improved%20embedded%20C%20SDK.%20We're%20happy%20to%20present%20it%20as%20the%20newest%20addition%20to%20the%20Azure%20SDK%20family%3A%20the%20public%20preview%20of%20the%20%E2%80%9CAzure%20SDK%20for%20Embedded%20C%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--639092845%22%20id%3D%22toc-hId--639092845%22%3EEmbedded%20C%20SDK%20explained%3C%2FH3%3E%0A%3CP%3EAt%20its%20core%2C%20the%20embedded%20C%20SDK%20is%20a%20set%20of%20libraries%20that%20will%20help%20you%20take%20advantage%20of%20Azure%20IoT%20capabilities.%20It%20provides%20helper%20functions%20so%20your%20application%20can%20connect%20to%20-ERR%3AREF-NOT-FOUND-Azure%20IoT%20Hub%2C%20send%20telemetry%20messages%20(-ERR%3AREF-NOT-FOUND-device%20to%20cloud)%2C%20receive%20-ERR%3AREF-NOT-FOUND-cloud%20to%20device%20messages%2C%20-ERR%3AREF-NOT-FOUND-direct%20device%20methods%2C%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fiot-hub%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Edevice%20twin%3C%2FA%3E%20metadata.%20It%20can%20also%20be%20provisioned%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-hub%2Fiot-hub-devguide-messages-d2c%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Edevice%20provisioning%3C%2FA%3E%20services.%20%3CBR%20%2F%3EIoT%20developers%20will%20now%20have%20the%20flexibility%20to%20bring%20any%20MQTT%20client%2C%20TLS%20and%20socket%20layer%20they%20prefer%20to%20their%20application%2C%20allowing%20for%20extreme%20optimization%20by%20leveraging%20libraries%20that%20are%20optimized%20for%20the%20target%20device.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22csdk.png%22%20style%3D%22width%3A%20294px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F192847i36CBF1C893D7CE35%2Fimage-dimensions%2F294x316%3Fv%3D1.0%22%20width%3D%22294%22%20height%3D%22316%22%20title%3D%22csdk.png%22%20alt%3D%22Embedded%20C%20SDK%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EEmbedded%20C%20SDK%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20MQTT%20layer%20requires%20a%20MQTT%20client%20like%20Eclipse%20Paho%2C%20Mosquitto%20or%20any%20MQTT%20library%20that%20works%20on%20your%20device.%20The%20MQTT%20connection%20can%20also%20be%20used%20over%20Web%20Sockets.%3C%2FP%3E%0A%3CP%3EThere%20is%20no%20dynamic%20memory%20allocation%20in%20the%20Embedded%20C%20SDK.%20For%20constrained%20devices%20scenarios%2C%20you%20are%20in%20control%20of%20how%20much%20memory%20will%20be%20consumed%20by%20allocating%20the%20memory%20in%20the%20application%20and%20passing%20in%20the%20buffers%20with%20the%20SDK%20calls.%3C%2FP%3E%0A%3CP%3EThe%20following%20code%20snippet%20shows%20how%20the%20Embedded%20C%20SDK%20initialize%20the%20client%20to%20allow%20IoT%20Hub%20connectivity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3Eint%20main()%0A%7B%0A%2F%2FGet%20the%20default%20IoT%20Hub%20options%0Aaz_iot_hub_client_options%20options%20%3D%20az_iot_hub_client_options_default()%3B%0A%0A%2F%2FInitialize%20the%20client%20with%20hostname%2C%20device%20id%2C%20and%20options%0Aaz_iot_hub_client_init(%26amp%3Bmy_client%2C%20my_iothub_hostname%2C%20my_device_id%2C%20%26amp%3Boptions)%3B%0A%0A%2F%2FGet%20the%20MQTT%20user%20name%20to%20connect%0Aaz_iot_hub_client_get_user_name(%26amp%3Bmy_client%2C%20my_mqtt_user_name%2C%20%0Asizeof(my_mqtt_user_name)%2C%20%26amp%3Bmy_mqtt_user_name_length)%3B%0A%0A%2F%2FGet%20the%20MQTT%20client%20id%20to%20connect%0Aaz_iot_hub_client_get_client_id(%26amp%3Bmy_client%2C%20my_mqtt_client_id%2C%20%0Asizeof(my_mqtt_client_id)%2C%20%26amp%3Bmy_mqtt_client_id_length)%3B%0A%0A%2F%2FAt%20this%20point%20you%20are%20free%20to%20use%20my_mqtt_client_id%20and%20my_mqtt_user_name%20to%20connect%20using%20your%20MQTT%20client.%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1848419988%22%20id%3D%22toc-hId-1848419988%22%3EHow%20to%20get%20started%3F%3C%2FH3%3E%0A%3CP%3EThe%20best%20way%20to%20get%20started%20with%20the%20-ERR%3AREF-NOT-FOUND-Embedded%20C%20SDK%20is%20to%20see%20it%20in%20action!%20Feel%20free%20to%20try%20any%20of%20the%20samples%20available%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EIoT%20Hub%20Telemetry%3C%2FSTRONG%3E%3A%20Send%205%20telemetry%20messages%20using%20the%20IoT%20Hub%20Client.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EIoT%20Hub%20Twin%3C%2FSTRONG%3E%3A%20Use%20twin%20features%20such%20as%20updating%20reported%20properties%2C%20receiving%20the%20twin%20document%2C%20and%20receiving%20desired%20properties%20using%20the%20IoT%20Hub%20Client.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EIoT%20Hub%20Methods%3C%2FSTRONG%3E%3A%20Invoke%20device%20methods%20from%20the%20cloud.%20The%20sample%20supports%20a%20method%20named%20%22ping%22%20which%2C%20if%20successful%2C%20will%20return%20a%20%E2%80%9Cpong%E2%80%9D%20response.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EIoT%20Hub%20C2D%3C%2FSTRONG%3E%3A%20Receive%20and%20view%20incoming%20cloud%20to%20device%20(C2D)%20messages%20using%20the%20IoT%20Hub%20Client.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EDevice%20Provisioning%20Services%3C%2FSTRONG%3E%3A%20Register%20a%20device%20using%20the%20IoT%20Provisioning%20client%20%3CBR%20%2F%3EFor%20a%20high-level%20understanding%20of%20the%20architecture%20and%20components%20of%20the%20Embedded%20C%20SDK%2C%20take%20a%20look%20at%20the%20-ERR%3AREF-NOT-FOUND-state%20machine%20diagram%20which%20explains%20the%20SDK%20components%2C%20and%20a%20clear%20view%20of%20the%20separation%20of%20responsibilities%20between%20your%20application%20and%20the%20Embedded%20C%20SDK.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22toc-hId-40965525%22%20id%3D%22toc-hId-40965525%22%3ELet%20us%20know%20what%20you%20think!%3C%2FH3%3E%0A%3CP%3EAs%20we%20continue%20to%20work%20on%20improving%20the%20experience%20for%20IoT%20developers%2C%20we%20encourage%20you%20to%20provide%20feedback%20through%20our%20open%20source%20-ERR%3AREF-NOT-FOUND-GitHub%20repository%20and%20stay%20tuned%20on%20-ERR%3AREF-NOT-FOUND-Azure%20Updates%20for%20any%20new%20IoT%20SDK%20announcements.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1400406%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20have%20ever%20struggled%20to%20fit%20your%20application%20into%20a%20constrained%20IoT%20device%2C%20we%20have%20great%20news%20for%20you!%20We%20released%20the%20new%20Embedded%20C%20SDK%2C%20built%20to%20support%20microcontrollers%2C%20optimized%20for%20memory%20usage%20with%20no%20dynamic%20memory%20allocation%2C%20fully%20embracing%20MQTT%20and%20providing%20access%20to%20a%20number%20of%20Azure%20Services.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1400406%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20IoT%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IoT%20Hub%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

If you have ever struggled to fit your application into a constrained IoT device, we have great news for you! We released the new Embedded C SDK, built to support microcontrollers, optimized for memory usage with no dynamic memory allocation, fully embracing MQTT and providing access to a number of Azure Services.

 

 

Why do we need an Embedded C SDK?

As the IoT industry evolves, companies and developers are identifying many more opportunities to create amazing solutions for real world problems.
When we look at the devices that are enabling these digital transformation scenarios, we can find all sorts of devices going from pretty powerful hardware running full OS (Windows / Linux), like the Raspberry PI, all the way down to single core MCU (microcontrollers) – constrained devices like the ESP8266.
While you can easily fit any of the Azure SDKs into more powerful devices, doing the same with a constrained device has previously required an optimized version of the C SDK, along with specific compiling requirements to reduce its footprint for the limited resources available.
Additionally, scenarios with constrained devices installed in remote locations, bring additional challenges. These devices may require limited power sources like solar power and battery-operation. Also, the lack of Wi-Fi will require network alternatives like cellular, mesh networks, or LoRa.
Overall, we recognized all of these challenges and the corresponding gaps in what our existing C SDK could provide, so we completely redesigned a new and improved embedded C SDK. We're happy to present it as the newest addition to the Azure SDK family: the public preview of the “Azure SDK for Embedded C”.

 

Embedded C SDK explained

At its core, the embedded C SDK is a set of libraries that will help you take advantage of Azure IoT capabilities. It provides helper functions so your application can connect to Azure IoT Hub, send telemetry messages (device to cloud), receive cloud to device messages, direct device methods, and device twin metadata. It can also be provisioned using the device provisioning services.
IoT developers will now have the flexibility to bring any MQTT client, TLS and socket layer they prefer to their application, allowing for extreme optimization by leveraging libraries that are optimized for the target device.

 

Embedded C SDKEmbedded C SDK

 

The MQTT layer requires a MQTT client like Eclipse Paho, Mosquitto or any MQTT library that works on your device. The MQTT connection can also be used over Web Sockets.

There is no dynamic memory allocation in the Embedded C SDK. For constrained devices scenarios, you are in control of how much memory will be consumed by allocating the memory in the application and passing in the buffers with the SDK calls.

The following code snippet shows how the Embedded C SDK initialize the client to allow IoT Hub connectivity.

 

int main()
{
//Get the default IoT Hub options
az_iot_hub_client_options options = az_iot_hub_client_options_default();

//Initialize the client with hostname, device id, and options
az_iot_hub_client_init(&my_client, my_iothub_hostname, my_device_id, &options);

//Get the MQTT user name to connect
az_iot_hub_client_get_user_name(&my_client, my_mqtt_user_name, 
sizeof(my_mqtt_user_name), &my_mqtt_user_name_length);

//Get the MQTT client id to connect
az_iot_hub_client_get_client_id(&my_client, my_mqtt_client_id, 
sizeof(my_mqtt_client_id), &my_mqtt_client_id_length);

//At this point you are free to use my_mqtt_client_id and my_mqtt_user_name to connect using your MQTT client.
}

 

 

How to get started?

The best way to get started with the Embedded C SDK is to see it in action! Feel free to try any of the samples available:

  • IoT Hub Telemetry: Send 5 telemetry messages using the IoT Hub Client.
  • IoT Hub Twin: Use twin features such as updating reported properties, receiving the twin document, and receiving desired properties using the IoT Hub Client.
  • IoT Hub Methods: Invoke device methods from the cloud. The sample supports a method named "ping" which, if successful, will return a “pong” response.
  • IoT Hub C2D: Receive and view incoming cloud to device (C2D) messages using the IoT Hub Client.
  • Device Provisioning Services: Register a device using the IoT Provisioning client
    For a high-level understanding of the architecture and components of the Embedded C SDK, take a look at the state machine diagram which explains the SDK components, and a clear view of the separation of responsibilities between your application and the Embedded C SDK.

Let us know what you think!

As we continue to work on improving the experience for IoT developers, we encourage you to provide feedback through our open source GitHub repository and stay tuned on Azure Updates for any new IoT SDK announcements.