Security Based Alarm System With Arduino Mega 2560

Introduction

In this article I will explain about security based Alarm Systems with Arduino Mega 2560. It can be used to identify a person who crossed a line  without permission. It can be used at many places like schools, homes, hospitals, colleges, industries etc.
 
Parts
  • Arduino Mega 2560.
  • PIR Sensor
  • GSM Module
  • Buzzer 
  • LED 
GSM
  • GSM means Global System For Mobile Communication. It is used to send and receive message in critical area.
  • It can also act as GSM modem.
  • It can have a PIN configuration and MIC is also attached.


      Figure 1: GSM Board 
PIR Sensor
  • It is used to detect people moving around approximately 10m from sensor.
  • The actual range is between 5m to 12m.
  • It is of high sensitivity and low noise.

     
            Figure 2 : PIR Sensor
Connection

Step 1 - Arduino Mega 2560 To GSM Board
  • Connect the RX pin of the GSM board to the 04 of Arduino Mega 2560.
  • Connect the TX pin of the GSM board to the 03 of Arduino Mega 2560.
  • Connect the 5V power supply to the Arduino Mega 2560.
  • At last connect the 12 DC voltage to the GSM board. 
Step 2 - Arduino Mega 2560 To PIR Sensor
  • In the PIR sensor they have three pins.
  • The first pin can be connected to dc voltage range as 5v.
  • The second pin can be connected to the Arduino board 5 in digital pin. 
Step 3 - Arduino Mega 2560 To LED
  • The Anode(+) pin can be connected to the digital pin 7 to an Arduino board.
  • The cathode(-) pin can be connected to the Gnd to an Arduino board. 
Step 4 - Arduino mega 2560 To Buzzer
  • The red color wire can be connected to the digital pin 10 to the Arduino board.
  • The black color wire can be connected to the Gnd to the Arduino board.
  • We can connect both the wires in exchange. 
Programming
  1. #include < SoftwareSerial.h >   
  2. #include "Timer.h"  
  3. const int PIR = 5;  
  4. const int TC35TXD0 = 04;  
  5. const int TC35RXD0 = 03;  
  6. SoftwareSerial mySerial = SoftwareSerial(TC35RXD0, TC35TXD0);  
  7. const int siren = 10;  
  8. int count;  
  9. Timer t;  
  10. void setup()   
  11. {  
  12.     pinMode(testswitch, INPUT);  
  13.     pinMode(testled, OUTPUT);  
  14.     pinMode(PIR, INPUT);  
  15.     pinMode(siren, OUTPUT);  
  16.     pinMode(TC35button, OUTPUT);  
  17.     mySerial.begin(9600);  
  18.     digitalWrite(testled, LOW);  
  19.     digitalWrite(siren, LOW);  
  20.     digitalWrite(TC35button, HIGH);  
  21.     count = 0;  
  22. }  
  23. void loop()  
  24. {  
  25.     if (digitalRead(testswitch) == HIGH)   
  26.     {  
  27.         if (digitalRead(PIR) == HIGH)   
  28.         {  
  29.             digitalWrite(testled, HIGH);  
  30.         } else {  
  31.             digitalWrite(testled, LOW);  
  32.         }  
  33.     }  
  34.     if (digitalRead(testswitch) == LOW)  
  35.     {  
  36.         digitalWrite(testled, LOW);  
  37.         delay(15000);  
  38.         digitalWrite(siren, HIGH);  
  39.         delay(500);  
  40.         digitalWrite(siren, LOW);  
  41.         delay(15000);  
  42.         digitalWrite(siren, HIGH);  
  43.         delay(500);  
  44.         digitalWrite(siren, LOW);  
  45.         delay(500);  
  46.         digitalWrite(siren, HIGH);  
  47.         delay(500);  
  48.         digitalWrite(siren, LOW);  
  49.         while (count < 2)   
  50.         {  
  51.             t.update();  
  52.         }  
  53.         digitalWrite(TC35button, LOW);  
  54.         delay(1000);  
  55.         digitalWrite(TC35button, HIGH);  
  56.         delay(20000);  
  57.         mySerial.print("AT+CMGF=1\r");  
  58.         delay(1000);  
  59.         mySerial.print("AT+CMGS=\"+xxxxxxxxxxxx\"\r");  
  60.         delay(1000);  
  61.         mySerial.println("object dected ALERT!");  
  62.         mySerial.print("\r");  
  63.         delay(1000);  
  64.         mySerial.println((char) 26);  
  65.         mySerial.println();  
  66.         delay(5000);  
  67.         digitalWrite(siren, HIGH);  
  68.         delay(20000);  
  69.         digitalWrite(siren, LOW);  
  70.         delay(1800000);  
  71.     }  
  72. }  
  73. void checkPIR()  
  74. {  
  75.     if (digitalRead(PIR) == HIGH)  
  76.     {  
  77.         count = count + 1;  
  78.     }  
  79. }  
  80. void clearPIR()  
  81. {  
  82.     if (count >= 2) {} else  
  83.     {  
  84.         count = 0;  
  85.     }  
  86. }  
Explanation
  • In this article I explained about security of the system.
  • It can work or function in the sensor.
  • The sensor can be used to monitor the object of a person.
  • It can locate the object and sends SMS to mobile. It also raises an alarm.
  • It will function under the GSM Module. 
Output

 
                                  Figure 3: Output

Up Next
    Ebook Download
    View all
    Learn
    View all