Facebook home Automation - Black keyhole

welcome to our keyhole, we provide you various knowledge from various sources such as Electric&Electronic, Health, Arduino, IOT, Diy projects, A/l past paper and model paper, Even though you can keep in touch with current technology

Facebook home Automation

Share This

 






In this project we will look how to make Facebook home Automation using Facebook messenger. These features of Facebook can be really helpful in building any IoT based project. Like here we will use Facebook to control the devices in our home remotely. You just need to send a text message to a chatbot which can control lights in your home from any part of the world. 


Components

       1. 5v Relay

        2.NodeMcu

        3.LED or AC bulb


Circuit




 Check out my previous post


MQTT

MQTT stands for Message Query Telemetry Transport. MQTT is a TCP/IP based publish and subscribe protocol which is designed for lightweight machine to machine interactions with IOT devices. These devices act as the client who communicates to the server known as broker. A broker is a server which allows clients to send short messages to the broker and receive messages if they are subscribed to certain topic. It acts as a server that handles all the information of the devices that are connected to the server. A client can be either publisher (sending data from device to the server) or subscriber (getting data from the server to the device) of information simultaneously.


Facebook Messenger

  Facebook Messenger is a messaging platform which was developed by Facebook. peoples can text, make voice note, video calls, send imag and videos between Individuals or Groups


Chatfuel

Chatfuel is the leading bot platform for creating AI chatbots for Facebook. People can create AI chat bots which can be used to trigger any event from remote distance. A simple text from you on messenger can add AI features in your projects.

IFTTT

IFTTT stands for IF THIS THAN THAT. It is a free web-based service that allows connecting to web services, applications and devices such as Google, Facebook, Adafruit, Webhooks, Telegram, etc. to automate the tasks. Applets help to combine two services using a trigger and an action. It simply means if something is triggered in one web service then an action will take place in other web service.


Adafruit IO

Adafruit IO is a server by Adafruit Industries. It is a platform for interacting with IOT devices using HTTP and MQTT protocols which helps to store and view data and also helps in controlling the devices.



Working of Facebook Controlled Home Appliances

In this project we will control a home appliance like a lamp using Facebook messenger. On typing certain keywords on the messenger you will be able to control devices in your house. The message will be sent to one chatbot which will trigger respective AI block in the Chatfuel. That block is linked to some JSON API which will send a POST request to the IFTTT. IFTTT will help to link Webhooks and Adafruit to send and store the data to the Adafruit with the help of Webhooks. Webhooks will create an event which will have unique trigger key to trigger the event. The data sent to Adafruit will trigger the toggle button in the dashboard. Adafruit acts as the server for NodeMCU and sends the data to it which in result activate or deactivate the lamp with the help of MQTT.




watch the tutorial steps with video explanation



Setup of Adafruit IO for controlling Home Appliances

    I have provided the steps in points form. If you want more clarification see above video

  • Open https://io.adafruit.com/ and Click on Get Started for Free. Enter the details and create a new account. After this you will be redirected to the Adafruit IO Homepage. Click on Feeds. Now in the Feeds page, click on Action button and then click on Create a New Feed and give some name to the feed. Here I named it “OnOff” name to my Feed.

  •  Now in the Dashboard click on the Actions and then Select Create a New Dashboard. Now give a name to your Dashboard and click on Create, here I gave “Home Automation” name to my Dashboard.
  • Then click on your newly created dashboard. In your dashboard page you have to create a new block for On/Off toggle button. Click on the plus button in the dashboard page to create a new block and then select the first “Toggle Button”
  • Tick the checkbox of the Feed (Here my feed is OnOff) and click on Next Step.

    Now give the name for toggle button ON and OFF and Click on Create Block. Now a toggle button will be created on your dashboard which will help us to send the data to our feed.



Setup of IFTTT to Trigger Adafruit Toggle button

  • Go to https://ifttt.com/ and sign in with Facebook or Google. After signing in click on My Applets on the top and then click on New Applets.

  • Then click on “+ this” and search for Webhooks in Choose a service section.
  • Now click on Receive a web request
  • Type any Event Name 
  • After that, click on “+ that” 
  • search for Adafruit
  • Click on Send data to Adafruit IO. Select the Feed Name created before in Setup of Adafruit IO section. Select value1 by clicking on add ingredient in Data to save and click on Create Action and then click on Finish.
  • Now go to the webhooks settings, copy the URL and past it in your notepad, which contains Webhooks key with mixed characters which will help to connect Chatfuel to IFTTT.

Setup of Chatfuel with Facebook

  •  Go to https://chatfuel.com/ and click on login with your Facebook Id.
  • Then click on my First bot to create fb page 
  • It will direct you to create fb page through your Id. you can simply name it as per your wish and connect it with your bot it will automatically redirect in Chatfuel environment. In my case I have a page already, So I have connected it with my chatbot
  • Now create two new blocks (here Relay ON and Relay OFF). Then click on Relay ON and select the Text from Add Element. Write the text you want to display on when the user call for the relay on block. Do the same for Relay OFF block.
  • Click on Set Up AI  
  • Select the RELAY ON in the bot replies with section. Now add texts in if user says something similar to section. These texts will help to trigger the blocks. Do the same for RELAY OFF button.
  • Now we have to add JSON API for both RELAY ON and RELAY OFF blocks to link chatfuel with IFTTT. You can test your chatbox by clicking on TEST YOUR BOT and the welcome text will be send to your messenger account.

  • Now we have to add JSON API for both RELAY ON and RELAY OFF blocks to link chatfuel with IFTTT. You can test your chatbox by clicking on TEST YOUR BOT and the welcome text will be send to your messenger account.

  •  Set type as POST 

  • Here are the two URLs which are copied in the JSON API section of RELAY ON and RELAY OFF. This URL contains Event name and Webhooks trigger key.

event name is indicating the name which you created in the webhooks settup
past the webhooks key which you pasted in your notepad(in that URL just copy the key which is indicated after the path of key)

value 1 means Relay on
value 2 means Relay off


Code

    
    Before going to upload the code download the Adrafruit_mqtt library from your library manger

       Get the username and Aio_key from Adrafruit website. You can see in my video to how to get the key and username.



Hope you have liked this post don't forget to share between others who aspire to make these kind of project.


























No comments:

Post a Comment

business queries

Pages