It makes sense to have a cloud-based aggregation system for my embedded “IoT” device(s), so I wanted to explore Microsoft’s Azure IoT suite. There’s a lot of marketing fluff, but I wanted to see how quickly I could get up and running. So let’s try …
What is the Azure IoT Suite?
The Azure IoT Suite includes a host of services, which combined allow for the large-scale collection of data from IoT devices (Microsoft marketing speak: “Cloud-scale telemetry ingestion from website, apps and devices”). Other services allow for the (a) analysis of the incoming data, (b) out-going control messaging to the devices and (c) presentation of the data in real-time.
Perhaps more important for developers is understanding how the data flows from devices through the gateway to the presentation layer. In our example, we’ll be using an IP-capable device which will send messages directly to the Azure IoT Hub (“Cloud Gateway”) and we’ll view the information in the presentation layer.
To help us quickly get up and running, the Azure IoT Suite offers:
- An Azure IoT SDK toolset which will allow us to quickly integrate the device’s connection to Azure. While there is support for multiple languages and platforms, we’ll use the node.js tool set.
- Azure offers a set of predefined presentation views which are based on the type of usage they intend to provide. The presentation view is an auto-generated website in the azurewebsites.net domain based on the selected name of the IoT Hub.
Seting up our Azure IoT Suite
The first step that you have to go through is to create an Azure account. I started the process at the Microsoft Azure IoT Suite page’s ‘Try Now’ button. There is a 30-day free trial option, but you still need to give a credit card. The overall procedure is pretty quick and takes about 5 minutes from the time you start to the time you are connected to your Azure portal manager.
This next step of the two step procedure creates a presentation website based on the type of business model that best represents your enterprise. At the time of this blog entry, the only option was ‘Remote Monitoring’ though ‘Predictive Maintenance’ is planned for the future.
Once the Azure account is set up, I recommend using the newer management portal, called Azure Preview Portal, to view and manage the Azure iOT services. I favorited the ‘IoT Hub’ to allow me to easily access the various services available as part of the Azure IoT Suite.
Connecting a Device to Azure IoT
With our IoT suite set up, we are ready to code. While I plan to use an embedded Linux device which will be running a node, I decided to use Visual Studio 2015 Community Edition as my IDE in this project. By default, node.js project templates aren’t included in VS2015, so you need to install them.
I’ll be connecting my device based on the sample code provided in the remote-monitoring.js file. Looking in this source, we’ll see that we need some key pieces of information from our Azure IoT Suite, specifically information on the deviceID, deviceKey, hubName and hubSuffix.
To get this information, we’ll need to create a device using the presentation view – at the bottom of the page, select the Add Device icon and follow the wizard to generate the necessary device identification parameters.
After I updated the remote-monitoring.js file, I used WinSCP to move it to my target device.
We’ll then SSH into our target, use npm to install the ‘azure-iot-device’ dependency and then start the node application. Within 5 seconds you should see telemetry data coming in from our device. The sample code auto-generates temperature values and we can see them being updated every second.
So it took me a couple of hours from the time I started to seeing data being reported live on my Azure presentation layer. The fact that I can quickly add disparate IP devices to such a power back end is pretty remarkable. In a future post I’ll investigate more things that we can do now that we’re ingesting data.