FeaturedIOTIOT Projects

Facebook IOT Panic Button

Facebook IOT Panic Button is the best social project to work on. In this tutorial you will learn to make a kind of SOS button that can post on Facebook a predefined message in case of emergency when it is pressed, so that your friends and family can response to you in the right time.

This project is similar to the Amazon Button, which is use to order a product. Here, we are making a similar one but with a little approach to make a social impact.

Working Principle :

A push button is connected to NodeMCU 12E with a HIGH signal and is pulled down to ground via 10K resistor. When the button is pressed, we read the status at a digital pin.

When there is a HIGH status at the pin is observed, then a trigger or  URL is requested via NodeMCU (which is connected to a Internet connection) . This URL is a IFTT Facebook post API request that on our behalf post a status with a message that we have predefined for it while making the IFTT Makers  Recipe.

IFTT  stands for ‘If This Then That’. It is a a free web-based service to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Instagram, or Pinterest. Here we will be using Facebook Post Status Applet. It has become a powerful tool for triggering actions and can be connected Amazon Alexa, Facebook, Twitter, Instagram, Fitbit, Slack, Skype, and hundreds more web applications.

Components Required:

  1. NodeMCU 12E (ESP8266 based dev. boards)
  2. Push Button
  3. Jumper wires or Connecctors
  4. Mini Breadboard(optional)

Connection/Schematic :

 

Making the IFTT Recipe :

  1. Go to IFTT official website : https://ifttt.com/join and Log in with facebook.
  2. Search service ‘Maker’ and select ‘Maker Webhooks’ option.
  3. Select Web Request and give Event name and then click the button ‘Create trigger’.
  4. In the next window, click the ‘+’ icon.
  5. From the Applets choose ‘Facebook’ Applet.
  6. Choose  Action – ‘Create a status message’.
  7. Enter the Status message and choose add ingredients (if you want to, here we have added time of occurrence of event).
  8. Click on Finish.
  9. Search for Maker Hookers and go to ‘Documentation’.
  10. In the text field enter the ‘Event name’ and copy the part of the URL highlighted.

Coding NodeMCU:

Before, proceeding further check whether you Arduino IDE has the ESP8266 packages and boards. Follow this to know the basics of NodeMcu and how to install esp8266 library to Arduino IDE Click

In the code given below, change the SSID and Password according to you WiFi’s or Hotspot’s name and password.

#include <ESP8266WiFi.h>
const char* ssid     = "Alokom";  
const char* password = "42224222"; 
int button= D6;             // D1 pin of ESP12E board
int LED =16;               // D0 pin of ESP12E board
const char* host = "maker.ifttt.com";     //IFTTT channel address
int buttonState = LOW;

void setup() {

  pinMode(button, INPUT);

  pinMode(LED,OUTPUT);

  Serial.begin(115200);

  digitalWrite(LED,HIGH); // By default Off state

  }

int value = 1;

void loop() {

   buttonState = digitalRead(button);

    if (buttonState == HIGH) {                     //button is pulled down to ground via 10k resistor

       if (value == 1){

         WiFi.disconnect();

         Serial.println("Button Pressed");

         WiFi.begin(ssid, password); // connecting to wifi

         while (WiFi.status() != WL_CONNECTED) {

         Serial.println("Conencting");

         delay(500);

       }

       digitalWrite(LED,LOW);  // LED turns On

       WiFiClient client;

       const int httpPort = 80;

       if (!client.connect(host, httpPort)) {

        Serial.println("Weak Network");

        return;

       }

       // We now create a URI for the request

String url = "/trigger/Help_Me/with/key/cWJY3w2-p0viJ6k9_3AfcgF6myL-PLo9XD3xlU7JZ";   //our link to trigger the event with special key and event name 

  

       // This will send the request to the server

client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");  // GET request 

       

       value = 0;

       delay(5000);

       digitalWrite(LED,HIGH);  // LED turns Off

       }

    }

    else{

    value = 1;

    delay(500);

    }

}

 

Paste, your part of the IFTT URL, which you have copied earlier in the line indicated as below

Now,your SOS or i say Social Panic Button is ready. Make it as a wearable IOT gadget like a wrist band. Hope you liked this content and we are looking forward to bring more interesting contents like this.

 

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Close
Back to top button
Close