A key use case for Azure is as a place for working with the internet of things. A selection of IoT-focused services handle working with streams of data from any number of devices, adding machine learning and stream analytics. Most of the features you’ll need come as part of , or through Cortana Analytics. In fact, the only thing that’s missing is the IoT hardware.
Where it comes to connecting devices to Azure, Microsoft takes an open approach. You’re not limited to x86 and ARM devices running Windows 10 IoT Core (though I’m sure the folks in Redmond would be quite happy if you chose that approach). Instead, the only real requirement is the ability to access Azure’s APIs. That lets you use anything from micro-PCs like the Latte Panda single-board computers with full Windows 10 installs to Raspberry Pis running Linux, as well as simple firmware-driven devices like those using the open source Arduino.
That gives you a big choice of devices, but it’s also hard to choose a platform suitable for a pilot program, especially if you’re looking to build a sensor-based IoT solution. Although most IoT projects start with off-the-shelf “maker” boards like the Arduino or the Raspberry Pi, production devices tend to be built around common Wi-Fi modules and ARM-based microcontrollers.
Introducing the Azure IoT DevKit features
Instead of developing its own IoT starter kit, Microsoft is working with MXChip to deliver that can work directly with Azure’s IoT tools. The result is an open source board built around a STM32F412 ARM microcontroller and an EMW3166 Wi-Fi module with 256KB of RAM and 2MB of flash storage. It’s got both USB connectivity and 2.4GHz Wi-Fi, as well as a collection of environmental sensors and a small OLED display. There’s even a microphone and an IR emitter, which should let you work with some of Azure’s machine learning-based APIs to build your own version of Amazon’s Echo.
, the Azure command-line interface, and Node.js. Other tools in the archive provide device-specific libraries, as well as the drivers needed to install software and test your code.
Installing it all is easy enough; I unzipped the file and ran the install.cmd script that handled all the work for me, adding the appropriate extensions to my existing copy of Visual Studio Code. One thing to note: The installer will install the Arduino IDE. You won’t actually need to use it, but it’s a prerequisite for the Visual Studio Code Arduino extension, installing drivers and libraries for the Azure IoT DevKit board.
Building your first Azure IoT application
Once you’ve got everything on your PC, you’re ready to start building IoT apps on both your Azure IoT DevKit and on Azure, with the Azure IoT DevKit board connected directly to Visual Studio Code. With a direct connection, code edited in Visual Studio Code will deploy, run, and debug on the board, giving you a roundtrip from editor to device.
Start by disconnecting your device from your PC, and launch Visual Studio Code. Once it’s up and running, you can plug the Azure IoT DevKit’s USB cable into your PC, where it’ll be detected by the Visual Studio Code Arduino extension. This will automatically configure Visual Studio Code to work with the board, opening a welcome page with links to Azure documentation and to sample code. I had a little trouble getting my development machine to detect the Azure IoT DevKit board the first time I plugged it in, but a quick reboot had me ready to go.
Microsoft has provided , hosted on GitHub. I began with a basic Azure IoT Hub integration that would read environmental data from the Azure IoT DevKit, uploading it to Azure for analysis and display. The sample code included scripts that used the Azure command-line interface to configure a IoT Hub instance via an Azure Resource Manager template, taking advantage of Visual Studio Code’s built-in terminal, so I didn’t have to leave my IDE to use the Azure Portal. It’ll also collate the information needed to add authentication and connection data to your code.
The Arduino extension for Visual Studio Code includes tools to manage and deploy Arduino libraries to your board, which you’ll need to run any code you write. Choose the library you want and click Install. Once the library installs, you can configure your board to run the sample code. Again, you’ll use a Visual Studio Code script to get the connection details for the device, linking it to the IoT Hub you configured. The sample code then loads onto the board, which will reset and start sending data to Azure, ready for consumption in an app. The sample code published debug data over the device’s serial USB connection, data that’ll show up in Visual Studio Code’s serial console. You can also monitor operation in the Azure Portal.
Getting a board like this working and connected is only part of the story. Once you’re pushing environmental data at regular intervals, you can start to add it to a larger-scale Azure application, taking advantage of tools like Stream Analytics or , adding data consumers to your Azure IoT Hub. What Microsoft and MXChip have done here is give you a place to start, what you do next is up to you and your business’s IoT needs.