Capture the data
A typical IoT solution today, has many devices sending sensor data to a central location. For the purposes of this book, that location is the Azure public cloud, and devices connect to IoT Hub, a component of the Azure IoT Suite. Devices can connect to IoT Hub directly, if they are powerful enough to do so and run a full IP stack. Devices can also connect by using a gateway. The gateway can be used merely to relay the data, or it can do some processing locally (i.e. edge processing).
In this chapter, we will take a look at how IoT Hub works and how devices can connect to it. In Chapter 1, we have already seen how to create an IoT Hub using Azure CLI 2.0 and how to forward data to IoT Hub using the Particle Cloud. In later sections, we will see how to connect to IoT Hub without the help of Particle, by using protocols such as HTTP and MQTT.
In IoT scenarios, you often have to send messages to a device in addition to receiving messages. This type of two-way communication is possible with IoT Hub, and we will see how to achieve it. We will write an Azure Function that is able to accept a request to restart our device remotely which will give us a chance to work with the IoT Hub APIs and SDKs. This two-way connectivity is very similar to what you have seen before with MQTT.
IoT Hub is not the only way to capture data from devices. Event Hubs can be used as an alternative and we will take a look at its features and differences with IoT Hubs.