How To Control Home Appliance From Internet Using Arduino and ESP8266

How To Control Home Appliances From Internet Using Arduino and ESP8266

In this article we are showing how you can control your home appliances from anywhere in world using Internet. In our daily life we always forget to switch off Lights, TV, AC, Fan and other appliances and unnecessary we waste electricity and money of course, which is very precious for us.

So we have created a very simple video that you can follow and convert your normal home to Smart Home and you can control from anywhere in world.

Components Required :-

  1. 1 x Arduino uno board
  2. 1 x USB cable
  3. 1 x ESP8266 WiFi Module
  4. 1 x Relay Board
  5. 1 x Jumper wire (Male to Male)
  6. 9 x Jumper wire (Male to Female)
  7. 1 x Breadboard
  8. 1 x Yellow Bulb
  9. 1 x Red Bulb

Connection :-

Source Code :-

 

#include "SoftwareSerial.h"

String ssid ="WIFI_NAME";
String password="WIFI_PASSWORD";

SoftwareSerial esp(3, 2);// RX, TX

String server = "www.iotboys.com"; //Your Host 
String uri = "/YOUR_API"; // Your 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 {

Serial.println("Cannot connect to wifi ! Connecting again..."); }
connectWifi();

}
/////////////////////////////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=";

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();

int RED_BULB_ON = response.indexOf("RED_BULB>TRUE")>0?1:0;
int YELLOW_BULB_ON = response.indexOf("YELLOW_BULB>TRUE")>0?1:0;

if(RED_BULB_ON==1)
{
  digitalWrite(RED_BULB, LOW);
}
else
{
  digitalWrite(RED_BULB, HIGH);
}
if(YELLOW_BULB_ON==1)
{
  digitalWrite(YELLOW_BULB, LOW);
}
else
{
  digitalWrite(YELLOW_BULB, HIGH);
}
}
esp.println("AT+CIPCLOSE");

}
}
}

void loop() {
  httpget();
}
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on telegram
Share on reddit
Share on tumblr
Related Posts
About Author

62 thoughts on “How To Control Home Appliance From Internet Using Arduino and ESP8266”

  1. An impressive share! I’ve just forwarded this
    onto a colleague who has been doing a little research on this.

    And he in fact bought me lunch simply because I stumbled
    upon it for him… lol. So allow me to reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending time to discuss this subject here on your website.

    1. Saddar Uddin Memon

      Salam, bro my esp8266 can not connect to my system and no any AT command work what I do plz give your ideas. Thnkx

    2. Saddar Uddin Memon

      Salam, bro my esp8266 can not connect to my system and no any AT command work what I do plz give your ideas. Thnkx

    1. Hello Rishabh,
      Thanks for reaching us.
      That page is only having HTML and Angular code where we are calling a web API that we have developed in ASP.NET Web API.
      Let us know if you still need this.

      Best Regards,
      IoTBoys

          1. Can you forward me the mail web page code sent iot boys for home automation using arduino and esp8266..

          1. Can you forward me the mail web page code sent iot boys for home automation using arduino and esp8266

          2. Hello, I am also trying to develop the web page for this project. Could you please send me the code for the web page too.

  2. my have no String server = “www.iotboys.com”; //Your Host
    String uri = “/YOUR_API”; // Your URI.. so please give me host server or html code or web page code

    please give me step by step description of this project ,as soon as.

  3. i have connected and programmed the arduino but how to use the switch button through your website,please reply fast

  4. Thanks for your tutorial.Could you please send me the html file? I dont know anything about html programming or API.

    1. Hi Alireza,
      To accomplish this project better to have knowledge about Web API and HTML because this is just a demo project lot of other things you need to do apart from this video.
      You must have a web server enabled IIS so that you can host our middleware code there and can make request. Once you are able to host the application let us know will provide the html source code.

      Best Regards,
      IoTBoys

      1. I got a free host with iis server from somee.com and learned how to upload files on the server.Could you please send me the html source code?

  5. Hello ! CAN you tell me how to connect ESP8266 WiFi Module with internet, I have connected each and every thing according to your diagram and have uploaded the same code to my arduino uno that you have provided, please help me out in this. Please

  6. This design is spectacular! You obviously know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool!

  7. Please provide also the web page code to understand the request as soon as possible. Can I add one more device in that

  8. Gracia Ortenzio

    I really can’t believe how great this site is. Keep up the good work. I’m going to tell all my friends about this place.

  9. That sure is one pretty site you have there. Can I ask you a very simple question? What kind of fertilizer do you use to make it grow so wonderfully?

  10. in the video at last you have directly gone to the site of controlling. can you please explain how to open the site and its address

  11. Hey there! I’ve been reading your website for some time
    now and finally got the bravery to go ahead and give you a
    shout out from Lubbock Tx! Just wanted to say keep up the good job!

  12. Great Job IoTBoys!!
    I am very thankful for your tutorial. We are doing similar project for a module in college. But i am stuck in between not knowing how to write API in back-end as I am beginner. We will be thankful if you could share your API or make tutorial for write API for similar project.
    THANK YOU

  13. رمزيات حب

    Hello, yes this article is in fact good and I have learned lot of things from it on the topic of blogging.
    thanks.

  14. Hello, I found this helpful. We are going to create smart home lighting controlled by Android Smartphone using WiFi. Is this project okay to do with android application? because I’ve watched the video you controlled the lights using laptop.. do you have any tutorial, for controlling by using android smartphone or android app?

  15. Can you please kindly reply on my message soon as you read it 🙂 We’re planning to buy arduino device soon, because we only have 1 and half week for our sembreak.. I just needed the list of hardware components for now we’re writing documentation for our capstone. Thank You IoT Boys ^_^ btw, I already have use HTML, JAVA, PHP language.. what was the language will be used in this project ? because I am new to this kind of project.

  16. hello sir ,
    i need the html and api code for the following project in arduino beacause we need to develop the apk frontend and some more brief about the project. thanks in advance

  17. Do i have to configure my ESP8266 also or i just have to put the code in arduino??
    secondly how can i conncet to a link like you have show in your video a website from where you switch on and off the bulbs

Leave a Comment

Your email address will not be published.