Advertisement
gsm security alarm prototype

GSM Home Security Alarm System with Arduino

gsm security alarm prototype

Real Time Home Security System using GSM Technology-An Anti-theft System!

This project deals with the design & development of a theft control system for home, which is being used to prevent/control any theft attempt. The developed system makes use of an embedded system (comprises an open hardware microcontroller and a gsm modem) based on Global System for Mobile communication (GSM) technology.

The designed & developed system can be installed in the home. An interfacing intrusion-detector unit is also connected to the microcontroller-based security system.
In case of an intrusion attempt, a warning message is being transmitted by the system (as an sms) to the owner’s mobile phone, or to any pre-configured mobile phone number for further processing.

Block Diagram

Block Diagram

The security system comprises of an Arduino Uno microcontroller and a standard SIM900A based GSM/GPRS modem. The whole system can be powered from any 12VDC/2A power supply unit/battery.

System diagram of the security system is shown here.

arduino gsm security alarm

arduino gsm security alarm

Working of the system is very simple and self-explanatory. When input power is applied to the system, the system goes into standby mode. However, when the terminals of connector J2 is short circuited, the preprogrammed warning message is automatically transmitted to the concerened mobile number. You can connect any intrusion detection unit (such as a light fence or a motion sensor) to the input connector J2. Note that an active-low (L) at pin 1 of connector J2 triggers the security system.

Further, an optional “call – alert” facility is added to the security system, which will initiate a telephone call when push button switch S2 is activated by the user (or by another electronic module). After the “call” key (S2) operation, the call can be aborted by depressing the second push button switch S3 – the “end” key. This option can be used to make a “missed call” alert, incase of an intrusion attempt.

The circuit is highly-flexible so that you can use any SIM900A modem (and ofcourse any Arduino Uno board) of your choice. Carefully read the modem documentation before construction to make the task sweet and simple.

Arduino Sketch:

/*
* Arduino Home Security GSM Alarm
* An Arduino + SIM900A Project
* T.K.Hareendran
* Tested at TechNode PROTOLABZ
* 21 August 2014
* http:// www.electroschematics.com
*/
//Connect the Tx pin of the GSM modem to D3
//Connect the Rx pin of the GSM modem to D4
//SMS Trigger Key/Input connected to D7 (Active LOW)
//CALL Trigger Key connected to D8 (Active LOW)
//END Key Connected to D9 (Active LOW)
#include <NewSoftSerial.h>
NewSoftSerial mySerial(3,4); // RX and TX pins to communicate with GSM module
#define msg_key 7
#define call_key 8
#define end_key 9
String number ="0000000000"; // Add the 10-Digit Mobile Number to which message / call is to be made,by replacing the 0's
void setup()
{
   Serial.begin(9600);
   mySerial.begin(9600);
   pinMode(msg_key,INPUT);
   pinMode(call_key,INPUT);
   pinMode(end_key,INPUT);
   digitalWrite(msg_key,HIGH);
   digitalWrite(call_key,HIGH);
   digitalWrite(end_key,HIGH);
}
void loop()
{
   //Sends an sms everytime msg_key is pressed
   if (digitalRead(msg_key)==LOW) // Check if the sms key is being pressed
   {
      mySerial.println("AT+CMGF=1"); // Set the Mode as Text Mode
      delay(150);
      mySerial.println("AT+CMGS=\"+00"+number+"\""); // Specify the Destination number in international format by             replacing the 0's
      delay(150);
      mySerial.print("Warning! Intruder Alert!"); // Enter the message 
      delay(150);
      mySerial.write((byte)0x1A); // End of message character 0x1A : Equivalent to Ctrl+z
      delay(50);
      mySerial.println();
   }
   //Makes a call when call_key is pressed
   else if (digitalRead(call_key)==LOW) // Check if the call key is being pressed
   {
      mySerial.println("ATD+91"+number+";"); //Specify the number to call
      while(digitalRead(call_key)==LOW);
      delay(50);
   }
   //Hang the call
   else if (digitalRead(end_key)==LOW) // Check if the hang up key is being pressed
   {
      mySerial.println("ATH");
      while(digitalRead(end_key)==LOW);
      delay(50);
   }
} 

If you are a newcomer in Arduino world, it is recommended to refer related tutorials and projects available elsewhere in this website!

111 Comments

Join the conversation!

Error! Please fill all fields.
  • arya

    SIR,
    Can i use a 12v battery to power the gsm module??

  • Guna Seela Maniam

    Hi,
    Thanks for your reply.
    Yes I’m beginner in this field.

  • Surved

    What is error in program?

    • Surved

      Hello,
      Before replaying I would like – are you beginner in field of programming? If yes need to worried shortly you be master.
      Following are some suggestion by which you can minimize the errors –
      1. I don’t have any knowledge about “SIM900.h” . So you can try remove it and such file is not available in even in arduino IDE.
      2. Same thing is with “sms.h”.
      3. And remaining are syntax error. So go through program once again.

      Try to stick to the above given program and after checking all the working as well as functionality of your system, try to do some changes.

    • Guna Seelan Maniam

      Dear Sir,
      Here I attach the error

  • Guna Seela Maniam

    dear Sir,

    I’ve problem with the below arduino code and need your help to verify and correct the error.

    #include // include the servo files
    #include “SIM900.h” // file for sim900
    #include // library for serial communication
    #include “sms.h” // file for sms function
    #define trigPin 13 // defining the trigger
    #define echoPin 12 // and echo pins
    SMSGSM sms; // creation of sms object
    boolean started= false; // variable for storing the value
    Servo myservo; // create servo object to control a servo
    // a maximum of eight servo objects can be created
    int pos = 0; // variable to store the servo position
    void setup()
    {

    Serial.begin (9600); // baud rate
    pinMode(trigPin, OUTPUT); // initialising trig and echo pins
    pinMode(echoPin, INPUT); // tells us which is i/p and o/p
    myservo.attach(9); // attaches the servo on pin 9 to the servo object
    }
    void loop()
    {
    long duration, distance; // variables to store the time of flight and distance value
    for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 90 degrees
    // in steps of 1 degree
    {
    digitalWrite(trigPin, LOW); // initializing the trigger pins
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH); // same as above
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW); // same as above
    duration = pulseIn(echoPin, HIGH); // when echo pin goes high, time of flight is calculated
    distance = (duration/2) / 29.1; // formula for calculating distance
    if(distance 0) // range of sensor, can be modified till 400 cm
    {

    Serial.println(“GSM Testing to send SMS”); // gsm welcome msg
    if (gsm.begin(9600)) // setting up of gsm baudrate
    {
    Serial.println(“\nstatus=READY”); // status of gsm
    started=true; // if ready make provide a value to the variable
    }
    else
    Serial.println(“\nstatus=IDLE”); // // status of gsm
    if(started)// if the gsm is ready
    {
    if (sms.SendSMS(“+60137601443”, “an un identified object is detected”))// number to
    which you want to send the sms and the sms text//
    {
    Serial.print(distance); // distance is printed on the serial monitor
    Serial.println(” cm”);
    Serial.println(“\nSMS sent OK”); // confirmation msg
    myservo.write(pos); // tell servo to go to position in variable ‘pos’
    delay(15); // waits 15ms for the servo to reach the position
    }

    }
    }
    else
    {
    Serial.println(” no object is detected in the range”);
    myservo.write(pos); // tell servo to go to position in variable ‘pos’
    delay(15); // waits 15ms for the servo to reach the position
    }
    }
    for(pos = 90; pos>=1; pos-=1) // goes from 90 degrees to 0 degrees
    {
    digitalWrite(trigPin, LOW); // initializing the trigger pins
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH); // same as above
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW); // same as above
    duration = pulseIn(echoPin, HIGH);
    distance = (duration/2) / 29.1;
    if(distance 0) // range of sensor, can be modified till 400 cm
    {

    Serial.println(“GSM Testing to send SMS”); // gsm welcome msg
    if (gsm.begin(9600)) // setting up of gsm baudrate
    {
    Serial.println(“\nstatus=READY”); // status of gsm
    started=true; // if ready make provide a value to the variable
    }
    else
    Serial.println(“\nstatus=IDLE”); // // status of gsm
    if(started)// if the gsm is ready
    {
    if (sms.SendSMS(“+60137601443”, “an un identified object is detected”))// number to
    which you want to send the sms and the sms text//
    {
    Serial.print(distance); // distance is printed on the serial monitor
    Serial.println(” cm”);
    Serial.println(“\nSMS sent OK”); // confirmation msg
    myservo.write(pos); // tell servo to go to position in variable ‘pos’
    delay(15); // waits 15ms for the servo to reach the position
    }
    }

    else
    {
    Serial.println(” no object is detected in the range”);
    myservo.write(pos); // tell servo to go to position in variable ‘pos’
    delay(15); // waits 15ms for the servo to reach the position
    }
    }
    }

  • arya

    sir,
    wt about the power requirement of gsm module?can we use a 12v dc supply?

  • Arturs

    Hello, Sir.
    I have following problems with my code:
    Arduino: 1.6.5 (Windows 7), Board: “Arduino/Genuino Uno”

    Arduino_GSM_Modem_Security_System.ino: In function ‘void loop()’:
    Arduino_GSM_Modem_Security_System:29: error: invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’
    Arduino_GSM_Modem_Security_System:40: error: invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’
    invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’

    Please help me 🙂

  • arya

    sir,
    can you specify the name of the sensor we have to use as our intrusion detection unit?? is it a PIR SENSOR? is there any specification for the sensor to be used?

  • arya

    sir,
    wt about the budget of this project???
    we have chosen this as our mini project..
    kindly plz leave a reply soon…

  • Sayooj raj

    Im a plus two science student pls help

  • Sayooj raj

    Hi.
    im sayooj. (student)
    pls help to complete the project
    give yours contact no.

Looking for the latest from TI?