Many developers use NodeMCU esp8266 module for creating Iot devices. Azure is one of biggest cloud service providers in the world. In this blog post, i will be showing you how to sent data collected by the NodeMCU esp8266 module to Azure and store it.

We will need to create 3 resourses in Azure to collect and store data. They are Azure Iothub, Stream Analysis and Azure Storage. Azure Iothub is a service which enables bidirectional communication with billions of IoT devices. Stream Analysis job is service which is capable of setting up a real-time analytic computations on data streaming. This service is used to transfer the data recieved by Azure Iothub to Azure Storage. Azure storage account contains all of Azure Storage data objects: blobs, files, queues, tables, and disks. We will be using Azure table storage to store the dat.

Setting up Azure

Create an account in Microsoft Azure

Create a new Resource Group

Create Iothub and add a new device

Copy the primary connection string of the device

Create Azure table storage

Create Stream Analysis

Config input and output of Stream Analysis

Note that Parition key and RowKey require a unique id. So we using the data and time as the value for both.

Setting up the hardware

We will be using my tweeked verison of the sample code provided by Microsoft which available on my github account. Before we upload the code to NoduMCU, we will need to install the following libraries :

AzureIoTHub.h

AzureIoTProtocol_MQTT.h

AzureIoTUtility.h

After installtion follow the following instruction as given in azure-iot-arduino repository