GSM Based Home Security System

Security is a big challenge everywhere because thefts, gas leakage are increasing day by day. This system is used to alert us from danger by sending SMS through GSM Modules.

Here, gas sensor acts as a gas leakage detector, PIR acts as a motion detector and LCD to display the message for our reference. This project detects either gas leaking or motion detection, it sends SMS through a GSM Module when an alert is triggered.
Circuit Diagram:-
PROJECT DETAILS:-
1. Detect Gas Leakage (like LPG,Smoke) such petroleum based gaseous substance that can be detected using MQ2 Sensor. PIR detects the motion, We can connect a manual ON/OFF Power Switch to enable or disable to avoid unnecessary triggers.
2. Setup an SMS based Alert Mechanism and send 3 SMS (3 alert messages) to 2 specified mobile numbers (that is stored in Arduino Code).
3. Produce a sound alarm upon gas leak ,motion detection and stop the alarm once gas leak is under control (gas presence in atmosphere is under normal range).
4. Display status in an LCD using a 16×2 LCD module.

COMPONENTS REQUIRED:-
1. SIM800L GSM Module
2. PIR sensor
3. MQ2 sensor
4. Arduino UNO
5. LCD (16*2) Display with I2C
6. Buzzer
7. Jumper wires
8. 12V DC Adopter/1Amps
GSM Module Pins:-
TX:Transmitter pin which is connected to RX of arduino.
RX:Receiver pin which is connected to the TX of arduino.

PIR Sensor Pins:-
VCC: Power Supply Positive
GND: Ground
OUT: Sensor digital output

MQ2 Sensor Pins:-
VCC: Power Supply Positive
GND: Ground
DO: Sensor Digital output
AO: Analog Output

LIBRARY USED:- 
SoftwareSerial: https://github.com/PaulStoffregen/SoftwareSerial
LCD I2C Library: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

PROGRAM:
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial gsm(9, 10);//Arduino’s (Rx,Tx)

int gassensor = 8;
int buzzer = 6;
int gasRead, Gas_alert_val, recheckGas;
int Gas_Leak_Status;
int sms_count = 0;
int pir = 5;
int pir_Status;

void setup()
{
pinMode(gassensor, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(pir, INPUT);
Serial.begin(9600);
lcd.begin();
gsm.begin(4800);
delay(500);
digitalWrite(buzzer, LOW);
}
void loop()
{
int pirsensor = digitalRead(pir);
if (pirsensor == HIGH)
{
digitalWrite(buzzer, HIGH);
delay(1000);
while (sms_count < 3)
{
gsm.println(“AT+CMGF=1”);
delay(1000);
gsm.println(“AT+CMGS=\”+91XXXXXXXXXX\”\r”); // change to the phone number you using
delay(1000);
gsm.println(“someone entered!”);
delay(200);
gsm.println((char)26);
delay(1000);
gsm.println(“AT+CMGS=\”+91XXXXXXXXXX\”\r”); // change to the phone number you using
delay(1000);
gsm.println(“pir alert !”);
delay(200);
gsm.println((char)26);
delay(1000);
sms_count++;
}
pir_Status = 1;
lcd.setCursor(0, 1);
lcd.print(“pir Alert! SMS “);
Serial.println(“pir Alert! SMS “);
delay(2000);
lcd.clear();
}
else
{
digitalWrite(buzzer, LOW);
delay(1000);
}
CheckGas(); //Check Gas Leaked or not
CheckShutDown(); //Check again if gas leakage stopped
}
void CheckGas()
{

lcd.setCursor(0, 0);
lcd.print(“Home Security”);
//Serial.println(“Gas Scan – ON”);
Gas_alert_val = ScanGasLevel();
if (Gas_alert_val == LOW)
{
SetAlert(); // Function to send SMS Alerts
}
}
int ScanGasLevel()
{
gasRead = digitalRead(gassensor); // reads the Gas sensor D0 Pin

return gasRead; // returns temperature value in degree celsius
}

void SetAlert()
{
digitalWrite(buzzer, HIGH);
while (sms_count < 3)
{
gsm.println(“AT+CMGF=1”);
delay(1000);
gsm.println(“AT+CMGS=\”+91XXXXXXXXXX\”\r”); // change to the phone number you using
delay(1000);
gsm.println(“Gas Leaking!”);//the content of the message
delay(200);
gsm.println((char)26);//the stopping character
delay(1000);
gsm.println(“AT+CMGS=\”+91XXXXXXXXXX\”\r”); // change to the phone number you using
delay(1000);
gsm.println(“Gas Leaking!”);//the content of the message
delay(200);
gsm.println((char)26);//the message stopping character
delay(1000);
sms_count++;
}
Gas_Leak_Status = 1;
lcd.setCursor(0, 1);
lcd.print(“Gas Alert! SMS “);
Serial.println(“Gas Alert! SMS “);
delay(2000);
lcd.clear();
}

void CheckShutDown()
{
if (Gas_Leak_Status == 1)
{

recheckGas = ScanGasLevel();
if (recheckGas == HIGH) //D0 Pin becomes HIGH when No Gas
{
lcd.setCursor(0, 1);
lcd.print(“No Gas Leaking”);
Serial.println(“No Gas Leaking”);
digitalWrite(buzzer, LOW);
sms_count = 0; //Reset count for next alert triggers
Gas_Leak_Status = 0;
}
}
}

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 504

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×