Arduino based security alarm system with PIR sensor and SIM900 GSM shield.

Motion sensors are devices that can detect when something is moving in front of them. The most common type of motion sensor is the passive infrared (PIR) sensor, which can be used to detect the presence of people, animals, or other objects that emit heat. PIR sensors are often used in security systems.

Overview


A motion sensor is a device that can detect the presence of an object in its field of view and trigger an event accordingly. There are several different types of motion sensors, each with their own strengths and weaknesses. PIR sensors are often used in security systems, as they can be used to set off an alarm when someone enters a room and that's exactly what we'll do in this tutorial.


The security system that we will be doing in this tutorial is a complete wireless security solution that includes a PIR sensor and siren. The system is easy to install and can be used in both residential and commercial applications. The PIR sensor detects motion and sends an alert through a text message thanks to the SIM900 GSM module to your mobile phone wherever you are with an in-place alert, you can also set it to send a message directly to the city police!


Getting the items


For this project you will need the following components: 

Sale Off
Voltaat Arduino Uno R3 (Voltaat Version)
45 QAR
Sale Off
Voltaat Active Buzzer - 5V
2 QAR
Sale Off
Voltaat SIM900 GSM Shield for Arduino
79 QAR
Sale Off
Voltaat PIR Motion Sensor
17 QAR

Make sure you also have a breadboard and jumper wires to connect everything together

Sale Off
Voltaat Full-size Breadboard
20 QAR
Sale Off
Voltaat Jumper Wires - Male to Male (40 Pack)
10 QAR

Wiring it up


Before you begin to connect the SIM900 GSM shield to your Arduino, you must first familiarize yourself with it and configure it so that it works for you correctly. The following image shows the most important components of the SIM900 GSM shield. This will help you to understand the tutorial by getting to know its components better.


On the serial port select, make sure the jumper cap is connected as indicated in the image.

A 5V 2A DC adaptor will also be required to deliver power to the shield through the dc jack. You must thoroughly examine the adaptor's specifications.


When you use the adaptor, you must turn on the power supply selection button, and to turn it on, then you must press the power key, exactly like when you start up your computer.


Also, before attaching the shield to the Arduino, place the SIM card into the SIM card slot at the bottom of the shield and turn off the PIN lock.


To obtain the correct readings from the sensor and control the SIM900 GSM module to send the SMS alert, follow the instructions below as well as the image that demonstrates how to connect the sensor to the Arduino.



Connections from the Arduino to the breadboard:

• Arduino pin GND → Breadboard ground line

• Arduino pin 5V → Breadboard 5V line


Connections from the sim900 GSM module:

• GND pin→ Breadboard ground line

• TXD pin → Arduino pin 7

• RXD pin → Arduino pin 8


Connections from the PIR sensor:

• positive pin→ Breadboard 5V line

• Signal pin → Arduino pin 2

• Negative pin → Breadboard ground line


Connections from the buzzer:

• Negative pin→ Breadboard ground line

• Positive pin→ Arduino pin 11


Connections from the Arduino to the breadboard:

• Arduino pin GND → Breadboard ground line

• Arduino pin 5V → Breadboard 5V line


Connections from the sim900 GSM module:

• GND pin→ Breadboard ground line

• TXD pin → Arduino pin 7

• RXD pin → Arduino pin 8


Connections from the PIR sensor:

• positive pin→ Breadboard 5V line

• Signal pin → Arduino pin 2

• Negative pin → Breadboard ground line


Connections from the buzzer:

• Negative pin→ Breadboard ground line

• Positive pin→ Arduino pin 11


Coding


This code purpose is to get the reading from the PIR sensor through the Arduino digital pin input, and then determine if it is high that means there is some one in your house, then the Arduino will send a message to your phone number you specified at the code using the SIM900 GSM shield and the buzzer will be activated. This way, you will be alerted when someone comes to your home.


In order to set up the communication between the Arduino and the SIM900 GSM module we use SoftwareSerial Library. It allows serial communication on other digital pins of an Arduino board.


Let's look at the code, then you should be able to understand it once you follow the instructions and read the comments.


  1. /*
  2. Sound controlled LED
  3.  
  4. Tutorial link: https://www.voltaat.com/blogs/tutorials/clap-to-light-up
  5.  
  6. This is an Arduino sketch turns on an LED once with clapping
  7.  
  8. Components Needed:
  9. 1. Sound sensor ....x1
  10. 2. LED .............x1
  11.  
  12. Connections:
  13. Sound sensor G → Arduino pin GND
  14. Sound sensor + → Arduino pin 5V
  15. Sound sensor D0 → Arduino pin 2
  16. LED → Arduino pin 3
  17.  
  18. */
  19.  
  20. #define SOUND_PIN 2 // Pin of the sound sensor
  21. #define LED_PIN 3 // Pin of the LED
  22.  
  23. // Keep the status of the led to be changed later
  24. bool led_status =false;
  25.  
  26. // Commands inside void setup run once
  27. void setup(){
  28.  
  29. Serial.begin(9600);// Start the serial monitor
  30. pinMode(SOUND_PIN, INPUT);// Set Pin connected to the sound sensor as an INPUT
  31. pinMode(LED_PIN, OUTPUT);// Set Pin connected to the LED as an OUTPUT
  32.  
  33. }
  34.  
  35. // Commands inside void loop run forever
  36. void loop(){
  37.  
  38. // If sound detected
  39. if(digitalRead(SOUND_PIN)== HIGH){
  40.  
  41. // If the LED was off
  42. if(led_status ==false){
  43.  
  44. digitalWrite(LED_PIN, HIGH);// Turn LED on
  45. led_status =true;// Set the LED status
  46. Serial.println("Turn LED on");
  47.  
  48. }else{// Otherwise, if LED was on
  49.  
  50. digitalWrite(LED_PIN, LOW);// Turn LED off
  51. led_status =false;// Set the LED status
  52. Serial.println("Turn LED off");
  53.  
  54. }
  55.  
  56. }
  57.  
  58. }
  59.  

Testing it out


Now try out the circuit that you have built and try clapping to see if it works! You can adjust who sensitive the microphone should be to your claps buy adjusting the blue potentiometer on the microphone sensor. You can rotate in clockwise or counter clockwise to adjust the sensitive! Try to replace the LED with a relay also, this way you can control your room lights with your claps, making your room a smart room.


Resources 


Arduino Code

LCD Library
DHt11 Library

Fritzing Wiring file

Related Tutorials


How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

Liquid error: Could not find asset snippets/zend_pre_order_theme_snippet.liquid
Liquid error: Could not find asset snippets/uploadkit.liquid