How To Control Home Appliance 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 = ""; //Your Host 
String uri = "/YOUR_API"; // Your URI

int RED_BULB=5; 

void setup() {

  pinMode(RED_BULB, OUTPUT);
  digitalWrite(RED_BULB, HIGH);
  digitalWrite(YELLOW_BULB, HIGH);


void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";



if(esp.find("OK")) {


else {

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

/////////////////////////////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" +

String sendCmd = "AT+CIPSEND=";


esp.println(getRequest.length() );


if(esp.find(">")) { 
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;

  digitalWrite(RED_BULB, LOW);
  digitalWrite(RED_BULB, HIGH);
  digitalWrite(YELLOW_BULB, LOW);
  digitalWrite(YELLOW_BULB, HIGH);


void loop() {

You may also like...

28 Responses

  1. Alex says:

    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.

  2. zikrifuaad says:

    how can i get into the cloud

  3. Roma says:

    I love it when folks cⲟme together and
    ѕhare opіnions. Great website, keep it up!

  4. Rishabh says:

    provide also the web page code to understand the request.

  5. somnath panja says:

    my have no String server = “”; //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.

  6. Alireza says:

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

    • IoT Boys IoT Boys says:

      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,

  7. Danish says:

    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

  8. Sunbun says:

    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!

  9. Gracia Ortenzio says:

    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.

  10. Shery Sick says:

    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?

Leave a Reply

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