fbpx

ESP8266-Home Automation

Automation defines allowing things work without human intervention based on the predefined command, In Home allowing electrical appliance work based on soft command over the internet using smartphone.

Block Diagram

Flow Chart

Component Required

  1. Node MCU.
  2. Relay 5v
  3. Jumper wire
  4. BreadBoard

Software Required

  1. MIT App inventor – Android
  2. Firebase
  3. Arduino 

Circuit diagram

Firebase

Login To firebase

  • create new project
  • Create database for home automation device
  • Set firebase security rules to test mode to allow esp8266 to set and read database
  • Set Rules of firebase to read and write in real timedatabase
  • Select Real-time Database 
  • Copy the URL- Required in code as firebase host-id to communicate with firebase
  • Click to add child to Create a field to hold data in firebase
  • Create FAN field to hold device status data in firebase.
  • FAN, DEVICE field in realtime database hold homeautomation field data.
  • Get authentication id from firebase.

Android Application

  • Create New project from mit app inventor for home automation
  • Select layout to place the user interface component
  • Create a header from the Android application: 

             drag and drop label in the screen for app header

  • Android App Home Screen Layout Design
  • Use the firebase database url, you can ignore the FirebaseToken 
  • Add the action need to done when button pressed

When Button1(FAN On Button) Write the vale to firebase as 0                 When Button3(FAN Off Button) Write the vale to firebase as 1

 When Button2(LIGHT On Button) Write the vale to firebase as 0                 When Button4(LIGHT Off Button) Write the vale to firebase as 1

  • Android App  

Code

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define FIREBASE_HOST " "

#define FAN 2
#define LIGHT 3
const char* ssid = "IMAKE"; // Your ssid
const char* password = "12345678"; // Your Password


void setup()
{
pinMode(FAN,OUTPUT);
pinMode(LIGHT,OUTPUT);

Serial.begin(115200);
delay(100);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi is connected");
Serial.println(WiFi.localIP());
delay(1000);
Firebase.begin(FIREBASE_HOST);
}


void loop()
{
if(Firebase.getString("FAN") == "0")
{
  digitalWrite(FAN,HIGH);
}else if(Firebase.getString("FAN") == "1")
{
  digitalWrite(FAN,LOW);

}
if(Firebase.getString("LIGHT") == "0")
{
  digitalWrite(LIGHT,HIGH);
}else if(Firebase.getString("LIGHT") == "1")
{
  digitalWrite(LIGHT,LOW);

}
}


 

Leave a Reply

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