Home Automation System

Home Automation System

Controlling home appliances using GSM and Arduino

In this module, we are building a home automation system, where one can control the home appliances, using the simple smart phone, just by sending SMS through phone. It will turn any home electronic appliances ON and OFF from anywhere.

In this module, Arduino is used for controlling whole the process. Here we have used GSM wireless communication for controlling home appliances. We send some commands like “#light on*”, “#light off*”, “#fan on*”, “#fan off*” and so on for controlling AC home appliances. After receiving given commands by Arduino through GSM, Arduino send signal to relays, to switch ON or OFF the home appliances using a relay driver.

Here we have used a prefix in command string that is “#”. This prefix is used to identify that the main command is coming next to it and “*” at the end of string indicates that message has been ended.

When we send SMS to GSM module by Mobile, then GSM receives that SMS and sends it to Arduino. Now Arduino reads this SMS and extract main command from the received string and stores in a variable. After this, Arduino compare this string with predefined string. If match occurred then Arduino sends signal to relay via relay driver for turning ON and OFF the home appliances. And relative result also prints on 16×2 LCD by using appropriate commands.

Components required:

  • Arduino UNO
  • GSM module
  • Relay switch
  • Bulb with holder
  • Connecting wires
  • Breadboard
  • 16*2 LCD
  • Power Supply
  • Mobile phone

Block diagram:

Fig 1: Block diagram of controlling electronic home appliances

Here, there is list of messages which we send via SMS to turn appliances On and Off:

Here, there is pin specifications of the components for home automation system:

Arduino                              LCD

GND         ————–>   Pin1
5V             ————–>   Pin2
10k + D13  ———–>    Pin3
D12         ————–>    Pin4
GND        ————–>    Pin5
D11         ————–>    Pin6
NC           ————–>    Pin7
NC           ————–>    Pin8
NC           ————–>    Pin9
NC           ————–>    Pin10
D5           ————–>    Pin11
D4           ————–>    Pin12
D3           ————–>    Pin13
D2           ————–>    Pin14
5V           ————–>    Pin15
GND       ————–>    Pin16

Arduino                        Relay

D7         ————–>      In1
D8         ————–>      In2
D9         ————–>      In3
D10      ————–>      In4

Relay                             Home Appliances

NC1      ————–>      Power supply(Vcc)
CP1      ————–>       Light(Vcc)
NC2      ————–>      Power supply(Vcc)
CP2      ————–>       Fan(Vcc)
NC3      ————–>      Power supply(Vcc)
CP3      ————–>       Tv(Vcc)
NC4      ————–>      Power supply(Vcc)
CP4      ————–>       Ac(Vcc)

NoteLight, Fan, Tv, Ac(GND) to Power supply(GND)and also make sure that connect GSM(Rx) pin to Arduino(Tx1) pin and GSM(Tx) pin to Arduino(Rx0) pin.

Here is the arduino code:

#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define Light 7
#define Fan 8
#define TV 9
#define AC 10

int temp=0,i=0;
char str[15];

void setup()
{
 lcd.begin(16,2);
 Serial.begin(9600);
 pinMode(Light, OUTPUT);
 pinMode(Fan, OUTPUT);
 pinMode(TV, OUTPUT);
 pinMode(AC, OUTPUT);
 
 lcd.setCursor(0,0);
 lcd.print("GSM Control Home");
 lcd.setCursor(0,1);
 lcd.print(" Automation ");
 delay(2000);
 lcd.clear();
 lcd.print("Circuit Digest");
 delay(1000);
 lcd.setCursor(0,1);
 lcd.print("System Ready");
 Serial.println("AT+CNMI=2,2,0,0,0");
 delay(500);
 Serial.println("AT+CMGF=1");
 delay(1000);
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Light Fan TV AC ");
 lcd.setCursor(0,1);
 lcd.print("OFF OFF OFF OFF"); 
}
void loop()
{
 lcd.setCursor(0,0);
 lcd.print("Light Fan TV AC ");
 if(temp==1)
 {
 check();
 temp=0;
 i=0;
 delay(1000);
 }
}
 void serialEvent() 
 {
 while(Serial.available()) 
 {
 if(Serial.find("#"))
 {
 //digitalWrite(led, HIGH);
 delay(1000);
 //digitalWrite(led, LOW);
 while (Serial.available()) 
 {
 char inChar=Serial.read();
 str[i++]=inChar;
 if(inChar=='*')
 {
 temp=1;
 return;
 } 
 } 
 }
 }
 }
void check()
{
 if(!(strncmp(str,"light on",8)))
 {
 digitalWrite(Light, HIGH);
 lcd.setCursor(7,1); 
 lcd.print("ON ");
 Serial.println("LIGHT ON");
 delay(200);
 }
 
 else if(!(strncmp(str,"light off",9)))
 {
 digitalWrite(Light, LOW);
 lcd.setCursor(7,1); 
 lcd.print("OFF");
 Serial.println("LIGHT OFF");
 delay(200);
 } 
 
 else if(!(strncmp(str,"fan on",6)))
 {
 digitalWrite(Fan, HIGH);
 lcd.setCursor(0,1); 
 lcd.print(" ON");
 Serial.println("FAN ON");
 delay(200);
 }
 
 else if(!(strncmp(str,"fan off",7)))
 {
 digitalWrite(Fan, LOW);
 lcd.setCursor(0,1); 
 lcd.print(" OFF");
 Serial.println("FAN OFF");
 delay(200);
 }
 
 else if(!(strncmp(str,"tv on",5)))
 {
 digitalWrite(TV, HIGH);
 lcd.setCursor(7,1); 
 lcd.print(" ON");
 Serial.println("TV ON");
 delay(200);
 }
 
 else if(!(strncmp(str,"tv off",6)))
 {
 digitalWrite(TV, LOW);
 lcd.setCursor(7,1); 
 lcd.print(" OFF");
 Serial.println("TV OFF");
 delay(200);
 } 
 
 else if(!(strncmp(str,"ac on",5)))
 {
 digitalWrite(AC, HIGH);
 lcd.setCursor(7,1); 
 lcd.print(" ON");
 Serial.println("AC ON");
 delay(200);
 }
 
 else if(!(strncmp(str,"ac off",6)))
 {
 digitalWrite(AC, LOW);
 lcd.setCursor(7,1); 
 lcd.print(" OFF");
 Serial.println("AC OFF");
 delay(200);
 } 
 else if(!(strncmp(str,"all on",6)))
 {
 digitalWrite(Light, HIGH);
 digitalWrite(Fan, HIGH);
 digitalWrite(TV, HIGH);
 digitalWrite(AC, HIGH);
 lcd.setCursor(0,1); 
 lcd.print("ON ON ON ON");
 Serial.println("ALL ON");
 delay(200);
 }
 
 else if(!(strncmp(str,"all off",7)))
 {
 digitalWrite(Light, LOW);
 digitalWrite(Fan, LOW);
 digitalWrite(TV, LOW);
 digitalWrite(AC, LOW);
 lcd.setCursor(0,1); 
 lcd.print("OFF OFF OFF OFF ");
 Serial.println("ALL OFF");
 delay(200);
 } 
}

Some screenshots of implementation:


Youtube link:

Smart Door Locking System

In this module we build smart door locking system, that opens when you enter the password and similarly closes door by pressing “*” and “#” key through 4*4 keypad. Furthermore, this module will expanded by integrating it with ESP8266 wifi module through which you can operate the lock wirelessly by giving password using mobile application and apart from that we can also use bluetooth module to connect with it.

Components required for smart door locking system are:

  • PCB
  • Switches
  • Connecting wires
  • Soldering wire
  • Arduino UNO
  • Servo motor
  • 9V power supply
  • Esp8266 wifi module
  • 16*2 LCD screen

Note: Here we made keypad using switch for our sake of knowledge you can also use 4*4 membrane keypad.

In this module, the servo motor is an essential components require for opening and closing the door. Servo motor have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board.

    • Here, is the pin specifications of Smart door locking system:

      Keypad                                  Arduino

      Col1             ————–>      D10
      Col2             ————–>      D9
      Col3             ————–>      A0
      Col4             ————–>      A1
      Row1           ————–>      A2
      Row2           ————–>      A3
      Row3           ————–>      A4
      Row4           ————–>      A5

      Servo Motor                      Arduino

      Signal         ————–>       D6
      VCC            ————–>       VCC
      GND           ————–>        GND

       Here is the arduino code:

      #include <Servo.h>
      #include <Keypad.h>
      
      Servo servo_Motor; 
      char* password = "123AB";
      int position = 0;
      
      const byte ROWS = 4; 
      const byte COLS = 4; 
      
      char keys[ROWS][COLS] = {
      {'1','2','3','A'},
      {'4','5','6','B'},
      {'7','8','9','C'},
      {'*','0','#','D'}
      };
      
      byte rowPins[ROWS] = {A2, A3, A4, A5};
      //byte colPins[COLS] = {5, 4, 3, 2};
      byte colPins[COLS] = {10, 9, A0, A1};
      Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
      int redPin = 7;
      int greenPin =8;
      
      
      void setup()
      {
        Serial.begin(9600);
        
        delay(1000);
        pinMode(redPin, OUTPUT);
        pinMode(greenPin, OUTPUT);
        Serial.println("Door Lock System");
        servo_Motor.attach(6);
        setLocked(true);
      }
      
      void loop()
      {
        char key = keypad.getKey();
        if (key == '*' || key == '#')
        {
          position = 0;
          setLocked(true);
        }
        if (key == password[position])
        {
            position ++;
        }
        if (position == 5)
        {
          setLocked(false);
        }
        delay(100);
      }
      
      void setLocked(int locked)
      {
        if (locked)
        {
          digitalWrite(redPin, HIGH);
          digitalWrite(greenPin, LOW);
          servo_Motor.write(0);
          
          Serial.println("Door closed");
          delay(1000);
        }
        else
        {
          digitalWrite(redPin, LOW);
          digitalWrite(greenPin, HIGH);
          servo_Motor.write(90);
          
          Serial.println("Door Opened");
      
        }
      }
      

      Some screenshots of implementation:

Youtube link:

Robomopper using HC-05 Bluetooth

This module covers a wide range of robotics applications and highly focused on DIY area. The aim of this module is to develop an autonomous robot that can move itself without continuous human guidance. The autonomous cleaner robot consists of low power consuming electronic components and it can operate at very low power.

It is design and implement a Autonomous Vaccum Cleaner Robot and can be handle manually via Phone Application. Vacuum Cleaner Robot is designed to make cleaning process become easier rather than by using manual vacuum or we can say human itself. The main objective of this module is to design and implement a vacuum robot prototype. Also, the vaccum robot can be operated using bluetooth module via andriod application to handle it manually by giving commands to robot to move in any direction respectively.

Hardware/Software required for these module are:

  • Arduino UNO
  • HC-05 bluetooth
  • 2 x DC motor(150 rpm)
  • Motor Driver
  • Water pump
  • Handmade chassis, wheel, mob
  • Sena App(for operating bluetooth module)

Here, the pin specifications of Floor cleaner robot are:

Motor Driver                            Arduino

In1                        ————–>    D7
In2                        ————–>    D8
In3                        ————–>    D9
In4                        ————–>    D10
GND                     ————–>    GND

HC-05 Bluetooth                       Arduino

5V                         ————–>    NC
Rx                         ————–>     Tx
Tx                         ————–>     Rx
3.3V                     ————–>     3.3V
GND                     ————–>    GND

Note: Apply power supply to motor driver through 9v to 12v battery and also connect left DC motor and right DC motor to motor driver to give respectively.

 Here is the arduino code:

int in1=8;
int in2=9;
int in3=10;
int in4=11;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(in1,OUTPUT);
  pinMode(in2,OUTPUT);
  pinMode(in3,OUTPUT);
  pinMode(in4,OUTPUT);
  Serial.println("Demonstration Of Simple Robot");
  delay(500);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)
  {
    int input=Serial.read();
    switch(input)
    {
      case 'f' : MoveF();
      break;
      case 'b' : MoveB();
      break;
      case 'l' : MoveL();
      break;
      case 'r' : MoveR();
      break;
      case 's' : Stop();
      break;
      default : break;
    }
  }
}

void MoveF()
{
  Serial.println("move forword..");
  digitalWrite(in3,HIGH);
  digitalWrite(in4,LOW);
  digitalWrite(in1,HIGH);
  digitalWrite(in2,LOW);
}

void MoveB()
{
  Serial.println("move backword..");
  digitalWrite(in3,LOW);
  digitalWrite(in4,HIGH);
  digitalWrite(in1,LOW);
  digitalWrite(in2,HIGH);
}

void MoveL()
{
  Serial.println("move Left..");
  digitalWrite(in3,LOW);
  digitalWrite(in4,LOW);
  digitalWrite(in1,HIGH);
  digitalWrite(in2,LOW);
}

void MoveR()
{
  Serial.println("move Right..");
  digitalWrite(in3,HIGH);
  digitalWrite(in4,LOW);
  digitalWrite(in1,LOW);
  digitalWrite(in2,LOW);
}

void Stop()
{
  Serial.println("Stopp..");
  digitalWrite(in3,LOW);
  digitalWrite(in4,LOW);
  digitalWrite(in1,LOW);
  digitalWrite(in2,LOW);
}