Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
140 min
Share

Making an SMS security system using Arduino

The security system that we will make in this tutorial is a complete wireless security solution that includes a PIR sensor, GSM module and a buzzer. The PIR sensor detects motion and sends an alert through a text message to your mobile phone using the SIM900 GSM module.

Project Video

Overview

In this tutorial, we will use the PIR sensor with Arduino and the SIM900 GSM shield to send a message to your phone that alerts you when someone enters your house!

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
SIM900 GSM Shield for Arduino
Get Item
Passive Buzzer – 5V
Get Item
PIR Motion Sensor
Get Item

Steps

Wiring it Up

Connect the wires between the SIM900 GSM shield and the Arduino and the PIR sensor and the the buzzer as shown in the image below.

 Connections from the Arduino to the breadboard:


    • Arduino GND pin  → Breadboard ground line


    • Arduino 5V pin  → Breadboard 5V line



 Connections from the sim900 GSM module:


    • TWO 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


/*
 Voltaat learn (http://learn.voltaat.com/)
 Link for full tutorial:

 Tutorial: making an SMS security system using Arduino


 The code function is to get the reading from the PIR sensor through
 the Arduino digital pin input and then determine if it is high,
 which means there is someone in your house.

 Connections from the Arduino to the breadboard:
 • Arduino GND pin  → Breadboard ground line
 • Arduino 5V pin  → Breadboard 5V line

 Connections from the sim900 GSM module:
 • TWO 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
*/

//Allows serial communication on other digital pins of an Arduino board
#include "SoftwareSerial.h"

//Configure software serial port with digital pins 7,8
SoftwareSerial SIM900(7, 8);

//Define the variable pirSensor to digital Pin 2
int pirSensor = 2;

//Define the variable pirSensorRead and initialize its value to 0
int pirSensorRead = 0;

//Define the variable buzzer to digital Pin 11
int buzzer = 11;

//Commands inside void setup run once.
void setup() {

 //Arduino communicates with SIM900 GSM shield at a baud rate of 9600 (9600 bits per second)
 SIM900.begin(9600);

 Serial.begin(9600);
 //buzzer is defined as an output
 pinMode(buzzer, OUTPUT);

 //pirSensor is defined as an input
 pinMode(pirSensor, INPUT);

 sendSMS();
}

// Commands inside void loop run forever
void loop()
{
 // Read the value of digital output from rainSensor and assign it in the variable pirSensorRead
 pirSensorRead = digitalRead(pirSensor);


 if (pirSensorRead == HIGH)
 {
   //Generates a square wave of the specified frequency (1000)
   //on a pin (buzzer)for a duration of 200 Millisecond to make a tone
   tone(buzzer, 1000, 2000);
   Serial.println("Security Alarm, There is someone in your house!");
   //Function we made to send the SMS
   sendSMS();
   //Delay for 15 seconds
   delay(15000);
 }

}

void sendSMS()
{
 //Command to set SIM900 GSM to SMS mode
 SIM900.print("AT+CMGF=1\r");
 //Delay for 100 milliseconds
 delay(100);
 //Replace +xxxxxxxxxxxxxx with your phone number in international format
 SIM900.println("AT+CMGS=\"+xxxxxxxxxxxxxx\"");
 delay(100);
 //Send "Security Alarm, There is someone in your house!" message
 SIM900.println("Security Alarm, There is someone in your house!");
 delay(100);
 SIM900.println((char)26);
 delay(100);
 SIM900.println();
 delay(5000);
}

   

Testing it Out

security_system_main

To test the PIR sensor, try to move in front of it, the sensor will be triggered and the buzzer will sound an alert. You will also receive an SMS on your phone number alerting you that there is someone in your house.

Resources

No items found.