Arduino Based Security System using GSM & PIR Sensor

Nowadays we use the different type of security system in our home to protect from Intruder and thief. There are the different PIR home security system in the market depending on their applications.

The PIR motion sensor based security system is one of them. This motion sensor based security system detects any trespassing that occurs in the range of the motion sensor. Depending on the movement of the object it sends a signal to the arduino board.

This PIR home security system has the capability of sending SMS once any motion or movement is detected. This SMS sending gives the user a great safety feature remotely. It also has one alarm in the system.

Working with PIR motion sensor and arduino is very easy. When it detects some movement, it sends a digital output to arduino and arduino take decisions accordingly like turn ON/OFF the alarm, lights or sending SMS message to the owner of the home.

How to Build Motion Sensor SMS Alert System

For this project you should know:

At the end connect all the modules.

Hardware Required

  • Arduino Uno
  • PIR Motion Sensor
  • GSM Modem
  • Piezo Buzzer
  • NPN Transistor BC548
  • Resistor 1K ohm
  • Breadboard

Pinout and Rating of PIR

Pin Name Function
GND Connects to Ground or Vss
+ Vcc Connects to Vdd (3.3V to 5V) @ ~100uA
OUT Output Connects to an I/O pin set to INPUT mode

Jumper Setting in PIR

Position Mode Description
H Retrigger Output remains HIGH when the sensor is retriggered repeatedly. The output is LOW when idle (not triggered).
L Normal Output goes HIGH then LOW when triggered. Continuous motion results in repeated HIGH/LOW pulses. The output is LOW when idle.

PIR Sensor Calibration

PIR sensor needs some “warm-up” time to function correctly. Because there is some settling time involved in learning its environmental conditions. This time is approx 10-60 seconds. During this time there should be a slow motion in sensors field of view.

PIR Sensor Sensitivity

PIR sensor has a range approx 20feet and depends on environmental conditions. It is designed to adjust in slowly changing conditions this generally happens when day progresses. It responds by giving a high signal on the sudden change in its environment.

PIR Motion Sensor Arduino Connection

Piezo Buzzer Arduino Connection

PIR Motion Sensor GSM Modem Connection with Arduino

In the previous tutorial, we have interfaced PIR motion sensor and piezo buzzer with the arduino. And the interfacing and programming are quite easy to understand.

The good feature of this project is to send SMS with GSM Modem when the PIR sensor detects any movement. The interrupt in this project makes it very reliable in detection of PIR Sensor.

PIR motion sensor is connected with arduino digital pin 2 using the interrupt feature. The piezo buzzer is connected to the arduino digital pin 13 for indication of the alarm. The main feature of this project is to send the SMS to the mobile phone of an owner when it detects any trespassing or movement in the PIR sensor area.

For sending the SMS we have used the SIM300. You can use the SIM900 or equivalent. The important thing is, we should know how to interface gsm module with arduino and send the SMS. The second important part is using interrupt we are reading the motion sensor value. So the question is why to use the interrupt.

What is Interrupt

An interrupt is a great way of serving the input connected to the CPU like arduino. Depending on the importance of the input we use the interrupt. Using interrupt, the CPUs execute its normal program which is less important. And keep an eye on the most important input like fire alarm input, smoke sensor, and burglar alarm. And CPU wants never miss reading this input while executing the other low priority code. By connecting this input to the interrupt pin and programming the CPU for that. If input occurs on the interrupt pin, CPU serve it first by pausing other less important code.

Motion Sensor GSM Modem Arduino Code – Sending SMS

As we have used the interrupt to read the motion sensor input. When arduino receives the signal from the motion sensor. It stops executing the normal code and control goes to the ISR(Interrupt Service Routine). ISR is the location of the code. And after the interrupt, control come here and execute the code available at this location. The different interrupt has its own ISR. Here the function void makeSMS_Alarm()is executed when some movement is detected by the PIR sensor. In this section, arduino sending the SMS to the owner of the home and activated the alarm.

/*#####PIR Motion Sensor GSM Home Security System - SMS Alert Arduino Project####
Connection:Buzzer        - Digital Pin 13
Motion Sensor - Digital Pin 02
GSM Modem RX  - Digital Pin 01(TX)
And Connect the supply to above module*/

int pin = 13; //Piezo Buzzer Connected
volatile int state = LOW;

void setup()
{
  pinMode(pin, OUTPUT);     // buzzer as output
  digitalWrite(pin, state); //make buzzer OFF
  //PIR Motion Sensor connected at digital pin 2 i.e. interrupt 0
  attachInterrupt(0, makeSMS_Alarm, RISING);
  Serial.begin(9600);  //set Baud Rate  
}

void loop()
{   

}

void makeSMS_Alarm()
{ 
  // Piezo Buzzer ON
  state = HIGH;
  digitalWrite(pin, state);
  
  //Send SMS
  Serial.print("AT+CMGF=1\r"); 
  //Phone number you want to send the sms
  Serial.print("AT+CMGS=\"+91xxxxxxxxxx"\r"); 
  //Text to send                             
  Serial.print("Intruder Alert - Someone At Home | www.maxphi.com\r");
  //sends ctrl+z, end of message    
  Serial.write(0x1A);                                                          
}

Leave a Reply

Your email address will not be published. Required fields are marked *