IoT hub and Microsoft Flow integration

Hi Folks,

In this blog, we are going to talk about the IoT hub and its integration with the Microsoft Flows. If you do not know about the IoT hub and Microsoft Flows you can visit below links to know more about them:

IoT hub – Click here or  Click here

Microsoft Flows – Click here

We could able to write a Microsoft workflow to send messages to the IoT hub to trigger some event or task. There are many approaches by which we can send data//messages to the IoT hub but these approaches have some disadvantages like one  has to deal with Single board computers or programming of simulators which is a time consuming process Task of workflow using Microsoft flow tool is therefore to find an easy way to send data (messages) to the Azure IoT hub without much effort.

Process to achieve it-

We can send a event or a message via  HTTP via REST API’s, here we can use the POST method for transmission, an HTTP request which can be sent out to the IoT Hub.

Structure for such URL would be:

https: // {IoT-HubID} .azure-devices.net / devices / {DeviceID} / messages / events? api-version = 2016-02-02

Here in above structure if a URL

  • IoT HubID is the unique name of the Azure IoT hub used
  • DeviceID is the unique device ID

The body of the call then contains the possible value pairs according to the following scheme:

{

“Attribute_1”: “Message_1”,

“Attribute_n”: “Message_n”

}

For Security reasons for IoT hub and devices, a SAS token must be required to be sent via the header of the HTTP request. Which authenticates the device and then can send data to the IoT hub. SAS token can be generated with the help of some lines of code or with Azure Device Explorer.

How to send messages to the IoT hub using Microsoft Flow?

One can create and manage automated workflows using Microsoft Flow more information can be found from the below link:

Click here

We only need two connectors in the workflow to achieve it:

  • Flow button connector
  • HTTP connector
MicrosoftFlow

Conclusion

Sending event or messages to the IoT hub is very easy with the Microsoft Flow tool. Combining the Azure IoT Hub, Azure Device Explorer and Microsoft Flow enable fast and convenient implementation of these use cases.

Related Posts

Leave a comment