Burglar Alarm using Arduino and PIR Sensor with SMS Alarm using GSM Module
We have built a simple arduino anti theft alarm, why not build an advanced version of the same burglar detector? What if we can build a burglar alarm that texts you an sms when an intruder is detected ? cool idea – isn’t it? So lets get our hands at it – a burglar alarm that sends text message (sms) using arduino and pir sensor.
We are going to use a gsm module in addition to components and modules used in above circuit. You need to have an idea of how to interface a gsm module and arduino together before you begin this project. Assemble the circuit as shown in the gsm burglar alarm circuit.
GSM/GPRS Module – Buyers Guide – you don’t own a GSM/GPRS module? are you looking to buy one? Please go through our detailed buyers guide for GSM/GPRS module which helps you to choose the right module in the right price range.
GSM based Arduino Intruder Alarm – Circuit Diagram
Connections Explained!
Refer previous circuit diagram and its explanation first. The only addition module used is GSM Module.
GSM Module – Connect its Tx pin to Pin 9 of Arduino | Connect Rx to Pin 10 – Arduino | Vcc or Power Jack to +12 Volt | Make GND or Ground pin common to all other components and modules
Objectives of the PIR Sensor Alarm using Arduino
Detect a motion – an intruder or a burglar using PIR sensor
Activate the buzzer alarm upon detection of burglar/intruder – Alarm should sound until Reset switch is pressed
Send 3 SMS to a predefined mobile number set inside the program.
Stop the alarm when reset switch is pressed. Also reactivate the SMS alert facility upon reset.
#include<SoftwareSerial.h> SoftwareSerial mySerial(9, 10); int sensor=7; //The output of PIR sensor connected to pin 7 int push_switch=6; // push button switch connected to pin 6 int buzzer=8; // buzzer connected at pin 8 int sensor_value; //variable to hold read sensor value int sms_count=0; void setup() { pinMode(sensor,INPUT); // configuring pin 7 as Input pinMode(push_switch,INPUT); // configuring pin 6 as Input pinMode(buzzer,OUTPUT); // configuring pin 8 as OUTPUT mySerial.begin(9600); } void loop() { Check_Burglar();// subroutine to check sensor status and activation of outputs Check_Reset(); // subroutine to check if alarm reset switch pressed or not } void Check_Burglar() { sensor_value=digitalRead(sensor); // Reading sensor value from pin 7 if(sensor_value==HIGH) // Checking if PIR sensor sends a HIGH signal to Arduino { digitalWrite(buzzer,HIGH); // Activating the buzzer while(sms_count<3) //Number of SMS Alerts to be sent limited at 3 { SendTextMessage(); // Function to send AT Commands to GSM module } }} void Check_Reset() { if(digitalRead(push_switch==HIGH))// Checking if pushbutton was pressed { digitalWrite(buzzer,LOW); // turning OFF the buzzer sms_count=0; // Reactivating the SMS Alert Facility }} void SendTextMessage() { mySerial.println("AT+CMGF=1"); //To send SMS in Text Mode delay(1000); mySerial.println("AT+CMGS="+919495xxxxxx"r"); // change to the phone number you using delay(1000); mySerial.println("Gas Leaking!");//the content of the message delay(200); mySerial.println((char)26);//the stopping character delay(1000); sms_count++; }
So how simple was that advanced Arduino intrusion alarm using GSM module ? The program is self explanatory! If you have any doubts, please ask in comments section.