Recently I have taken a webinar for Azure IoT hub and I have created this demo for that session. Raspberry Pi 2 running on Windows 10 IoT Core (Visit www.windowsondevices.com for more details) is connected with a TI Sensor tag (Bluetooth LE) and a Servo motor interfaced through GPIO pins which acts as a cooler system. Sensor tag has a combo of sensors such as temperature, pressure, humidity, accelerometer, gyrometer etc. is pumping data to RPi2. It pushes the sensor data to cloud through Azure IoThub services and a PC application receives the data from it and also send control commands to the device. A Threshold value for the temperature can be set from the PC application and when temperature raised higher than the threshold, a command is sent to RPi 2 device through Azure IoThub to switch ON the cooler and vice versa.
Development Setup
Visit the following website for setting up the development environment as well as a sample application creation.
Azure IoT HubBelow link helps you to getting started with Azure IoT Hub. This helps you to create an IoTHub unit, accessing it from devices, device explorer tools to create your own device in you IoTHub unit.
https://azure.microsoft.com/en-in/documentation/articles/iot-hub-csharp-csharp-getstarted/
Device Side Application (UWP)RemoteThermoController is the device side application you can find in the below github link. Device side application is a Windows 10 UWP application which includes the necessary packages for accessing the Azure IoT hub, Servo motor (GPIO) and the TI sensor tag ( Bluetooth LE).
• Download the application from the Github and copy the necessary connection string information for your device id taken from the Device Explorer tool as shown in the below picture. See the links mentioned in the Azure IoThub topic for accessing device Explorer.
• Paste it on the "connectionstring" variable in the mainpage.xaml.cs file as shown in the below image.
• Build and run the application, UI will be launched, where you can select the TI sensor tag in the list of Bluetooth device to pair.
• Connect it and you can see the sensor values displayed on the screen and also on the debug messages in visual studio ( if you run it through remote debugger).
• Now sensor values are pushed to Azure IoT hub.
• Servo motor will be switch on/off based on the Command received from the PC application through Azure IoT Hub device endpoint.
PC Side Application (.Net)RemoteThermoControllerPC is a PC side application that you can find in the below github link. This is a classic .Net application which includes the necessary package to access the Azure IoT hub.
• Download the application from the given github and copy the necessary connection string information from your Azure IoT Hub portal.
• This connection string is not device specific and it is IoT Hub unit specific. Using this connection string you can access all the devices created in this IoT Hub unit.
• Paste the connection string as shown in the below picture.
• Build and run the application and you can see the sensor values pushed by the device as shown in the below picture. You can set the threshold value for the temperature to play with the cooler system.
• When the temperature is greater than the threshold value, Cooler ON command will be sent to device and when the temperature is lesser than the threshold value Cooler OFF command will be sent to device using Azure IoT Hub service endpoint.
Presentation SlidesSensor to Cloud Using IoTHub - Webinar ( Slides and Demo Source code)
Comments
Please log in or sign up to comment.