/dht11-azureIoT

This repository contains a simple solution to take readings from a DHT11 sensor, display the temperature and humidity, and send the data in real time to Azure Iot Hub.

Primary LanguageC++

Overview

This repository contains a simple solution to take readings from a DHT11 sensor, display the temperature and humidity, and send the data in real time to Azure Iot Hub.

Pre-requisites

You should have Visual Studio 2015 with Windows 10 SDK on a Windows 10 Machine. The sample here runs on Windows 10 IoT Core on a Raspberry Pi 2 - hence you should have a RPi2 with Windows 10 IoT Core image loaded on a compatible SD Card.

Steps

To get this to work, follow the steps below:

  1. Setup IoT Hub in your Azure account. Instructions here

  2. Install the Device Explorer utility if you don't have it already, and note down the device connection string. Instructions here

  3. Paste this device connection string in solution/Sensors.OneWire/MainPage.xaml.cs (line 27)

  4. Clean the solution and Build the solution by going to the Build toolbar in your Visual Studio 2015.

  5. Deploy the solution to your Raspberry Pi 2. (Choose Remote Machine while deploying and specify the IP address/Machine Name of the Pi). If you want to find out the IP address of the Raspberry Pis in the network, you can use the Windows 10 IoT Core Dashboard. All the Nuget Packages will be automaticaly restored.

  6. The solution should start working properly now. The data format being sent is of the form {"DeviceId":1,"temperature":29.0,"unitOfTemp":"C","humidity":41.0,"unitOfHumidity":"%","TimeFlag":"6/13/2016 3:47:14 PM"} You can see this data in the Output window of Visual Studio. You can verify that the data is being sent to Azure by using the same Device Explorer tool above. Go to the Data tab, choose the device, and click on Monitor.

Credits

This code is a modified version of this Hackster project. The code to send data to Azure has been added to this project.