Begin IoT — The Azure Way !!
Here we have yet another interesting topic that is creating a lot of buzz in the digital and smart world that we are in. 😀
There are so many interesting open questions that comes to our mind when we hear ‘Internet of Things’ right ??
What are ‘Things’ in ‘Internet of Things’ ?
Why are ‘Things’ important in IoT ?
Why cloud for IoT ?
How does information generated from IoT create value ?
What is the Scope of IoT ?
Now, before narrowing down to ‘How to Use IoT’, we first need to understand ‘What is IoT’, next step is to understand ‘What is IoT over the Azure Cloud’ Post this we will see a small demonstration on End to End solution approach with the help of Azure Services for Internet of Things.
Internet of Things
IoT itself has so many definitions, because the domain itself is so vast, but to make it shorter, it is an approach to Collect Data, to connect to Devices, to make Devices Smarter
IoT basically exchanges Information/Data through devices, as devices do store a lot of data that is useful for human beings and Internet enables devices to communicate to each other.
With the rise of Internet and the rise in the data that gets generated online like the amount of shopping that we do, the amount of browsing that we do, the amount of food that we order, and usage of lot of applications on the Internet, ‘Analytics’ gets into picture from day to day life.
For all the data streaming and analytics that we are talking about, the Solution is ‘Internet of Things’ — These Devices collect the data and only Job remaining for us is to use this information
We can use this data for n number of purposes, like to serve the customer better, like to make better medicines, make better machineries. The same thing is what data science is doing and that’s what Internet is doing for us. But for all this, we need someway or the other to collect the data, when it comes to human beings, YES we are the sharpest people on Earth, but the question is when it comes to accuracy, the only problem lies is, human won’t be as accurate as the machine is. So we need machine to collect this data.
Now connecting the dots, because the data is huge and the amount of data generated is huge on the Internet, it has given us a solution, and this solution is IoT. 😊
One futuristic example of IoT are the Driverless Cars
These cars don’t have drivers and are sensible enough to take you to your destination on their own. Equipped with tons of devices like sensors, gyroscopes, cloud architecture, internet and more, these cars sense huge chunks of data on traffic, pedestrians, conditions of the road such speed breakers, potholes, corners and sharp turns and immediately process them at rapid speeds. This information is passed to the controller which takes corresponding driving decisions. Artificial Intelligence and Machine Learning are crucial aspects of driverless cars as well.
IoT on Azure
Now that we have been convinced enough on yes we need smarter devices and yes we need a solution to connect devices, collect data. The next step is to narrow down to a find a platform that can provide solution for various computations and services.
Azure gives ready to use services to make use the data that gets generated from devices. Azure provides software services and computing and we can rent these services for a particular time.
Getting to the solution from initial brainstorming queries.
Why Cloud for IoT :
Easy to provision, use and manage
Pay as you go, scale as you need
It has a global reach
It definetely provides end to end security and privacyScope of IoT
Today, IoT is being implemented everywhere which is of human concern like smart city, smart environment, security, smart business process, smart agriculture, home automation and hethcare.
IoT Solution Architecture from Azure IoT Hub
IoT applications can be described as things (devices) sending data that generates insights. These insights generate actions to improve a business or process. An example is an engine (the thing) sending temperature data. This data is used to evaluate whether the engine is performing as expected (the insight). The insight is used to proactively prioritize the maintenance schedule for the engine (the action)
Demonstration for Solution with Azure IoT
Now, let us understand what all we need to demonstrate a simple IoT solution.
At first we need a device with sensor to generate telemetry data
I need to add this device to the Azure IoT hub.
Once we receive the raw data, we need to convert this data to a meaningful information to store and visualize the same.
Visualization can be used to find anamolies on the sensor data.
Following the above requisites of a given problem statement, we narrow down to the following architecture for a typical IoT Solution.
To categorize the same, we have used the following components-
RaspberryPi Simulator: It has few sensor data such as humidity and temperature. This is the available online simulator. Random stream of data is passed to the online simulator. This is a prepackaged solution which is publicly available.
This can be available on https://azure-samples.github.io/raspberry-pi-web-simulator/
Azure IoT Hub: We need to add a device to the Azure IoT hub. The hub generates a connection string, that the device must use to have a secured connection between the device and IoT hub. We must place this Connection string inside the source code of application running on the device. In our case that’s the Rasberry pi Online simulator.
Data Storage: The IoT hub here acts as a gateway it receives the raw data from the simulator, now we need to convert this data to meaningful information and store and visualize the same. To serve this purpose, we have chosen ADX (Azure Data Explorer) for storage and visualize.. as it’s cost effective from the storage perspective and also has a need separation for hot and cold data. When I say hot and cold data here, ADX comes with a configuration wherein we can define the hot and cold period. it’s based out of the data access frequency, if the data access frequency is high then hot storage is preferred, else we can opt for cold storage. It comes with an added advantage of using the Kusto query language which is intuitive query language that is inline the sql semantics that we use.
Visualization:This use case can be typically used to find anamolies on the sensor data that we are collecting from the device.
To begin with, login to http://portal.azure.com
Create a Resource Group → Create IoT Hub → IoT Devices →Create a device and register to IoT Hub
Add a Built-in Endpoint to the IoT Hub. In the below screenshot, we have created a consumer endpoint
Add a Shared access policy to the resource group created in IoT Hub. This will generate a connection string
Add the ‘Connection string’ to the Online Raspberry pi simulator to create a secured connection between the Device and IoT hub.
Once the Connection String is added to the source code of the simulator, the Telemetry data can be triggered from the Raspberry pi to the IoT hub. Following screenshot shows the sequence of messages generated once the telemetry data is triggered.
We have just sent telemetry data from Rasberry Pi to the IoT hub and this telemetry data consists of humidity and temperature as the sensor data this is the raw json packets which is generated from device to the IoT hub. We will need to store this data using the Azure Data Explorer. This configures the Insights and it’s a fully managed analytics, storage, and visualization service that makes it simple to explore and analyze billions of IoT events simultaneously.
Create a ADX cluster in Azure
ADX cluster — create a database — add data ingestion — masterData (data is ingested here )
Once the ADX Cluster is added and a db connection is created for data ingestion. We can query the database by establishing the connection to the azure data explorer through this url https://dataexplorer.azure.com/ and pull the data using the kusto query language
Here, I have created a function to create a folder to visualize a high alert on temperature above 25 and humidity above 75 using the Kusto Query Language
.create-or-alter function with (folder = “powerbivisualization”) HighAlertDataForTempAndHumidity {
Telemetry| extend isHighAlert = temperature > 25 and humidity > 75
| where isHighAlert == true| project messageId, temperature, humidity
}
We can use the Power Bi tool to visualize this data by establishing the connection between the db connection created for the data ingestion from Azure data explorer to PowerBi
This explains an end to end solution right from collecting a raw data from a device with a sensor to analyzing and Visualizing the anamolies to a raw information.
Hope this gave you a good trigger to Begin with IoT — The Azure Way and hope this brings in a lot of enthusiasm to explore more on this further !! Keep Exploring !!