GSM Based Home Automation using Arduino, GSM SIM900

Share This

Hello friends! Welcome back to ElectroDuino. This blog is base on GSM Based Home Automation using Arduino and GSM SIM900 Module. Here we will discuss Introduction to GSM Based Home Automation System, Project Concept, Block Diagram, components required, circuit diagram, working principle, and Arduino code.

Introduction

Home Automation System is a wireless technology that is used to control home appliances remotely. This system is alow to control your home appliances using a computer, phone, or remote. At the present time, many types of Home Automation Systems are available in the market. These are DTMF-controlled home Automation, IR Remote based home Automation, RF remote-controlled home Automation, Bluetooth-controlled home Automation, and IoT-based Home Automation. In this blog, we will design a GSM Based Home Automation using Arduino and GSM SIM900 Module.

Project Concept of GSM Based Home Automation System

The GSM Based Home Automation system is used to control home appliances by sending SMS from your Phone. This project is consists of Arduino, GSM SIM900 Module, 16×2 LCD module, and Relay Module. Where Arduino is the main microcontroller which controls the entire system. GSM Module is used to wireless communication with the phone, for controlling home appliances. The 16×2 LCD module is used to display the status (turn ON or turn OFF) of the home appliances. The relay module is an electronic switch, that’s control AC appliances. We send SMS like “#light on*”, “#light off*” from the Phone to turn ON or OFF the Light using a Relay Module. We can control electrical devices like light bulbs, motor, fan, TV, refrigerator, etc using this system. Here in this project, we have used 4 220v bulbs for the demonstration which indicates Light, Fan, Pump, and TV.

Block Diagram

GSM Based Home Automation using Arduino and GSM SIM900 Module
GSM Based Home Automation using Arduino

Components Required

Components NameQuantity
Arduino UNO1
GSM SIM900 Module1
16×2 LCD Module1
4 Channel Relay Module1
AC Bulb with Holder and Wire4
9V 1 Amp Adapter (DC Power supply)1
Cell phone1
PCB board1
Connecting wiresAs required in the circuit diagram
220V AC Power supply 

Tools Required

Tools NameQuantity
Soldering Iron1
Soldering wire1
Soldering flux1
Soldering stand1
Multimeter1
Desoldering pump1
Wirecutter1

Circuit Diagram of GSM Based Home Automation using Arduino and GSM SIM900 Module

GSM Based Home Automation using Arduino and GSM SIM900 Module Schematic
GSM Based Home Automation using Arduino and GSM SIM900 Module Schematic

Circuit Wiring

Components PinArduino pin
GSM module Vcc, Relay module Vcc and LCD  Display Vdd and LED + Pins  Arduino 5V Pin, but LCD  Display LED + Pins connected to Arduino 5V Pin through 220ohm resistor.
GSM module Gnd, Relay module Gnd and LCD  Display Vss, Rw and LED – Pins GND (ground) Pin
GSM module TXDigital Pin “D0 / RX”
GSM module RXDigital Pin “D1 / TX”
4 Channel Relay Modules IN1, IN2, IN3, IN4Respectively  Digital Pin “D6”, “D5”, “D4”, “D3”, 
LCD  Display RS, E, D4, D5, D6, D7Respectively  Digital Pin “D12”, “D11”, “D10”, “D9”, “D8”, “D7”
LCD  Display V0 pin  10k Potentiometer Signal pin, Potentiometer one pin is connected to 5V and another pin is connected to GND(ground)
9V 1 Amp Adapter External DC Power supply for operating Arduino and GSM module

Working Principle

In Arduino programming, we have used a prefix in the command string that is “#”. This prefix is used to identify that the main command is coming next to it and “*” at the end of the string indicates that message has been ended. The program’s main loop continuously checks the availability of serial data from the GSM module. When we send an SMS from the phone like “#A.light on*”, “#A.light of*”, the GSM module receives the SMS and passes it to the microcontroller. Then Arduino reads this SMS and decodes the main command from the arrived string and stores in a variable. If this string match with the predefined string, then Arduino sends a signal to the relay module for turning ON and OFF the home appliances. You can see the home appliance’s current status on the LCD display (like, turn ON or turn OFF).

If this string does not match with the predefined string, then Arduino does not send the signal to the relay.

Below is the list of Messages .which is used to turn On and Off the Light, Fan, TV, and Pump.

SL.NOSMS from phone

Operation

1#light on*Light on
2#light off*Light off
3#fan on*Fan on
4#fan off*Fan off
5#tv on*TV on
6#tv off*TV off
7#pump on*Pump on
8#pump off*Pump off
9#all on*All appliance on
10#all off*All appliance off

Code for GSM Based Home Automation using Arduino and GSM SIM900 Module

#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,10,9,8,7);

#define Pump 6
#define TV 5
#define Fan 4
#define Light 3

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

void setup()

{

  lcd.begin(16,2);
  Serial.begin(9600);

  pinMode(Pump, OUTPUT);
  pinMode(TV, OUTPUT);
  pinMode(Fan, OUTPUT);
  pinMode(Light, OUTPUT);

  lcd.setCursor(0,0);
  lcd.print("GSM Based Home");
  lcd.setCursor(0,1);
  lcd.print("   Automaton    ");
  delay(2000);

  lcd.clear();
  lcd.print("ELECTRODUINO.");
  lcd.setCursor(0,1);

  lcd.print("     COM      ");
  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("Pump TV Fan Bulb");
  lcd.setCursor(0,1);
  lcd.print("OFF OFF  OFF OFF");

}

void loop()

{
  lcd.setCursor(0,0);
  lcd.print("Pump TV Fan Bulb");

  if(temp==1)

  {
    check();
    temp=0;
    i=0;
    delay(1000);
  }

}

 void serialEvent()

 {
  while(Serial.available())
  {
    if(Serial.find("#"))
    {
      while (Serial.available())
      {
      char inChar=Serial.read();
      str[i++]=inChar;
      if(inChar=='*')
      {
        temp=1;
        return;
      }
      }
    }
   }
  }




void check()

{
     if(!(strncmp(str,"pump on",5)))

    {
      digitalWrite(Pump, HIGH);
      lcd.setCursor(0,1);
      lcd.print("ON ");
      delay(200);
    } 

    else if(!(strncmp(str,"pump off",6)))

    {
      digitalWrite(Pump, LOW);
      lcd.setCursor(0,1);
      lcd.print("OFF");
      delay(200);
    }

      else if(!(strncmp(str,"tv on",5)))

    {
      digitalWrite(TV, HIGH);
      lcd.setCursor(4,1);
      lcd.print("ON ");
      delay(200);
    } 

    else if(!(strncmp(str,"tv off",6)))

    {
      digitalWrite(TV, LOW);
      lcd.setCursor(4,1);
      lcd.print("OFF");
      delay(200);
    }

    else if(!(strncmp(str,"fan on",5)))

    {
      digitalWrite(Fan, HIGH);
      lcd.setCursor(9,1);
      lcd.print("ON");
      delay(200);
    }

    else if(!(strncmp(str,"fan off",7)))

    {
      digitalWrite(Fan, LOW);
      lcd.setCursor(9,1);
      lcd.print("OFF");
      delay(200);
    }

    else if(!(strncmp(str,"light on",8)))

    {
      digitalWrite(Light, HIGH);
      lcd.setCursor(13,1);
      lcd.print("ON    ");
      delay(200);
    }

    else if(!(strncmp(str,"light off",9)))

    {
      digitalWrite(Light, LOW);
      lcd.setCursor(13,1);
      lcd.print("OFF");
      delay(200);
    }
   
    else if(!(strncmp(str,"all on",6)))

    {
      digitalWrite(Light, HIGH);
      digitalWrite(Fan, HIGH);
      digitalWrite(TV, HIGH);
      lcd.setCursor(0,1);
      lcd.print("ON  ON   ON  ON ");
      delay(200);
    }

    else if(!(strncmp(str,"all off",7)))

    {
      digitalWrite(Light, LOW);
      digitalWrite(Fan, LOW);
      digitalWrite(TV, LOW);
      lcd.setCursor(0,1);
      lcd.print("OFF OFF  OFF OFF");
      delay(200);
    }    
}
Share This

Leave a Reply

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