GSM based Home security system

GSM based Home security system using SIM 800L GSM module

projectImage

Things used in this project

 

Hardware components

HARDWARE LIST
1 Arduino UNO
1 GSM SIM800l
1 PIR Sensor, 7 m

Story

 

In this tutorial, I will show you how to make GSM Home Security using Arduino UNO, SIM800L GSM Module and PIR Motion Sensor. This gsm based system detects motion by using pir motion sensor and sends data to Arduino and then Arduino micro controller sends call alert to the emergency number through the sim800l GSM module.This is a very simple and easy to build home security system with just few lines of code. you can build this security system at home with a little efforts.

Schematics

projectImage

Code

CODE
/* This code works with motion sensor, when motion detects it will automatic call on number which is in code.
 * For more videos please visit our youtube channel. https://www.youtube.com/channel/UCsn5KGbvt5Se7MaLsfNYthA
 */

#include <SoftwareSerial.h>

SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted

#define Motion_Sensor A0 //Button pin, on the other pin it's wired with GND
bool Sensor_State; //Sensor_State


void setup()
{
 
  pinMode(Motion_Sensor, INPUT); //The button is always on HIGH level, when pressed it goes LOW
  sim800l.begin(9600);   //Module baude rate, this is on max, it depends on the version
  Serial.begin(9600);   
  delay(1000);
}
 
void loop()
{
  
//SendSMS(); 
  Sensor_State = digitalRead(Motion_Sensor);   //We are constantly reading the button State
 
  if (Sensor_State == HIGH) {            //And if it's pressed
    Serial.println("Sensor detect motion");   //Shows this message on the serial monitor
    delay(200);                         //Small delay to avoid detecting the button press many times
    
    SendSMS();                          //And this function is called
delay(4000);

 }
 else{
 Serial.println(".");
 }
 
  if (sim800l.available()){            //Displays on the serial monitor if there's a communication from the module
    Serial.write(sim800l.read()); 
  }
}
 
void SendSMS()
{
  Serial.println("Sending SMS...");               //Show this message on serial monitor
  sim800l.print("AT+CMGF=1\r");                   //Set the module to SMS mode
  delay(100);
  sim800l.print("AT+CMGS=\"+###############\"\r");  //Your phone number don't forget to include your country code, example +212123456789"
  delay(500);
  sim800l.print("Security Alert.....!!!!!!! Some one entered in the house ");       //This is the text to send to the phone number, don't make it too long or you have to modify the SoftwareSerial buffer
  delay(500);
  sim800l.print((char)26);// (required according to the datasheet)
  delay(500);
  sim800l.println();
  Serial.println("Text Sent.");
  delay(500);

}

The article was first published in hackster, December 6, 2021

cr: https://www.hackster.io/munir03125344286/gsm-based-home-security-system-c9ad90

author: Muhammad_Munir

License
All Rights
Reserved
licensBg
0