IOT EDGE – The Internet of Things on Azure
Azure IoT Edge is an Internet of Things (IoT) service that builds on top of IoT Hub and enables users to carry out edge computing. This means that the data is analyzed on the devices rather than in the cloud itself. With Edge computing, you can avoid transferring raw data by carrying out data cleaning, aggregation, and analysis on the device itself, and then send the insights gained to the cloud. This will result in reduced bandwidth costs, quicker response times, and reduced traffic. For example, when processing or streaming a video, these operations can be done by communicating directly with other IoT devices instead of sending them to the cloud itself.
LET’S DO AN OVERVIEW OF IOT EDGE COMPONENTS
Azure IoT Edge is built with three components: IoT Edge modules, IoT Edge runtime, and a cloud-based interface.
IoT Edge Modules
IoT Edge Module are containers that run Azure services, third-party services, or our own code. These modules are deployed to IoT Edge devices and execute locally on those devices. Azure IoT Edge supports Linux, Windows and Java, .NET Core 2.0, Node.js, C, and Python.
IoT Edge Runtime
The IoT Edge Runtime runs on each IoT Edge device and manages the modules deployed there. It allows monitoring and managing the device and eases the communication between the modules, the device, other devices, and the cloud. This runtime supports both Linux and Windows operating systems.
Cloud-based Interface
A cloud-based interface enables to remotely monitor and manage the IoT Edge devices. This service allows to create and configure workloads to be run on a specific type of device, send a workload to a set of devices, and monitor workloads running on the devices in the field.
DIGGING DEEP INTO THE IOT EDGE RUNTIME
Azure IoT Edge Runtime is composite by two modules: IoT Edge Agent and IoT Edge Hub.
IoT Edge Agent - Module responsible to instantiate the modules, ensuring that they continue to run, and reporting their status back to the IoT Hub.
IoT Edge Hub – Module that acts as a local proxy for IoT Hub by exposing the same protocol endpoints as IoT Hub. In other words, clients can connect to the IoT Edge runtime just as they would to IoT Hub.
Message Routing – Device-to-Cloud Communication
IoT Edge Hub can either use the AMQP or the MQTT protocol to communicate upstream with the cloud, independently from protocols used by downstream devices. AMQP is the default protocol.
The routes for the communication device-to-cloud are in the deployment manifest file. A deployment manifest tells an IoT Edge device (or a group of devices) which modules to install and how to configure them. Deployment manifests include the desired properties for each module twin. IoT Edge devices report back the reported properties for each module.
The routes are defined in the property Edge Hub in the deployment manifest file. The routes architecture is defined by:
FROM <source> WHERE <condition> INTO <sink>
The route bellow is an example of a device-to-cloud message sent by a specific module through some output. In other words, every output from the specific module is sent to upstream. This upstream represents the IoT Hub.
/messages/modules/<moduleId>/outputs/* INTO $upstream
Message Routing – Module-to-Module Communication
The IoT Edge Hub also enables device-to-module, module-to-module, and device-to-device communications by brokering messages. It supports two brokering mechanisms: Message Routing and the MQTT broker. Using message routing, you can also route messages into another module in the same manner as the device-to-cloud. By using a message routing mechanism, your module (container) does not depend on other modules, and the module user can define routing separately.
FROM /messages/modules/Module1/outputs/output1 INTO EndPoint(\"/modules/Module2/inputs/input1\")
How did we implement IoT Edge Azure in our INSIGHT Scanner?
An example of how we implemented IoT Edge Azure in our INSIGHT scanner is represented in the image bellow. Each scanner represents an IoT Edge device, and each device contains one IoT Edge Module that contains the logic of the motor inside the scanner. Every time the motor throws an error, a message is sent through the message routing to the IoT Hub.
The perks we found of working with IoT Edge Azure:
IoT Edge Azure works even if there is no Internet connection at the client location. IoT Edge Hub can determine if there is a connection or not. Once a connection is reestablished, it syncs all the data.
Supports two-way communication from device to cloud and vice-versa.
The ability to implement modularization allows us to decrease the coupling and dependency between modules. This way it is also possible for developers to work on different modules independently, not needing to wait for a module to be finished to work on a different one.
Open-Source Platform: Azure IoT Edge is available as an open-source project on GitHub.
Use of containers: Each module can be managed and maintained separately without having to deploy the entire application. The container images are stored in the standard registry either in the cloud or within the data center. You can build a CI/CD pipeline to automatically push the latest version of modules (container images) to multiple edge locations.
See you in our next blog post!