Control Home Appliance From Internet Using Arduino and WiFi

Control home appliances from anywhere in world using Internet. Make your home smart with Arduino and ESP8266 WiFi Module.

  • 9,465 views
  • 3 comments
  • 15 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
REST API

About this project

In this project 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.

Detail description available on www.iotboys.com

Visit www.iotboys.com for more projects .

Code

Source CodeC/C++
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();
}

Schematics

Circuit Design
Circuit Design
Control home appliances from anywhere from internet 1 1024x844 hrwrwvnbkr

Comments

Similar projects you might like

Stringent, the $15 Wall Plotter

Project tutorial by Fredrik Stridsman

  • 13,985 views
  • 17 comments
  • 85 respects

The Talking Alarm Clock

Project tutorial by Abe-Z

  • 290 views
  • 0 comments
  • 2 respects

Arduino LCD Video Game

Project tutorial by xXarduino_11Xx

  • 462 views
  • 0 comments
  • 5 respects

Cocktail Parasol

by alain_haerri

  • 3,223 views
  • 7 comments
  • 13 respects

Automated Projector Controller

Project tutorial by Kulwant singh

  • 1,080 views
  • 0 comments
  • 11 respects
Add projectSign up / Login