Burglar Alarm using Gsm with Arduino Uno Code
Burglar with SMS Alarm using GSM, Burglar Alarm with SMS using GSM with PIR: A Burglar Alarm – is basically an intruder alarm or an anti theft alarm.
So this project is all about building an anti theft alarm or an intruder alarm using Arduino and PIR sensor.
It is possible to enhance this project with many features like adding a GSM module to send SMS alerts to specified mobile numbers when an intruder is detected (when a motion is detected inside the range of PIR sensor).
So lets get to building our burglar alarm project using arduino.
The circuit diagram to build a simple burglar alarm or an intruder alarm using arduino is given below. You may assemble the circuit as shown in the diagram. Before getting into working of the alarm circuit, I shall brief the components used in this project.
PIR Sensor – is the heart of this simple burglar alarm circuit using arduino. A PIR sensor – is basically a motion sensor or a motion detector which identifies any object that moves inside its range of view.
PIR sensor identifies infra red radiations emitted by any object under its radar range.
Buzzer is used to create a sound alarm when ever a movement is identified inside the range of PIR sensor. A transistor 2N2222 is used to drive the buzzer.
The maximum current that can be sourced or sinked from an arduino pin is 20mA (the total current being 200mA from different pins).
But the buzzer will need more than just 20mA for its proper functioning. So how to give the necessary current required fir buzzer ?
We use switching transistor 2N222 for this purpose. It can act as a switch and at the same time it provides the required current amplification.
A 2N2222 transistor with a gain of 100 can give upto 1A current at its output. Another purpose of using a transistor in between arduino pin and buzzer is isolation.
A short circuit of the buzzer will destroy only the collector – emitter junction of transistor. Since their is isolation at the base region of transistor (base is connected to arduino), the destruction of collector-emitter junction will not affect base and hence our arduino will be safe from getting burned!
The 100 ohms resistor at base is used to limit base current of transistor. Switch – a push button switch is used to reset the burglar alarm once its activated. The capacitor is used for bypassing bouncing effects of a switch ( debouncing capacitor).
Connections Details
S NO | ARDUINO PIN | PIR , GSM BUZZER |
1 | 8 | BUZZER |
2 | 7 | PIR |
3 | 9 (Rx) | GSM (Tx) |
4 | 10 (Tx) | GSM (Rx) |
GSM based Arduino Intruder Alarm – Circuit Diagram
Applications of Burglar Alarm
1. Detect a motion – an intruder or a burglar using PIR sensor
2. Activate the buzzer alarm upon detection of burglar/intruder – Alarm should sound until Reset switch is pressed
3. Send 3 SMS to a predefined mobile number set inside the program.
4. Stop the alarm when reset switch is pressed. Also reactivate the SMS alert facility upon reset.
Complete Arduino Program
#include<SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
int sensor=7; //PIR sensor
int push_switch=6; // push button switch
int buzzer=8; // buzzer
int sensor_value; //Read sensor
int sms_count=0;
void setup()
{
pinMode(sensor,INPUT);
pinMode(push_switch,INPUT);
pinMode(buzzer,OUTPUT);
mySerial.begin(9600);
}
void loop()
{
Check_Burglar();
Check_Reset();
}
void Check_Burglar()
{
sensor_value=digitalRead(sensor);
if(sensor_value==HIGH)
{
digitalWrite(buzzer,HIGH);
while(sms_count<3)
{
SendTextMessage();
}
}
}
void Check_Reset()
{
if(digitalRead(push_switch==HIGH))
{
digitalWrite(buzzer,LOW);
sms_count=0;
}
}
void SendTextMessage()
{
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS=\"+919524802005\"\r"); // Replace your Cell number
delay(1000);
mySerial.println("A Person Entered");
delay(200);
mySerial.println((char)26);
delay(1000);
sms_count++;
}