Friday, April 1, 2016

GSM Based Home Security System With SMS Alert

This project has GSM technology and anti-theft system using PIR motion detection. Whenever Motion is detected it sends the SMS on predefined mobile number. We have connected PIR Motion sensor with this project.

GSM based home security system with SMS alert, it uses PIR Motion Sensor, GSM Modem and 16x2 LCD is used to display system status,  It Sends SMS through GSM modem that is attached to Serial Rxd and Txd  Pins when motion is detected from PIR sensor, Set your mobile number inside the code in SendSMS subroutine.

Features:
1. Sends Theft Alert SMS to Given number.
2. Displays status of system on LCD.
3. Uses PIR Motion sensor 
4. Low Cost

This project is very useful for Monitoring home security
In this project GSM Modem, PIR Sensor, 16x2 LCD and Arduino are main parts. 
You can try this project using Protius simulation. Circuit diagram, is provided with code. Download respective files.

Step 1: Make connections as per circuit diagram



Step 2: Program the Arduino

Program the arduino using following code



/*
Home Security System with SMS Alert

 Blog.Circuits4You.com 2016

 Demonstrates the use of PIR Motion sensor and GSM Module.  The Project
 generate SMS when motion is detected on PIR Sensor

 PIR Sensor is connected to Arduino Pin 8 and GSM Module on Serial Communication 
 Lines, Remove GSM Module While Programming. 
  
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 

 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int PIR=8;

void setup() {
  pinMode(PIR,INPUT);
  Serial.begin(9600);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
}

void loop() {
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("Security System ");
  lcd.setCursor(0, 1);
  lcd.print("   Activated    ");
  
    if(digitalRead(PIR)==HIGH)
    {
      // Print a message to the LCD.
      lcd.setCursor(0, 0);
      lcd.print("Theft Detected  ");
      lcd.setCursor(0, 1);
      lcd.print("Sending SMS.....");
  
      sendSMS();
      delay(5000);
    }
}

void sendSMS()
{
     Serial.println("AT+CMGD=1");    //Delete privious sent SMS
     delay(1000);
          
     Serial.println("AT+CMGF=1");   //Set SMS configuration
     delay(1000);
     
     Serial.print("AT+CMGW=");          //Write New SMS
     Serial.write(34);                  //Double quotes ASCII Code
     Serial.print("+9198--------");         //Enter Your Mobile number
     Serial.write(34);
     Serial.println();                  //Send Crrige return
     delay(1000);
     
     Serial.println("Alert: Theft Detected");
     delay(1000);

     Serial.write(26); //Cntrl+Z
     delay(1000);
     delay(1000);

     Serial.println("AT+CMSS=1");      //Send SMS from memory location 1
     delay(4000);
}


Step 3: Test the code

1. At power on LCD will display "Security System Activated"
2. When Motion is detected it will send SMS Alert to given mobile number.

You can find more demo codes and tutorial from top menu for more clear idea and details.

2 comments: