edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
Daini
Published © CC BY-SA

Home Security System using GSM

Home Security System Using Arduino, Pir Sensor And GSM Sim900A

BeginnerFull instructions provided1 hour29,951
Home Security System using GSM

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Arduino GSM shield
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic For this project

Code

Programming

Arduino
#include <SoftwareSerial.h>
SoftwareSerial SIM900(2, 3);
String textForSMS;

int pirsensor = 10;
int buzzer = 9;
int red = 7;
int green = 8;

void setup() {
  randomSeed(analogRead(0));
  Serial.begin(9600);
  SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
  Serial.println(" logging time completed!");
  pinMode(pirsensor, INPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  digitalWrite(buzzer, LOW);
  digitalWrite(red, LOW);
  digitalWrite(green, LOW);

  delay(100);

}

void loop() {


  if ( digitalRead(pirsensor) == HIGH) //
  {
    textForSMS =  "\Any Person in your Room  Plz Check It ";

    digitalWrite(buzzer, HIGH);
    digitalWrite(red, HIGH);
    digitalWrite(green, LOW);
    sendSMS(textForSMS);
    Serial.println(textForSMS);
    Serial.println("message sent.");
    delay(8000);
  }
  if ( digitalRead(pirsensor) == LOW) //
  {
    digitalWrite(buzzer, LOW);
    digitalWrite(red, LOW);
    digitalWrite(green, HIGH);
    delay(1000);
  }

}


void sendSMS(String message)
{
  SIM900.print("AT+CMGF=1\r");                     // AT command to send SMS message
  delay(1000);
  SIM900.println("AT + CMGS = \"+918830584864\"");  // recipient's mobile number, in international format

  delay(1000);
  SIM900.println(message);                         // message to send

  SIM900.println((char)26);                        // End AT command with a ^Z, ASCII code 26
  delay(1000);
  SIM900.println();
  // give module time to send SMS

}

Credits

Daini
31 projects • 17 followers

Comments