PIR Sensor Alarm System with GSM Connectivity

This article provides a step-by-step guide to building a security alarm system using an Arduino Uno, PIR sensor, SIM800L GSM module, and a buzzer, which detects motion and alerts you of intrusions via a GSM call.

Components Needed

Arduino Uno

PIR Sensor

A PIR (Passive Infrared) sensor is a motion sensor widely used in security and automation systems. It contains a pyroelectric sensor, which detects infrared radiation, and a lens to focus the radiation onto the sensor. The crystalline material in the pyroelectric sensor generates an electrical charge when it senses infrared radiation.

GSM sim800l Module

Circuit Diagram

PIR Sensor

GSM Module

Source Code

//Prateek

//https://justdoelectronics.com

//https://www.youtube.com/c/JustDoElectronics/videos

 

#include <SoftwareSerial.h>

const String PHONE = “+918830584864xx”;

#define rxPin 2

#define txPin 3

 

SoftwareSerial sim800(rxPin, txPin);

int pir_sensor = 6;

 

void setup() {

pinMode(pir_sensor, INPUT);

Serial.begin(115200);

sim800.begin(9600);

Serial.println(“SIM800L software serial initialize”);

sim800.println(“AT”);

delay(1000);

}

 

void loop() {

while (sim800.available()) {

Serial.println(sim800.readString());

}

while (Serial.available()) {

sim800.println(Serial.readString());

}

int val = digitalRead(pir_sensor);

if (val == HIGH) {

Serial.println(“Motion detected!”);

Serial.println(“calling….”);

delay(1000);

sim800.println(“ATD” + PHONE + “;”);

delay(20000);

}

}

 

 

Let’s go through the code and explain its functionality.

 

#include <SoftwareSerial.h>

const String PHONE = “+918830584864xx”;

#define rxPin 2

#define txPin 3

 

SoftwareSerial sim800(rxPin, txPin);

int pir_sensor = 6;

 

void setup() {

pinMode(pir_sensor, INPUT);

Serial.begin(115200);

sim800.begin(9600);

Serial.println(“SIM800L software serial initialize”);

sim800.println(“AT”);

delay(1000);

}

 

void loop() {

while (sim800.available()) {

Serial.println(sim800.readString());

}

while (Serial.available()) {

sim800.println(Serial.readString());

}

int val = digitalRead(pir_sensor);

if (val == HIGH) {

Serial.println(“Motion detected!”);

Serial.println(“calling….”);

delay(1000);

sim800.println(“ATD” + PHONE + “;”);

delay(20000);

}

}

Project Demo

Conclusion

This DIY project can be used for the security system of your home and office. if you used the Pir sensor then be care full is detect some time fault signal. I suggest you if you try to make a motion-based security system you used an ultrasonic sensor.