Getting your sensor data from a IoT DevKit into Table Storage

After a 2 month wait my MXCHIP AZ3166 IoT devkit arrived from Seeed. The board aimed to be easy to get started with sensor information and send data into the cloud. I always wanted to play around with this IoT sensor stuff and wondered how to access this data from applications. So I took some time and tried to find out how to get this sensor data from this board into Table storage that can be queried easily from any application. iot

Step 1 – Setting up the development environment

The first thing that needed to be done was setting up the development environment. This was a bit of challenge and took around 2 hours for me.

To set it up follow this Tutorial. https://microsoft.github.io/azure-iot-developer-kit/docs/get-started/

For me I had to update the firmware https://microsoft.github.io/azure-iot-developer-kit/docs/upgrading/ and a lot of packages like node where outdated.

Step 2 – Connecting to Azure IoT hub

There is a great getting stared project for this and it works fine, but it can bit challenging if errors appear.

Follow this guide. https://microsoft.github.io/azure-iot-developer-kit/docs/projects/connect-iot-hub/

I ran into the a few errors:

(node:9720) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Upload failure with error code 1 This was easily solved by connecting to a different USB port Data was not send, I had to renew my DHCP lease. If you run into errors just ask them here: https://gitter.im/Microsoft/azure-iot-developer-kit

Step 3 – Get your data into Azure Tables

When you have everything up and running and you see the board sending data it is time to get the data out of the IoT hub. data_send To see the output of in the left bottom of Visual studio code click the connector next “MCHIP AZ31666”. In the output window you will see all the debug information from your device.

Next is create a Azure Stream Analytics Job (https://portal.azure.com/#create/Microsoft.StreamAnalyticsJob). Enter a job name and select your resource group.

The Stream Analytics Job is going to transfer the messages from the IoT Hub to a Azure Storage Table.

Under Job Topology create an Input job. Select your IoT hub and select by event serialization format JSON. Under output create a output job select Azure tables. Use for partition key: deviceId and for Rowkey messageId.

The last to do is create a query, we are using the most basic query and that is “Select * INTO [YourTableName]” FROM [IoTName]. The names you can find on the left.

When this is done just hit start and connect to your azure table using the storage explorer.

Have any questions, please ask them below or find me on twitter.