In order to develop the scenario, I chose to use a Raspberry Pi with Windows 10 IoT Core installed on it. If you want to know the installation part, please refer the link.
There are five different components that I considered here
Electronic Circuit – I use DHT11 sensor to measure the temperature and humidity of the surroundings. The temperature and humidity data is considered as telemetry data. You can choose the telemetry data based on the sensor that you are gonna use.
Raspberry Pi – The main objective of the Raspberry Pi to act as a field gateway. DHT11 sensor is unable to connect to the internet and needs an intermediary gateway to read the data from it and send to the cloud.
IoT Hub – Azure IoT Hub is a fully managed service that enables reliable and secure bidirectional communications between millions of IoT devices and a solution back end. Raspberry Pi directly sends the data to Azure IoT Hub.
Stream Analytics – Stream Analytics is a fully managed service providing low-latency, highly available, scalable complex event processing over streaming data in the cloud. It reads the data from the Azure IoT Hub, processes it and sends the data to Power BI.
Power BI – Power BI acts as a real time dashboard which shows the real time data.
The entire article is divided into following six sections
- Building an electronic circuit
- Configure Azure IoT Hub
- Configure Azure Stream Analytics
- Develop Universal Windows Platform(UWP) application
- Configure the Power BI
Building an electronic circuit
The circuit contains a DHT11 sensor only. It has three pins i.e; positive, ground and data output. The pin will be configured properly as mentioned below
|DHT11 Sensor||Raspberry Pi|
|Positive pin||3.3 V|
|Ground Pin||Ground Pin|
|Data Output Pin||Pin 17|
Pin 17 of Raspberry Pi would be used to read the data from the DHT11 sensor.
Configure Azure IoT Hub
Azure IoT Hub does not ingest the data from the device unless the device is registered with the IoT Hub. Open Azure Ibiza portal and create the IoT Hub instance. Once IoT Hub instance in created, take the connectionstring from the settings blade. The connectionstring looks like
Download the Device Explorer, paste the connection string to the IoT HubConnection String section of Configuration tab and select the Update button. Go to the Management tab and select the Create button to pass the name of the device. This will create the device. You can choose any name that you want. The device will show up the Devices section and right click on the device row to copy the connection string which looks like
Configure Azure Stream Analytics
Create an Azure stream analytics from the Azure site (ASA job cannot be fully configured in ARM portal at the time of writing the article). It has contain inputs, query and output.
The input as IoT Hub created in the earlier step.
The query would be following one
System.Timestamp as Time, AVG(Temperature) as Temperature, AVG(Humidity) as Humidity
[input] i TIMESTAMP BY EventProcessedUtcTime
The output would be Power BI and it will ask for authentication to connect to your Power BI subscription. Please provide all the relevant details t connect to the Power BI subscription along with dataset and table name. You can choose any name for the dataset and table.
At this point of time, you can open Power BI dashboard but you won’t see any dataset because the data is not streamed to Power BI so far.
Develop Universal Windows Platform(UWP) application
The entire solution is available in github. The solution has two projects.
Sensors.Dht – The C++ project to use as a driver for DHT11 sensor and it has been taken from Hackster.io
PracticeApp – This is a UWP project. It has a model SensorData and MainPage.xaml to display the temperature and humidity. It will also send the date to IoT Hub which will be processed by Stream Analytics and displayed on the PowerBI dashboard.
Configure the Power BI
Run the application with proper configuration settings. Within few minutes, the dataset would be visible in the Power BI dashboard to use it for real time chart.