IoT Button - Microsoft Flow

by JoaoLucindo on ‎07-25-2017 06:29 PM


IoT Button: Process automation with Microsoft Flow using NodeMCU and Arduino IDE


In this article it will be developed an IoT button applied to the scenario of maintenance of a coffee machine using Microsoft Flow. However, it can be easily adapted to any other scenario or application.




  • Access to Microsoft Flow or Azure Logic Apps
  • Arduino IDE
  • NodeMCU development board
  • Push Button
  • 1 x 330 Ω resistor
  • 1 x 1M Ω resistor
  • Jumpers
  • Breadboard
  • Micro USB cable

Setup Microsoft Flow  Environment


    1)    Microsoft Flow portal


Access Microsoft Flow, log in and click "My Flows".




  2)    Create from blank


Click "Create from blank" to create a new workflow.




    3)    Request/Response


Give a name to your Flow. Select the Trigger "Request/Response".




    4)    Method GET


In "Advanced Options", choose  "Method GET".






     5)    Add an action


Click "Add an action" to add a new action.




    6)    Send an email


Choose the action "Office 365 Outlook - Send an email".




     7)    Create Flow


Complete all required fields (as you wish), and then click "Create Flow".


ingles 1.png




    8)    HTTP GET URL


Then copy and save the HTTP GET URL:<ID>/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=<ID>







Hardware Setup


    1)    Building a Circuit on Breadboard


Build the circuit like the one shown below.


MicrosoftFlow-LogicApps-Button-Frittzing Project_bb.png




The ESP8266 NodeMcu comes with a firmware that lets you program the chip with the Lua scripting language. But if you are already familiar with the Arduino way of doing things, you can also use the Arduino IDE to progam the ESP. In this tutorial we'll use the Arduino IDE.



 IDE Arduino setup


     1)    Package ESP8266


Download the IDE, and install it. Open the IDE; Choose File -> Preferences, in "Additional Boards Manager URLs" insert the URL "" and than click "OK". After this steps, your download will start automatically. Once it is finished, restart the IDE.




    Softaware Setup


Download the file "" attached and replace the values:


  • SSID by your wireless network name
  • PASSWORD by your wireless network password
  • HOST by the strings of the HTTP GET URL before 443 (in this case:  "" )
  • URL  by the strings of the HTTP GET URL after 443 (in this case "/workflows/<ID>/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=<ID>")


 By doing that, the final code will be:


#include <ESP8266WiFi.h>

//static const uint8_t D0   = 16;
//static const uint8_t D1   = 5;
//static const uint8_t D2   = 4;
//static const uint8_t D3   = 0;
//static const uint8_t D4   = 2;
//static const uint8_t D5   = 14;
//static const uint8_t D6   = 12;
//static const uint8_t D7   = 13;
//static const uint8_t D8   = 15;
//static const uint8_t D9   = 3;
//static const uint8_t D10  = 1;

int inPin = 16;   // pushbutton connected to digital pin 0   
int val = 0;     // variable to store the read value
//Include the SSL client
#include <WiFiClientSecure.h>

char ssid[] = "<SSID>";       // your network SSID (name)
char password[] = "<PASSWORD>";  // your network key

//Add a SSL client
WiFiClientSecure client;

void setup() {

  pinMode(inPin, INPUT);      // sets the digital pin 1 as input


  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {

  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();


String MicrosoftFlow() {
  char host[] = "";

  if (client.connect(host, 443)) {

    String URL = "/workflows/<ID>/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=<ID>";


    client.println("GET " + URL + " HTTP/1.1");
    client.print("Host: "); client.println(host);
    client.println("User-Agent: arduino/1.0");

void loop() {
  val = digitalRead(inPin);  // read input value



Now you can compile and upload the code from your computer to the device. You can see the result (after press the push button) in the picture below.

 12 - Copy.png













Meet Our Blog Authors
  • 7x Microsoft Business Solutions MVP (CRM)
  • Solution Architect with Slalom, and organizer of the Boston Office 365 User Group, and long term SharePoint/Office 365 veteren. Find more at Follow @DavidLozzi
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps.