GSM Alarm System Using Arduino and A PIR Sensor

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

www.electroniclinic.

com
/arduino-gsm-alarm-system/

GSM Alarm System Using Arduino and a PIR Sensor


⋮ 4/28/2019

 Description:

Arduino GSM Alarm System– This project is based on the Security system using PIR Sensor, Arduino
Uno, and GSM module “SIM900A”. The PIR sensor is used for Intruder detection. Whenever an
unauthorized person is detected a message is sent on the desired number. A relay module is also
connected with the Arduino Uno which can be used to turn on an Alarm or it can be used to turn on any
light as an indication that intruder is detected.

As in this project which is based on the GSM Alarm System, the GSM module is used, so with the help
of this project the home or office can be monitored from anywhere around the world. This project “
Arduino GSM alarm system “ can be used throughout the world, so far the GSM network is available.

Amazon Links:
12v Adaptor:

Arduino Uno

Arduino Nano

1/7
Mega 2560:

Mini Pir Sensor:

PIR Sensor:

Sim900A GSM Module:

DC 5V 2A Adaptor

1n4007 diode:

10k Resistor:

2n2222 NPN transistor

12V SPDT Relay:

One-Channel Relay Module:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through
these links. I would appreciate your support in this way!

PIR sensor Module used in the GSM Alarm System:

2/7
PIR SENSOR, PIR stands for the Passive Infrared Sensor, PIR SENSOR is most commonly known as
the motion sensor. PIR “passive infrared sensor” This sensor is designed for humans and animals
detections. The PIR sensor, like the one you can see in the picture above, can be easily used with
Arduino Uno or Mega and other microcontrollers as well.

Pir Sensor Parameters:

1. detection angle of 120 degrees.


2. the detection range of 7 m.
3. Size: 32x24mm
4. 4.TTL switch signal output high signal output (3.3V), a low signal output (0.4V).
5. 5 the trigger time is adjustable 0.3 seconds to 10 mins
6. commonly used in security projects/devices
7. 7 has a reusable trigger.
8. 4.5 to the 20V working voltage

Gsm Sim900A/Sim900D Module:

3/7
This is the GSM module that I will be using in the GSM Alarm System project, in the market we have
different types of GSM modules, the one I will be using today is sim900A, the same code is also tested
on sim900D, so if you want you can also use sim900D.

If you are from Pakistan, Bangladesh or India make sure you purchase the unlocked version of the
sim900A. This GSM sim900A module the one we will be using in this tutorial, as you can see on the
screen has no Onboard voltage regulator, so be careful while applying the voltage. Ideal voltage for this
GSM module is 4.7v but you can also connect it with the 5v adaptor.

As the ideal voltage for this gsm module is 4.7v to 5volts, so any voltage above this can damage the gsm
module. If you don’t have the regulated 5v adaptor then you can also use an lm317t adjustable voltage
regulator. I have a very detailed tutorial on this. Watch the video “Click Here”

As you can see sim900A module have so many pins which are clearly labeled but we will be using only 5
of these pins, the power supply pins, GND, Rxd 5v, and Txd 5v. The GND of the gsm sim900A module

4/7
will be connected with the Arduino GND, Txd of the gsm sim900A will be connected with the Arduino pin7
and finally, the Rxd of the gsm sim900A module will be connected with the  Arduino pin8.

If you want to study more in depth about the GSM SIM900A?

Circuit Diagram of the GSM Alarm System:

The recommended voltage for the GSM sim900A module is 4.7 volts to 5 volts. The TX and RX pins of
the gsm module are connected with the Arduino’s pin number 7 and pin number 8, and the Ground of the
GSM module is connected with the Arduino’s Ground. A relay module is connected with pin number 13 of
the Arduino, while the PIR sensor is connected with pin number 2 of the Arduino. The VCC and GND of
the PIR sensor are connected with the Arduino’s 5 volts and Ground.

Arduino Programming of the GSM Alarm System:


We start by including the softwareserial.h header file. The softwareSerial library is used for creating
multiple serial ports. As I always say never use the Arduino’s default serial port for the debugging
purposes. Now the question is if we use the Arduino’s default serial port for the debugging purposes then
how we will connect the GSM module. well, no worries at all we can create multiple serial ports using the
softwareserial library. I created a serial port on pin number 7 and pin number 8 with the name SIM900.
Pin number 7 is the RX will Pin number 8 is the TX. If you want you can select any other pins. then I
defined three variables of the type String and integer. The variable txtForSMS will be used for storing the
complete message. A PIR sensor is connected with pin number 2 and a relay is connected with pin
number 13.

1 #include <SoftwareSerial.h>
2 SoftwareSerial SIM900(7, 8); // gsm module connected here
3 String textForSMS;

5/7
4  
5 int pirsensor = 2; // pir sensor is connected with pin2 of the arduino
6 int relay = 13; // Alarm/light can be connected with this relay
7  
8 void setup() {
9  
10  
11   randomSeed(analogRead(0));
12   Serial.begin(9600);
13       SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
14 Serial.println(" logging time completed!");
15 pinMode(pirsensor, INPUT);
16 pinMode(relay, OUTPUT);
17 digitalWrite(relay, LOW);
18  
19   delay(5000); // wait for 5 seconds
20  
21   
22 }
23  
24 void loop() {
25  
26   
27      if ( digitalRead(pirsensor) == HIGH) //
28   {
29        textForSMS =  "\nIntruder detected";  
30        digitalWrite(relay, HIGH);
31   sendSMS(textForSMS);
32   Serial.println(textForSMS);
33   Serial.println("message sent.");
34 delay(8000);
35   }
36        if ( digitalRead(pirsensor) == LOW) //
37     {
38   digitalWrite(relay, LOW);
39   delay(1000);
40     }
41   
42 }
43  
44  
45 void sendSMS(String message)
46 {
47   SIM900.print("AT+CMGF=1\r");                     // AT command to send SMS message
48   delay(1000);
49 SIM900.println("AT + CMGS = \"+923339218213\"");  // recipient's mobile number, in
50 international format
51   delay(1000);
52   SIM900.println(message);                         // message to send
53   delay(1000);
54   SIM900.println((char)26);                        // End AT command with a ^Z, ASCII code 26
55   delay(1000);
56   SIM900.println();
57   delay(100);                                     // give module time to send SMS
58 }
59

6/7
Watch Video Tutorial:
Tags
alarm Arduino arduino gsm alarm arduino gsm pir sensor arduino gsm security system arduino pir gsm
alarm project Arduino uno dc electronics gsm gsm alarm system gsm and pir based security system gsm
pir gsm pir arduino pins of pir sensor pir pir gsm pir gsm alarm pir gsm alarm project pir gsm home
security pir gsm office security pir motion sensor arduino pir sensor and gsm based security pir sensor
arduino gsm pir sensor basics pir sensor gsm security pir sensor pinout details pir sensor with gsm
module sensor system top pir sensor tutorial

7/7

You might also like