Tutorial: Connect a sample IoT Plug and Play device application running on Linux or Windows to IoT Hub
This tutorial shows you how to build a sample IoT Plug and Play device application, connect it to your IoT hub, and use the Azure IoT explorer tool to view the telemetry it sends. The sample application is written in C and is included in the Azure IoT device SDK for C. A solution builder can use the Azure IoT explorer tool to understand the capabilities of an IoT Plug and Play device without the need to view any device code.
Before you continue, make sure you've set up your environment, including your IoT hub.
You can run this tutorial on Linux or Windows. The shell commands in this tutorial follow the Linux convention for path separators '/
', if you're following along on Windows be sure to swap these separators for '\
'.
The prerequisites differ by operating system:
This tutorial assumes you're using Ubuntu Linux. The steps in this tutorial were tested using Ubuntu 18.04.
To complete this tutorial on Linux, install the following software on your local Linux environment:
Install GCC, Git, cmake, and all the required dependencies using the apt-get
command:
sudo apt-get update
sudo apt-get install -y git cmake build-essential curl libcurl4-openssl-dev libssl-dev uuid-dev
Verify the version of cmake
is above 2.8.12 and the version of GCC is above 4.4.7.
cmake --version
gcc --version
To complete this tutorial on Windows, install the following software in your local Windows environment:
- Visual Studio (Community, Professional, or Enterprise) - make sure you include the Desktop Development with C++ workload when you install Visual Studio.
- Git.
- CMake.
In this tutorial, you prepare a development environment you can use to clone and build the Azure IoT Hub Device C SDK.
Open a command prompt in the directory of your choice. Execute the following command to clone the Azure IoT C SDKs and Libraries GitHub repository into this location:
git clone https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
git submodule update --init
Expect this operation to take several minutes to complete.
You can build and run the code using Visual Studio or cmake
at the command line.
Open the root folder of the cloned repository. After a couple of seconds, the CMake support in Visual Studio creates all you need to run and debug the project.
When Visual Studio is ready, in Solution Explorer, navigate to the sample iothub_client/samples/pnp/pnp_simple_thermostat/.
Right-click on the pnp_simple_thermostat.c file and select Add Debug Configuration. Select Default.
Visual Studio opens the launch.vs.json file. Edit this file as shown in the following snippet to set the required environment variables. You made a note of the scope ID and enrollment primary key when you completed Set up your environment for the IoT Plug and Play quickstarts and tutorials:
{ "version": "0.2.1", "defaults": {}, "configurations": [ { "type": "default", "project": "iothub_client\\samples\\pnp\\pnp_simple_thermostat\\pnp_pnp_simple_thermostat.c", "projectTarget": "", "name": "pnp_simple_thermostat.c", "env": { "IOTHUB_DEVICE_SECURITY_TYPE": "DPS", "IOTHUB_DEVICE_DPS_ID_SCOPE": "<Your ID scope>", "IOTHUB_DEVICE_DPS_DEVICE_ID": "my-pnp-device", "IOTHUB_DEVICE_DPS_DEVICE_KEY": "<Your enrollment primary key>" } } ] }
Right-click on the pnp_simple_thermostat.c file and select Set as Startup Item.
To trace the code execution in Visual Studio, add a breakpoint to the
main
function in the pnp_simple_thermostat.c file.You can now run and debug the sample from the Debug menu.
The device is now ready to receive commands and property updates, and has started sending telemetry data to the hub. Keep the sample running as you complete the next steps.
You use the cmake command-line utility to build the code:
Create a cmake subdirectory in the root folder of the device SDK, and navigate to that folder:
cd azure-iot-sdk-c mkdir cmake cd cmake
Run the following commands to build the SDK and samples:
cmake -Duse_prov_client=ON -Dhsm_type_symm_key=ON -Drun_e2e_tests=OFF .. cmake --build .
In Set up your environment, you created four environment variables to configure the sample to use the Device Provisioning Service (DPS) to connect to your IoT hub:
- IOTHUB_DEVICE_SECURITY_TYPE with the value
DPS
- IOTHUB_DEVICE_DPS_ID_SCOPE with the DPS ID scope.
- IOTHUB_DEVICE_DPS_DEVICE_ID with the value
my-pnp-device
. - IOTHUB_DEVICE_DPS_DEVICE_KEY with the enrollment primary key.
- IOTHUB_DEVICE_DPS_ENDPOINT with the value
global.azure-devices-provisioning.net
.
To learn more about the sample configuration, see the sample readme.
To run the sample application in the SDK that simulates an IoT Plug and Play device sending telemetry to your IoT hub:
From the cmake folder, navigate to the folder that contains the executable file and run it:
# Bash
cd iothub_client/samples/pnp/pnp_simple_thermostat/
./pnp_simple_thermostat
REM Windows
cd iothub_client\samples\pnp\pnp_simple_thermostat\Debug
.\pnp_simple_thermostat.exe
Tip
To trace the code execution in Visual Studio on Windows, add a break point to the main
function in the pnp_simple_thermostat.c file.
The device is now ready to receive commands and property updates, and has started sending telemetry data to the hub. Keep the sample running as you complete the next steps.
After the device client sample starts, use the Azure IoT explorer tool to verify it's working.
Open Azure IoT explorer.
On the IoT hubs page, if you haven't already added a connection to your IoT hub, select + Add connection. Enter the connection string for the IoT hub you created previously and select Save.
On the IoT Plug and Play Settings page, select + Add > Local folder and select the local models folder where you saved your model files.
On the IoT hubs page, click on the name of the hub you want to work with. You see a list of devices registered to the IoT hub.
Click on the Device ID of the device you created previously.
The menu on the left shows the different types of information available for the device.
Select IoT Plug and Play components to view the model information for your device.
You can view the different components of the device. The default component and any extra ones. Select a component to work with.
Select the Telemetry page and then select Start to view the telemetry data the device is sending for this component.
Select the Properties (read-only) page to view the read-only properties reported for this component.
Select the Properties (writable) page to view the writable properties you can update for this component.
Select a property by it's name, enter a new value for it, and select Update desired value.
To see the new value show up select the Refresh button.
Select the Commands page to view all the commands for this component.
Select the command you want to test set the parameter if any. Select Send command to call the command on the device. You can see your device respond to the command in the command prompt window where the sample code is running.
This sample implements a simple IoT Plug and Play thermostat device. The thermostat model doesn't use IoT Plug and Play components. The DTDL model file for the thermostat device defines the telemetry, properties, and commands the device implements.
The device code uses the standard function to connect to your IoT hub:
deviceHandle = IoTHubDeviceClient_CreateFromConnectionString(connectionString, MQTT_Protocol)
The device sends the model ID of the DTDL model it implements in the connection request. A device that sends a model ID is an IoT Plug and Play device:
static const char g_ModelId[] = "dtmi:com:example:Thermostat;1";
...
IoTHubDeviceClient_SetOption(deviceHandle, OPTION_MODEL_ID, modelId)
The code that updates properties, handles commands, and sends telemetry is identical to the code for a device that doesn't use the IoT Plug and Play conventions.
The code uses the Parson library to parse JSON objects in the payloads sent from your IoT hub:
// JSON parser
#include "parson.h"
If you've finished with the quickstarts and tutorials, see Clean up resources.
This tutorial shows you how to build a sample IoT Plug and Play device application, connect it to your IoT hub, and use the Azure IoT explorer tool to view the telemetry it sends. The sample application is written in C# and is included in the Azure IoT SDK for C#. A solution builder can use the Azure IoT explorer tool to understand the capabilities of an IoT Plug and Play device without the need to view any device code.
Before you continue, make sure you've set up your environment, including your IoT hub.
You can run this tutorial on Linux or Windows. The shell commands in this tutorial follow the Linux convention for path separators '/
', if you're following along on Windows be sure to swap these separators for '\
'.
In this tutorial, you prepare a development environment you can use to clone and build the Azure IoT SDK for C# repository.
Open a command prompt in a folder of your choice. Run the following command to clone the Microsoft Azure IoT SDK for C# (.NET) GitHub repository into this location:
git clone https://github.com/Azure/azure-iot-sdk-csharp
You can now build the sample and run it. Run the following commands to build the sample:
cd azure-iot-sdk-csharp/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat
dotnet build
To run the sample, run the following command:
dotnet run
The device is now ready to receive commands and property updates, and has started sending telemetry data to the hub. Keep the sample running as you complete the next steps.
After the device client sample starts, use the Azure IoT explorer tool to verify it's working.
Open Azure IoT explorer.
On the IoT hubs page, if you haven't already added a connection to your IoT hub, select + Add connection. Enter the connection string for the IoT hub you created previously and select Save.
On the IoT Plug and Play Settings page, select + Add > Local folder and select the local models folder where you saved your model files.
On the IoT hubs page, click on the name of the hub you want to work with. You see a list of devices registered to the IoT hub.
Click on the Device ID of the device you created previously.
The menu on the left shows the different types of information available for the device.
Select IoT Plug and Play components to view the model information for your device.
You can view the different components of the device. The default component and any extra ones. Select a component to work with.
Select the Telemetry page and then select Start to view the telemetry data the device is sending for this component.
Select the Properties (read-only) page to view the read-only properties reported for this component.
Select the Properties (writable) page to view the writable properties you can update for this component.
Select a property by it's name, enter a new value for it, and select Update desired value.
To see the new value show up select the Refresh button.
Select the Commands page to view all the commands for this component.
Select the command you want to test set the parameter if any. Select Send command to call the command on the device. You can see your device respond to the command in the command prompt window where the sample code is running.
This sample implements a simple IoT Plug and Play thermostat device. The model this sample implements doesn't use IoT Plug and Play components. The Digital Twins definition language (DTDL) model file for the thermostat device defines the telemetry, properties, and commands the device implements.
The device code connects to your IoT hub using the standard CreateFromConnectionString
method. The device sends the model ID of the DTDL model it implements in the connection request. A device that sends a model ID is an IoT Plug and Play device:
private static void InitializeDeviceClientAsync()
{
var options = new ClientOptions
{
ModelId = ModelId,
};
s_deviceClient = DeviceClient.CreateFromConnectionString(s_deviceConnectionString, TransportType.Mqtt, options);
s_deviceClient.SetConnectionStatusChangesHandler((status, reason) =>
{
s_logger.LogDebug($"Connection status change registered - status={status}, reason={reason}.");
});
}
The model ID is stored in the code as shown in the following snippet:
private const string ModelId = "dtmi:com:example:Thermostat;1";
The code that updates properties, handles commands, and sends telemetry is identical to the code for a device that doesn't use the IoT Plug and Play conventions.
The sample uses a JSON library to parse JSON objects in the payloads sent from your IoT hub:
using Newtonsoft.Json;
...
DateTime since = JsonConvert.DeserializeObject<DateTime>(request.DataAsJson);
If you've finished with the quickstarts and tutorials, see Clean up resources.
This tutorial shows you how to build a sample IoT Plug and Play device application, connect it to your IoT hub, and use the Azure IoT explorer tool to view the telemetry it sends. The sample application is written in Java and is included in the Azure IoT device SDK for Java. A solution builder can use the Azure IoT explorer tool to understand the capabilities of an IoT Plug and Play device without the need to view any device code.
Before you continue, make sure you've set up your environment, including your IoT hub.
You can run this tutorial on Linux or Windows. The shell commands in this tutorial follow the Linux convention for path separators '/
', if you're following along on Windows be sure to swap these separators for '\
'.
To complete this tutorial, install the following software in your local development environment:
In this tutorial, you prepare a development environment you can use to clone and build the Azure IoT Hub Device Java SDK.
Open a command prompt in the directory of your choice. Execute the following command to clone the Azure IoT Java SDKs and Libraries GitHub repository into this location:
git clone https://github.com/Azure/azure-iot-sdk-java.git
Navigate to the root folder of the thermostat sample in the cloned Java SDK repository and build it:
cd azure-iot-sdk-java/device/iot-device-samples/pnp-device-sample/thermostat-device-sample
mvn clean package
In Set up your environment, you created four environment variables to configure the sample to use the Device Provisioning Service (DPS) to connect to your IoT hub:
- IOTHUB_DEVICE_SECURITY_TYPE with the value
DPS
- IOTHUB_DEVICE_DPS_ID_SCOPE with the DPS ID scope.
- IOTHUB_DEVICE_DPS_DEVICE_ID with the value
my-pnp-device
. - IOTHUB_DEVICE_DPS_DEVICE_KEY with the enrollment primary key.
- IOTHUB_DEVICE_DPS_ENDPOINT with the value
global.azure-devices-provisioning.net
.
To learn more about the sample configuration, see the sample readme.
From the /device/iot-device-samples/pnp-device-sample/thermostat-device-sample folder, run the application:
mvn exec:java -Dexec.mainClass="samples.com.microsoft.azure.sdk.iot.device.Thermostat"
The device is now ready to receive commands and property updates, and has started sending telemetry data to the hub. Keep the sample running as you complete the next steps.
After the device client sample starts, use the Azure IoT explorer tool to verify it's working.
Open Azure IoT explorer.
On the IoT hubs page, if you haven't already added a connection to your IoT hub, select + Add connection. Enter the connection string for the IoT hub you created previously and select Save.
On the IoT Plug and Play Settings page, select + Add > Local folder and select the local models folder where you saved your model files.
On the IoT hubs page, click on the name of the hub you want to work with. You see a list of devices registered to the IoT hub.
Click on the Device ID of the device you created previously.
The menu on the left shows the different types of information available for the device.
Select IoT Plug and Play components to view the model information for your device.
You can view the different components of the device. The default component and any extra ones. Select a component to work with.
Select the Telemetry page and then select Start to view the telemetry data the device is sending for this component.
Select the Properties (read-only) page to view the read-only properties reported for this component.
Select the Properties (writable) page to view the writable properties you can update for this component.
Select a property by it's name, enter a new value for it, and select Update desired value.
To see the new value show up select the Refresh button.
Select the Commands page to view all the commands for this component.
Select the command you want to test set the parameter if any. Select Send command to call the command on the device. You can see your device respond to the command in the command prompt window where the sample code is running.
This sample implements a simple IoT Plug and Play thermostat device. The model this sample implements doesn't use IoT Plug and Play components. The DTDL model file for the thermostat device defines the telemetry, properties, and commands the device implements.
The device code uses the standard DeviceClient
class to connect to your IoT hub. The device sends the model ID of the DTDL model it implements in the connection request. A device that sends a model ID is an IoT Plug and Play device:
private static void initializeDeviceClient() throws URISyntaxException, IOException {
ClientOptions options = new ClientOptions();
options.setModelId(MODEL_ID);
deviceClient = new DeviceClient(deviceConnectionString, protocol, options);
deviceClient.registerConnectionStatusChangeCallback((status, statusChangeReason, throwable, callbackContext) -> {
log.debug("Connection status change registered: status={}, reason={}", status, statusChangeReason);
if (throwable != null) {
log.debug("The connection status change was caused by the following Throwable: {}", throwable.getMessage());
throwable.printStackTrace();
}
}, deviceClient);
deviceClient.open();
}
The model ID is stored in the code as shown in the following snippet:
private static final String MODEL_ID = "dtmi:com:example:Thermostat;1";
The code that updates properties, handles commands, and sends telemetry is identical to the code for a device that doesn't use the IoT Plug and Play conventions.
The sample uses a JSON library to parse JSON objects in the payloads sent from your IoT hub:
import com.google.gson.Gson;
...
Date since = new Gson().fromJson(jsonRequest, Date.class);
If you've finished with the quickstarts and tutorials, see Clean up resources.
This tutorial shows you how to build a sample IoT Plug and Play device application, connect it to your IoT hub, and use the Azure IoT explorer tool to view the telemetry it sends. The sample application is written in Node.js and is included in the Azure IoT device SDK for Node.js. A solution builder can use the Azure IoT explorer tool to understand the capabilities of an IoT Plug and Play device without the need to view any device code.
Before you continue, make sure you've set up your environment, including your IoT hub.
You can run this tutorial on Linux or Windows. The shell commands in this tutorial follow the Linux convention for path separators '/
', if you're following along on Windows be sure to swap these separators for '\
'.
To complete this tutorial, you need Node.js on your development machine. You can download the latest recommended version for multiple platforms from nodejs.org.
You can verify the current version of Node.js on your development machine using the following command:
node --version
In this tutorial, you prepare a development environment you can use to clone and build the Azure IoT Hub Device SDK for Node.js.
Open a command prompt in the directory of your choice. Execute the following command to clone the Microsoft Azure IoT SDK for Node.js GitHub repository into this location:
git clone https://github.com/Azure/azure-iot-sdk-node
You use the device SDK to build the included sample code. The application you build simulates a device that connects to an IoT hub. The application sends telemetry and properties and receives commands.
In a local terminal window, go to the folder of your cloned repository and navigate to the /azure-iot-sdk-node/device/samples/javascript folder. Then run the following command to install the required libraries:
npm install
This sample implements a simple IoT Plug and Play thermostat device. The model this sample implements doesn't use IoT Plug and Play components. The DTDL model file for the thermostat device defines the telemetry, properties, and commands the device implements.
Open the pnp_simple_thermostat.js file. In this file, you can see how to:
- Import the required interfaces.
- Write a property update handler and a command handler.
- Handle desired property patches and send telemetry.
- Optionally, provision your device using the Azure Device Provisioning Service (DPS).
In the main function, you can see how it all comes together:
- Create the device from your connection string or provision it using DPS.)
- Use the modelID option to specify the IoT Plug and Play device model.
- Enable the command handler.
- Send telemetry from the device to your hub.
- Get the devices twin and update the reported properties.
- Enable the desired property update handler.
In Set up your environment, you created four environment variables to configure the sample to use the Device Provisioning Service (DPS) to connect to your IoT hub:
- IOTHUB_DEVICE_SECURITY_TYPE with the value
DPS
- IOTHUB_DEVICE_DPS_ID_SCOPE with the DPS ID scope.
- IOTHUB_DEVICE_DPS_DEVICE_ID with the value
my-pnp-device
. - IOTHUB_DEVICE_DPS_DEVICE_KEY with the enrollment primary key.
- IOTHUB_DEVICE_DPS_ENDPOINT with the value
global.azure-devices-provisioning.net
.
To learn more about the sample configuration, see the sample readme.
Run the sample application to simulate an IoT Plug and Play device that sends telemetry to your IoT hub. To run the sample application, use the following command:
node pnp_simple_thermostat.js
You see the following output, indicating the device has begun sending telemetry data to the hub, and is now ready to receive commands and property updates.
Keep the sample running as you complete the next steps.
After the device client sample starts, use the Azure IoT explorer tool to verify it's working.
Open Azure IoT explorer.
On the IoT hubs page, if you haven't already added a connection to your IoT hub, select + Add connection. Enter the connection string for the IoT hub you created previously and select Save.
On the IoT Plug and Play Settings page, select + Add > Local folder and select the local models folder where you saved your model files.
On the IoT hubs page, click on the name of the hub you want to work with. You see a list of devices registered to the IoT hub.
Click on the Device ID of the device you created previously.
The menu on the left shows the different types of information available for the device.
Select IoT Plug and Play components to view the model information for your device.
You can view the different components of the device. The default component and any extra ones. Select a component to work with.
Select the Telemetry page and then select Start to view the telemetry data the device is sending for this component.
Select the Properties (read-only) page to view the read-only properties reported for this component.
Select the Properties (writable) page to view the writable properties you can update for this component.
Select a property by it's name, enter a new value for it, and select Update desired value.
To see the new value show up select the Refresh button.
Select the Commands page to view all the commands for this component.
Select the command you want to test set the parameter if any. Select Send command to call the command on the device. You can see your device respond to the command in the command prompt window where the sample code is running.
If you've finished with the quickstarts and tutorials, see Clean up resources.
This tutorial shows you how to build a sample IoT Plug and Play device application, connect it to your IoT hub, and use the Azure IoT explorer tool to view the telemetry it sends. The sample application is written for Python and is included in the Azure IoT Hub Device SDK for Python. A solution builder can use the Azure IoT explorer tool to understand the capabilities of an IoT Plug and Play device without the need to view any device code.
Before you continue, make sure you've set up your environment, including your IoT hub.
To complete this tutorial, you need Python installed on your development machine. Check the Azure IoT Python SDK for current Python version requirements. You can check your Python version with the following command:
python --version
You can download the latest recommended version for multiple platforms from python.org.
In your local Python environment, install the package as follows:
pip install azure-iot-device
Clone the Python SDK IoT repository:
git clone --branch v2 https://github.com/Azure/azure-iot-sdk-python
The azure-iot-sdk-python/samples/pnp folder contains the sample code for the IoT Plug and Play device. This tutorial uses the simple_thermostat.py file. This sample code implements an IoT Plug and Play compatible device and uses the Azure IoT Python Device Client Library.
Open the simple_thermostat.py file in a text editor. Notice how it:
Defines a single device twin model identifier (DTMI) that uniquely represents the Thermostat. A DTMI must be known to the user and varies dependent on the scenario of device implementation. For the current sample, the model represents a thermostat that has telemetry, properties, and commands associated with monitoring temperature.
Has functions to define command handler implementations. You write these handlers to define how the device responds to command requests.
Has a function to define a command response. You create command response functions to send a response back to your IoT hub.
Defines an input keyboard listener function to let you quit the application.
Has a main function. The main function:
Uses the device SDK to create a device client and connect to your IoT hub.
Updates properties. The Thermostat model defines
targetTemperature
andmaxTempSinceLastReboot
as the two properties for the Thermostat. Properties are updated using thepatch_twin_reported_properties
method defined on thedevice_client
.Starts listening for command requests using the execute_command_listener function. The function sets up a 'listener' to listen for commands coming from the service. When you set up the listener, you provide a
method_name
,user_command_handler
, andcreate_user_response_handler
.- The
user_command_handler
function defines what the device should do when it receives a command. - The
create_user_response_handler
function creates a response to be sent to your IoT hub when a command executes successfully. You can view this response in the portal.
- The
Starts sending telemetry. The pnp_send_telemetry is defined in the pnp_methods.py file. The sample code uses a loop to call this function every eight seconds.
Disables all the listeners and tasks, and exist the loop when you press Q or q.
In Set up your environment, you created four environment variables to configure the sample to use the Device Provisioning Service (DPS) to connect to your IoT hub:
- IOTHUB_DEVICE_SECURITY_TYPE with the value
DPS
- IOTHUB_DEVICE_DPS_ID_SCOPE with the DPS ID scope.
- IOTHUB_DEVICE_DPS_DEVICE_ID with the value
my-pnp-device
. - IOTHUB_DEVICE_DPS_DEVICE_KEY with the enrollment primary key.
- IOTHUB_DEVICE_DPS_ENDPOINT with the value
global.azure-devices-provisioning.net
.
To learn more about the sample configuration, see the sample readme.
Now that you've seen the code, use the following command to run the sample:
python simple_thermostat.py
You see the following output, which indicates the device is sending telemetry data to the hub, and is now ready to receive commands and property updates:
Listening for command requests and property updates
Press Q to quit
Sending telemetry for temperature
Sent message
Keep the sample running as you complete the next steps.
After the device client sample starts, use the Azure IoT explorer tool to verify it's working.
Open Azure IoT explorer.
On the IoT hubs page, if you haven't already added a connection to your IoT hub, select + Add connection. Enter the connection string for the IoT hub you created previously and select Save.
On the IoT Plug and Play Settings page, select + Add > Local folder and select the local models folder where you saved your model files.
On the IoT hubs page, click on the name of the hub you want to work with. You see a list of devices registered to the IoT hub.
Click on the Device ID of the device you created previously.
The menu on the left shows the different types of information available for the device.
Select IoT Plug and Play components to view the model information for your device.
You can view the different components of the device. The default component and any extra ones. Select a component to work with.
Select the Telemetry page and then select Start to view the telemetry data the device is sending for this component.
Select the Properties (read-only) page to view the read-only properties reported for this component.
Select the Properties (writable) page to view the writable properties you can update for this component.
Select a property by it's name, enter a new value for it, and select Update desired value.
To see the new value show up select the Refresh button.
Select the Commands page to view all the commands for this component.
Select the command you want to test set the parameter if any. Select Send command to call the command on the device. You can see your device respond to the command in the command prompt window where the sample code is running.
If you've finished with the quickstarts and tutorials, see Clean up resources.
If you're developing for constrained devices, you can use IoT Plug and Play with:
This article includes links and resources for these constrained scenarios.
Many of the samples below require a specific hardware device and the prerequisites are different for each of the samples. Follow the link to the relevant sample for detailed prerequisites, configuration, and build instructions.
The SDK for Embedded C offers a lightweight solution to connect constrained devices to Azure IoT services, including using the IoT Plug and Play conventions. The following links include samples for MCU-based devices and for educational and debugging purposes.
For a complete end-to-end tutorial using the SDK for Embedded C, the Device Provisioning Service, and IoT Plug and Play on an MCU, see Repurpose PIC-IoT Wx Development Board to Connect to Azure through IoT Hub Device Provisioning Service.
The SDK for Embedded C repository contains several samples that show you how to use IoT Plug and Play:
Note
These samples are shown running on Windows and Linux for educational and debugging purposes. In a production scenario, the samples are intended for constrained devices only.
Eclipse ThreadX includes a lightweight layer that adds native connectivity to Azure IoT cloud services. This layer provides a simple mechanism to connect constrained devices to Azure IoT while using the advanced features of Eclipse ThreadX. To learn more, see the Eclipse ThreadX overview.
The Eclipse ThreadX samples are provided with different kinds of IDE and toolchain combinations, such as:
- IAR: IAR's Embedded Workbench IDE
- GCC/CMake: Build on top of the open-source CMake build system and GNU Arm Embedded toolchain.
- MCUExpresso: NXP's MCUXpresso IDE
- STM32Cube: STMicroelectronics's STM32Cube IDE
- MPLAB: Microchip's MPLAB X IDE
The following table lists samples that show you how to get started on different devices with Eclipse ThreadX and IoT Plug and Play:
Manufacturer | Device | Samples |
---|---|---|
Microchip | ATSAME54-XPRO | GCC/CMake • IAR • MPLAB |
MXCHIP | AZ3166 | GCC/CMake |
NXP | MIMXRT1060-EVK | GCC/CMake • IAR • MCUXpresso |
STMicroelectronics | 32F746GDISCOVERY | IAR • STM32Cube |
STMicroelectronics | B-L475E-IOT01 | GCC/CMake • IAR • STM32Cube |
STMicroelectronics | B-L4S5I-IOT01 | GCC/CMake • IAR • STM32Cube |
In this tutorial, you've learned how to connect an IoT Plug and Play device to an IoT hub. To learn more about how to build a solution that interacts with your IoT Plug and Play devices, see: