
Going further to explain Home Automation Using Facebook Chat And Arduino ESP8266 WiFi Module. After reading and watching this video you will be able to control your home appliances e.g. TV, Fan, Refrigerator, Lights etc. from Facebook chat message with the help of Arduino Uno and ESP8266 WiFi Module.
You just need to send instructions like “RED BULB ON, TV ON, Room No-1 Fan Off” in chat and it will control your appliences based on your instruction. To accomplish this project we are using Facebook Graph API to communicate with Facebook Page messages and also created a middle-ware in .NET Web API technology which is responsible for getting the instruction from Facebook Graph API.
Home Automation Using Facebook Chat – Part – I
Home Automation Using Facebook Chat – Part – II
What Is The Role of Middle-Ware Application :-
10 Things Required for Home Automation Using Facebook Chat And Arduino ESP8266 WiFi Module:-
- 1 x Arduino uno board
- 1 x USB cable
- 1 x ESP8266 WiFi Module
- 1 x Relay Board
- 1 x Jumper wire (Male to Male)
- 9 x Jumper wire (Male to Female)
- 1 x Breadboard
- 1 x Yellow Bulb
- 1 x Red Bulb
- Middleware Written in .NET Web API (REST Service) Click Here To Download
Connection Diagram:-
Source Code for Home Automation Using Facebook Chat And Arduino ESP8266 WiFi Module :-
#include "SoftwareSerial.h" String ssid = "YOUR_SSID"; String password = "YOUR_WIFI_PASSWORD"; SoftwareSerial esp(3, 2);// RX, TX String server = "www.iotboys.com"//YOUR_MIDDLE_WARE Server Address; String uri = "/api/FacebookAutomation/ProcessCommand";//MIDDLE WARE URI int RED_BULB = 5; int YELLOW_BULB = 6; void setup() { pinMode(RED_BULB, OUTPUT); pinMode(YELLOW_BULB, OUTPUT); digitalWrite(RED_BULB, HIGH); digitalWrite(YELLOW_BULB, HIGH); esp.begin(9600); Serial.begin(9600); connectWifi(); httpget(); delay(1000); } void connectWifi() { String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\""; esp.println(cmd); delay(4000); if (esp.find("OK")) { Serial.println("Connected!"); } else { connectWifi(); Serial.println("Cannot connect to wifi"); } } /////////////////////////////GET METHOD/////////////////////////////// void httpget() { esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection. if ( esp.find("OK")) { Serial.println("TCP connection ready"); } delay(1000); String getRequest = "GET " + uri + " HTTP/1.0\r\n" + "Host: " + server + "\r\n" + "Accept: *" + "/" + "*\r\n" + "Content-Type: application/json\r\n" + "\r\n"; String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent. esp.print(sendCmd); esp.println(getRequest.length() ); delay(500); if (esp.find(">")) { Serial.println("Sending.."); esp.print(getRequest); if ( esp.find("SEND OK")) { Serial.println("Packet sent"); while (esp.available()) { String response = esp.readString(); Serial.println(response); if (response.indexOf("RED BULB ON") > 0) { digitalWrite(RED_BULB, LOW); } else if (response.indexOf("RED BULB OFF") > 0) { digitalWrite(RED_BULB, HIGH); } else if (response.indexOf("YELLOW BULB ON") > 0) { digitalWrite(YELLOW_BULB, LOW); } else if (response.indexOf("YELLOW BULB OFF") > 0) { digitalWrite(YELLOW_BULB, HIGH); } else if (response.indexOf("ALL ON") > 0) { digitalWrite(RED_BULB, LOW); digitalWrite(YELLOW_BULB, LOW); } else if (response.indexOf("ALL OFF") > 0) { digitalWrite(RED_BULB, HIGH); digitalWrite(YELLOW_BULB, HIGH); } } // close the connection esp.println("AT+CIPCLOSE"); } } } void loop() { httpget(); }
Home Automation Using Facebook Chat And Arduino ESP8266 WiFi Module
How To Control Home Appliance From Internet Using Arduino and ESP8266
Voice Control Home Automation System Using Arduino and HC-05
Ahmad Sayeed
Something that I have never heard. I know we can operate this trough intrent but never though about Facebook chat.
IoT Boys
Dear Ahmad,
Thanks for your appreciation, keep us visiting.
Best Regards,
IoTBoys
Anish G
Can you guys please share the middleware .NET code.
Thanks
IoT Boys
Sure Anish,
Thanks for asking.
IoT Boys
Find the middle ware source code at https://github.com/iotboys/HomeAutomationUsingFacebookChat
Aakash
Great, adding a camera will be more attractive. Can you please do that?
IoT Boys
Dear Aakash,
Thank you so much for your suggestion will implement very soon, keep visiting.
Best Regards,
IoTBoys
Adnan
Hi, could you please let me know where to download your middleware .net?
Thanks
IoT Boys
Dear Adnan,
You can download middle ware code on our website itself.
Will provide you link very soon.
Thanks for reaching us.
Habib
Hi,
Pls tell me how to connect fb my mobile fb account how to connect
Habib
Middle wire what? My fb email address. Whare u write http://www.iotboys.com here writing my fb email address right
IoT Boys
Middle Ware means there is a middle tier which is handling the request and response from Arduino to Facebook chat, so you must have a Windows Web Server(IIS), where you can host out middleware code and update the config with your Facebook pageID and access_token.
Best Regards,
IoTBoys
IoT Boys
Hi Habib,
You need to first create a Facebook page then you can connect with that Facebook page using Facebook Graph API.
We have used a middle ware developed in .NET to connect with Facebook Graph API .
Let us know if you have still doubt.
Best Regards,
IoTBoys
https://facebook.com/iotboys
https://twitter.com/iotboys
IoT Boys
Find the source code of middle ware https://github.com/iotboys/HomeAutomationUsingFacebookChat
ingrid
bonjour le demande si c’est seulement sur le meme seveur on peux envoyer les messages ou si on peux envoyer par notre propre compte facebook
IoT Boys
Hello ingrid,
Could you please write your comment in English language.
Sorry to say that we couldn’t understand your comment.
Best Regards,
IoTBoys
ingrid
I asked how to install the midllware, I downloaded files already,
IoT Boys
Hey ingrid,
You need to host middle-ware, it’s web application so you need to have Windows hosting account.
ingrid
ok how can we modify your code and the herberger or we can host it directly?
IoT Boys
You only need to update the access token to web.config file generated by Facebook Graph API, then you can directly host.
Mitendra Arya
Hi IoT Boys.
Its nice to see you doing great work.
Can u please get in deep touch with this idea?
Sridarshan Dasi
Hello Sir Please help me…How to Connect our Facebook Page with Facebook Graph API
IoT Boys
Hi Sridarshan,
Hope everything working fine for you, as already did troubleshoot with you.
Best Regards,
IoTBoys
Habib
hi friend pls sent me graph API LINK and how to do access token
IoT Boys
Hi Habib,
We are preparing the details steps for this project in format of PPT, will update the same link so keep visited.
Most probbaly will update by tomorrow EOD.
Best Regards,
IoTBoys
Mihir
hello are u done with the detail step for the project?
please share it
IoT Boys
Hi Mihir,
It has been updated, please have a look.
Rahul
It’s really incredible something different from other it’s made me more innovative in it sector. I also want to control same home application with voice command. But component should be same what you ppl used in above. So if u have anything like that please share with me…. Thank s
Teja
where did I have to upload this middle ware?
IoT Boys
Hi Teja,
You can find it on Github.
Best Regards,
IoTBoys
Ucgbc
Thanks for the excellent manual
ashif
showing an error connectWifi() was not declared in this scope can u help me
Hima Bindu Gorantla
Is any of you have completed this project?Will you please send us the document related to this project or related links
khaled fawzy
can you please make a video to describing the instruction to upload the middleware application to any web host and how to configure and link with Facebook graph API
regards
H VABEIZAWZI BEIA
it was a good tutorial,but the connection was easy, you guys must include a video of creating the most critical part which is that kind of API… Im totally lost.. if you could provide that part of linking most of us will be more helpful and we can have the knowledge and more interesting in these field.Thank You
danish
please you must include the confirmation message from esp so i’ll get to know that esp switch the led sucessfully.
danish
please include confirmation message from esp side so that i come to know that wether my actutator is off or not.
Osi
Boys,
Don’t you want to upgrade the code using ESP8266 board, like Wemos D1 R2 & Mini. And your first video has been removed.
Cheers,
Osi