|
| 1 | +--- |
| 2 | +title: Device development introduction |
| 3 | +titleSuffix: Azure IoT |
| 4 | +description: An overview of Azure IoT device development including an introduction to the device SDKs, modeling, IoT Edge modules, and a survey of the available tools. |
| 5 | +ms.service: iot-fundamentals |
| 6 | +services: iot-fundamentals |
| 7 | +author: dominicbetts |
| 8 | +ms.author: dobett |
| 9 | +ms.topic: overview |
| 10 | +ms.date: 03/16/2023 |
| 11 | +ms.custom: template-overview |
| 12 | + |
| 13 | +# As a solution builder or device developer I want a high-level overview of the issues around device development so that I can easily find relevant content. |
| 14 | +--- |
| 15 | + |
| 16 | +# Device development |
| 17 | + |
| 18 | +This overview introduces some of the key concepts around developing devices to connect to a typical Azure IoT solution. Each section includes links to content that provides further detail and guidance. |
| 19 | + |
| 20 | +IoT Central applications use the IoT Hub and the Device Provisioning Service (DPS) services internally. Therefore, the concepts in this article apply whether you're using IoT Central to explore an IoT scenario or building your solution by using IoT Hub and DPS. |
| 21 | + |
| 22 | +:::image type="content" source="media/iot-overview-device-development/iot-architecture.svg" alt-text="High-level IoT solution architecture diagram that highlights device connectivity areas" border="false"::: |
| 23 | + |
| 24 | +In Azure IoT, a device developer writes the code to run on the device. This code typically: |
| 25 | + |
| 26 | +- Establishes a secure connection to a cloud endpoint. |
| 27 | +- Sends telemetry collected from attached sensors to the cloud. |
| 28 | +- Manages device state and synchronizes that state with the cloud. |
| 29 | +- Responds to commands sent from the cloud. |
| 30 | +- Enables the installation of software updates from the cloud. |
| 31 | +- Enables the device to keep functioning while it's disconnected from the cloud. |
| 32 | + |
| 33 | +## Device types |
| 34 | + |
| 35 | +IoT devices can be separated into two broad categories, microcontrollers (MCUs) and microprocessors (MPUs). |
| 36 | + |
| 37 | +MCUs are less expensive and simpler to operate than MPUs. An MCU contains many of the functions, such as memory, interfaces, and I/O within the chip itself. An MPU draws this functionality from components in supporting chips. An MCU often uses a real-time OS (RTOS) or runs bare-metal (no OS) and provides real-time responses and highly deterministic reactions to external events. |
| 38 | + |
| 39 | +MPUs generally run a general purpose OS, such as Windows, Linux, or MacOSX that provides a nondeterministic real-time response. There's typically no guarantee as to when a task will complete. |
| 40 | + |
| 41 | +[Windows for IoT](/windows/iot/product-family/windows-iot) is an embedded version of Windows for MPUs with cloud connectivity that lets you create secure devices with easy provisioning and management. |
| 42 | + |
| 43 | +[Azure RTOS](/rtos/overview-rtos) is a real time operating system for IoT and edge devices powered by MCUs. Azure RTOS is designed to support highly constrained devices that are battery powered and have less than 64 KB of flash memory. |
| 44 | + |
| 45 | +[Azure Sphere](/azure-sphere/product-overview/what-is-azure-sphere) is a secure, high-level application platform with built-in communication and security features for internet-connected devices. It comprises a secured, connected, crossover MCU, a custom high-level Linux-based operating system, and a cloud-based security service that provides continuous, renewable security. |
| 46 | + |
| 47 | +## Primitives |
| 48 | + |
| 49 | +An Azure IoT device can use the following primitives when it interacts with the cloud: |
| 50 | + |
| 51 | +- *Device-to-cloud* messages to send time series telemetry to the cloud. For example, temperature data collected from a sensor attached to the device. |
| 52 | +- *File uploads* for media files such as captured images and video. Intermittently connected devices can send telemetry batches. Devices can compress uploads to save bandwidth. |
| 53 | +- *Device twins* to share and synchronize state data with the cloud. For example, a device can use the device twin to report the current state of a valve it controls to the cloud and to receive a desired target temperature from the cloud. |
| 54 | +- *Digital twins* to represent a device in the digital world. For example, a digital twin can represent a device's physical location, its capabilities, and its relationships with other devices. |
| 55 | +- *Direct methods* to receive commands from the cloud. A direct method can have parameters and return a response. For example, the cloud can call a direct method to request the device to reboot in 30 seconds. |
| 56 | +- *Cloud-to-device* messages to receive one-way notifications from the cloud. For example, a notification that an update is ready to download. |
| 57 | + |
| 58 | +## Device SDKs |
| 59 | + |
| 60 | +The device SDKs provide high-level abstractions that let you use the primitives without knowledge of the underlying communications protocols. The device SDKs also handle the details of establishing a secure connection to the cloud and authenticating the device. |
| 61 | + |
| 62 | +For MPU devices, device SDKs are available for the following languages: |
| 63 | + |
| 64 | +- [C](https://github.com/Azure/azure-iot-sdk-c/) |
| 65 | +- [Python](https://github.com/Azure/azure-iot-sdk-python/) |
| 66 | +- [C# (.NET)](https://github.com/Azure/azure-iot-sdk-csharp/) |
| 67 | +- [Node.js](https://github.com/Azure/azure-iot-sdk-node/) |
| 68 | +- [Java](https://github.com/Azure/azure-iot-sdk-java/) |
| 69 | + |
| 70 | +For MCU devices, see: |
| 71 | + |
| 72 | +- [Azure RTOS Middleware](https://github.com/azure-rtos/) |
| 73 | +- [FreeRTOS Middleware](https://github.com/Azure/azure-iot-middleware-freertos) |
| 74 | +- [Azure SDK for Embedded C](https://github.com/Azure/azure-sdk-for-c) |
| 75 | + |
| 76 | +## Samples |
| 77 | + |
| 78 | +All of the device SDKs include samples that demonstrate how to use the SDK to connect to the cloud, send telemetry, and use the other primitives. |
| 79 | + |
| 80 | +You can find more samples in the [code sample browser](/samples/browse/?expanded=azure&products=azure-iot%2Cazure-iot-edge%2Cazure-iot-pnp%2Cazure-rtos). |
| 81 | + |
| 82 | +## Device development without a device SDK |
| 83 | + |
| 84 | +Although you're recommended to use one of the device SDKS, there may be scenarios where you prefer not to. In these scenarios, your device code must directly use one of the communication protocols that IoT Hub and the Device Provisioning Service (DPS) support. |
| 85 | + |
| 86 | +For more information, see: |
| 87 | + |
| 88 | +- [Using the MQTT protocol directly (as a device)](../iot-hub/iot-hub-mqtt-support.md#using-the-mqtt-protocol-directly-as-a-device) |
| 89 | +- [Using the AMQP protocol directly (as a device)](../iot-hub/iot-hub-amqp-support.md#device-client) |
| 90 | + |
| 91 | +## Device modeling |
| 92 | + |
| 93 | +IoT Plug and Play enables solution builders to integrate IoT devices with their solutions without any manual configuration. At the core of IoT Plug and Play, is a device model that a device uses to advertise its capabilities to an IoT Plug and Play-enabled application such as IoT Central. This model is structured as a set of elements that define: |
| 94 | + |
| 95 | +- *Properties* that represent the read-only or writable state of a device or other entity. For example, a device serial number may be a read-only property and a target temperature on a thermostat may be a writable property. |
| 96 | +- *Telemetry* that's the data emitted by a device, whether the data is a regular stream of sensor readings, an occasional error, or an information message. |
| 97 | +- *Commands* that describe a function or operation that can be done on a device. For example, a command could reboot a gateway or take a picture using a remote camera. |
| 98 | + |
| 99 | +You can group these elements in interfaces to reuse across models to make collaboration easier and to speed up development. |
| 100 | + |
| 101 | +As a device developer, when you implement an IoT Plug and Play device there are a set of conventions to follow. These conventions provide a standard way to implement the device model in code by using the primitives available in the device SDKs. |
| 102 | + |
| 103 | +To learn more, see: |
| 104 | + |
| 105 | +- [What is IoT Plug and Play?](../iot-develop/overview-iot-plug-and-play.md) |
| 106 | +- [IoT Plug and Play modeling guide](../iot-develop/concepts-modeling-guide.md) |
| 107 | + |
| 108 | +## Containerized device code |
| 109 | + |
| 110 | +Using containers, such as Docker, to run your device code lets you deploy code to your devices by using the capabilities of the container infrastructure. Containers also let you define a runtime environment for your code with all the required library and package versions installed. Containers make it easier to deploy updates and to manage the lifecycle of your devices. |
| 111 | + |
| 112 | +Azure IoT Edge runs device code in containers. You can use Azure IoT Edge to deploy code modules to your devices. To learn more, see [Develop your own IoT Edge modules](../iot-edge/module-development.md). |
| 113 | + |
| 114 | +> [!TIP] |
| 115 | +> Azure IoT Edge enables multiple scenarios. In addition to running your IoT device code in containers, you can use Azure IoT Edge to run Azure services on your devices and implement field gateways. For more information, see [What is Azure IoT Edge?](../iot-edge/about-iot-edge.md). |
| 116 | +
|
| 117 | +## Development tools |
| 118 | + |
| 119 | +The following table lists some of the key development tools that you can use to develop IoT devices: |
| 120 | + |
| 121 | +| Tool | Description | |
| 122 | +| --- | --- | |
| 123 | +| [Azure IoT Hub (VS Code extension)](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) | This VS Code extension lets you manage your IoT Hub resources and devices from within VS Code. | |
| 124 | +| [Azure IoT explorer](howto-use-iot-explorer.md) | This cross-platform tool lets you manage your IoT Hub resources and devices from a desktop application. | |
| 125 | +| [Azure IoT extension for Azure CLI](https://learn.microsoft.com/en-gb/cli/azure/service-page/azure%20iot) | This CLI extension includes commands such as `az iot device simulate`, `az iot device c2d-message`, and `az iot hub monitor-events` that help you test interactions with devices. | |
| 126 | + |
| 127 | +## Next steps |
| 128 | + |
| 129 | +Now that you've seen an overview of device development in Azure IoT solutions, some suggested next steps include: |
| 130 | + |
| 131 | +- [Device infrastructure and connectivity](iot-overview-connectivity.md). |
0 commit comments