Anti-Theft and Burglar System with SMS Notification

Anti-theft and burglar system

This is a security system design with SMS notification; programmed with Arduino with GSM module SIM800L, having PIR motion sensors and laser trip mechanisms. The Anti-theft and burglar system allows specific users to arm it and disarm it by phone call. During the armed state; the systems motion and laser mechanisms are activated to sense for intruders senses when there is an intruder within the vicinity. When the system is armed and it informed the user via SMS that is is armed and it is alert for any intrusion. The users can also armed or disarm by calling the system design anytime.

In designing this project, the following components were used:

  1. Atmega328P MCU
  2. laser diodes
  3. Light dependent resistors (LDRs)
  4. Passive Infrared Sensors
  5. GSM module, SIM800L
  6. A house model

To design the Atmega328P MCU, we followed the circuit diagram shown below.

Circuit of Anti-Theft Design

Circuit Design Explanation:

As shown in the circuit diagram, the design used two PIR sensors; with these, we sensed motions or movements around a vicinity. Using the PIR in a timed sequence and adding a laser trip wire (using laser diodes and LDRs) would help us since would modelling a house model. Around the windows where burglars have high tendencies of prying the glasses or closures. We added two PIR sensors to window view post. The system would be set to enter “armed state”; which  is the state that the burglar(s) can trip the laser wire that is kept at a respected distance between the window and doors. The tripping would be caused by when the thief breaks the continuous light emitted by the laser onto the surface of the LDR. Then this breaking would make the design to go into the “burglary detect state”. This works a great deal with the PIR and the very close of the stranger to the user’s windows or door. Because in this state, the stranger is almost at the window, and once the PIR detect this illegal motion, it gives off loud vary siren tones by a very loud 12V electronic siren buzzer. And it automatically sends an SMS alert to the user telling him or her that strange movement occurred at his door or window during such time possible while they were not aware or sleeping; maybe perhaps gone out. The siren dies down after a while when it is no longer sensing the movement within its line of sights.

Circuit Diagram Mode of Operation:

The MCU is selected to be 28 pin Atmel Atmega328P. The atmeag328P chip has four (4) pins for power. Pin 7 and pin 20 for Vcc and pin 8 and pin 22 for GND power rails. The hardware reset pin, pin 1 is connected to a 10kΩ precision resistor to keep the pin at 5V HIGH. This pin is an ACTIVE LOW pin. This means the pin would reset the MCU when pulled to the ground (GND) hence the 10kΩ is a pullup resistor. The pin 9 and 10 of the MCU is connected to a 16Mhz crystal oscillator that helps with the pulse clocking and synchronization of internal operations of the MCU. We used the pin 2 and 3 of the MCU for programming it. Since these pins are the UART pins. Also know as the Receiver (Rx) and Transmitter (Tx) pins. This pins would form a crucial part in the FTDI pins connection as we would be using them to communicate between the MCU and the programming PC. 22pF capacitors are connected from pjn 9 and pin10 to GND respectively. This would help in sinking the noise generated by the internal switchings  of the MCU. To ensure that the MCU accepts programs onto its RAM, we soldered two 100nF  ceramic capacitors between pin 20 and pin 22 and then between pin 1 (RST) and CTR pin of the FTDI header pins.

Testing the MCU

To test if the microcontroller is accepting programs burned into it; we plugged the FTDI ISP programmer into the male header pin ISP input. We open the Arduino IDE and uploaded two programs: The Bare Minimum program and the Blink program.

Bare Minimum Sourcecode
void setup() {
void loop() {

Blink Sourcecode:
#define testLedPin 13
void setup() {
pinMode(testLedPin, OUTPUT);

void loop() {
digitalWrite(testLedPin, HIGH);
digitalWrite(testLedPin, LOW);

After uploading this source code to the MCU, the LED connected to pin 19 on the MCU starts blinking. We were so sure that the MCU is working to specification.

We needed a smart display to show the status of the alarm and when it is ‘armed’ and when it is ‘disarmed’. For this function, we used a 16×2 LCD module. The configuration to the MCU is done using 4-bit protocol as shown in the circuit diagram. The Vcc and GND pins of the LCD is connected to 5V and 0V power rails. The Vo is connected to the wiper pin of a 10kΩ potentiometer resistor or a 4.7kΩ connected to Vo then to ground. The register select (RS) pin is connected to pin 13 (PCD08) of the MCU while the enable (E) pin is connected to pin 14 (PCD09). These pins are very important to ensure the LCD screen display the characters that we need it to display. The read/write (R/W) pin of the LCD is grounded. And since we are using a 4-bit communication protocol; we connected four wires from D4 through D7 corresponding to pin 15 through 18 (PCD09 through PCD12) on the MCU. These data pins are very essential and cannot be overlooked when communicating microcontrollers. The LED(+) pin is connected to 5V power rail to ensure backlight brightness comes on when powered on. And finally, the LED(-) pin of the LCD, pin 16 is connected to ground or Vss.

//The following sourcecode is in C/C++ program using Arduino as IDE
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);

The SIM800L GSM was interfaced as shown in the circuit above. But since the MCU uses 5V logic and the Sim800L module uses 3.3V, we needed a voltage shifter. We connected a DC-DC buck converter to the output of the two LiPo batteries that were in series connection(This was later replaced with a 5V power supply module). The SIM800L connection to the MCU was software serial connection, which means that it could be altered in the programming syntax.

The idea was to arm and disarm the system using phone calls. After much tinkering and testing, we were able to send SMS from the GSM module and make it receive calls from authorized callers. Thus using this call times to ‘arm’ or ‘disarm’ the system design.

Finanly, we interfaced the PIR sensors, laser diodes and the LDRs but then we came across a flaw in the design.

Limitations  and modification of the circuit diagram:

The circuit diagram shown above was limited in function because it had only two PIR sensor and two laser diode to cover the front view and the back view of the compound model. This left a lot of blind spots for burglars to access and penetrate the vicinity. Also, we were already knowing the status of the security design with SMS alert that is sent to our phone; so the LCD display was overdoing it. We needed to cover more view points in the compound. However, this meant more sensors and more pin allocations from the MCU to the sensors. We added one more PIR to the design and two more laser diodes and LDR. However, this was at the cost of the LCD module. The new circuit diagram was thus:

final circuit diagram

Further adjustment made was to remove the relay for switch the 12V high pitch siren buzzer and use loud piezo buzzer instead and using transistor as a solid state switch to switch from the microcontroller. This reduced the rate of power consumption of the components and since this was a prototype, it was very ideal not to deafen the observers during display.


The compound model

The design for the Anti-theft burglary detection system was modelled after a bungalow house. The design began with dimensioning and measurement of the house outlook. We envisioned that we needed a compound with four (4) sides. Hence we made a dimension of a wooden rectangular base of length 65cm x 60cm.

The wooden base was cut with a hand saw and it was sand-papered according to ensure smoothness and splinters from entering the hands since hand gloves were not provided in the workshop. After this process, the vertical side braces which would act as the fences were cut out. For the width side of the fences, a pair of soft wood with dimensions: 60cm x 7cm x 2cm. The top of the soft wood is being installed nails and then barb-wired modeling it off from a real fence. Once this was completed; the gating system was also cut of. This has a dimension of 20cm x 2cm.

The front view

A model house s then placed inside this compound where the sensors are attached. The roof of the model house is a transparent plastic glass, which helps to view the circuit design from the top view angle.

The final outlook model
#include <EEPROM.h>
#include <SoftwareSerial.h>
SoftwareSerial cell(11, 12);

const char number1[] = {"09033827773"};
const char number2[] = {"07062174135"};
const char number3[] = {"*********"};

int8_t answer;
char aux_string[30];
char phone_number[15];
char received[15];
int length = 11;
String caller;
int counter = 0;
boolean Armed =;
char status = "ACTIVE";

int pirPin1 = 6; 
int pirPin2 = 9;
int pirPin3 = 10;
int ldrRoofPin = A0;
int ldrFrontPin = A1;
int ldrleftPin = A5;
int ldrRightPin = A3;

// Output Pins
int laserActivePin = A4;
int AlarmPin = 13;

int ldrTopSense, ldrLeftSense, ldrRightSense, ldrFrontSense; 

boolean pir1Sense = true;
boolean pir2Sense = true;
boolean pir3Sense = true;

void setup() {
  //tell MCU ur outputs
  pinMode(laserActivePin, OUTPUT);
    pinMode(AlarmPin, OUTPUT);
  //tell MCU ur inputs
  pinMode(pirPin1, INPUT);
  pinMode(pirPin2, INPUT);
  pinMode(pirPin3, INPUT);

  //off Alarm
  digitalWrite(AlarmPin, LOW);
    //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  //Begin serial communication with Arduino and SIM800L
  while ( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
           sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
  Serial.println("Connected to Mobile Network...");


void loop(){
  pir1Sense = digitalRead(pirPin1);
   pir2Sense = digitalRead(pirPin2);
   pir3Sense = digitalRead(pirPin3);

 ldrTopSense = analogRead(ldrRoofPin);
 ldrLeftSense = analogRead(ldrleftPin);
 ldrRightSense = analogRead(ldrRightPin);
 ldrFrontSense = analogRead(ldrFrontPin);

Serial.print("  ");
Serial.print("  ");

Serial.print("  ");
Serial.print("  ");
Serial.print("  ");

//program is allways waiting for a +CLIP to confirm a call was received
  //it will receive a +CLIP command for every ring the calling phone does
  while (answer = sendATcommand("", "+CLIP", 1000)) {
    //answer is 1 if sendATcommand detects +CLIP
    if (answer == 1)
      Serial.println("Incoming call");
      for (int i = 0; i < 15; i++) {
        //read the incoming byte:
        while (cell.available() == 0)
        { delay (50); }
        //stores phone number
        received[i] =;
      byte j = 0;
      //phone number comes after quotes (") so discard all bytes until find'em
      while (received[j] != '"') j++;
      for (byte i = 0; i < length; i++) {
        phone_number[i] = received[i + j];
    for (int i = 0; i < length; i++) {
      // Print phone number:
      caller += phone_number[i];
    Serial.println("\n>>>" + caller);
    //After 3 RINGs compare the caller ID with the authorized list then take decisions.
    if(counter > 3){
    if(caller != number1 &amp;&amp; caller != number2 &amp;&amp; caller != number3){
      Serial.println("Unknown Caller"); 
      sendATcommand("ATA", "OK", 500);
      Serial.println("I just picked to HangUp"); 
      sendATcommand("ATH", "OK", 500);
    else {
       Serial.println("Authorized Caller");
       sendATcommand("ATH", "OK", 500);
       Serial.print("I Know You MASTER, no need to pick."); 
       Armed = !Armed;
       EEPROM.update(0, Armed); 
       counter = 0;
    Serial.print("Armed ");
     sendSMS("07062174135", "Alarm Armed. \nThank You.");
     sendSMS("09033827773", "Alarm Armed. \nThank You.");
    Serial.print("Not Armed");
    sendSMS("07062174135", "Alarm Disarmed. \nThank You.");
    sendSMS("09033827773", "Alarm Disarmed. \nThank You.");

 if(Armed == 1){
analogWrite(laserActivePin, 225);
digitalWrite(AlarmPin, LOW);
   Serial.println("LASER ON");
            analogWrite(AlarmPin, 255);
            Serial.println("\nALARM now ACTIVE");
            sendSMS("07062174135", "Intrusion Detected At left Window.");
            sendSMS("09033827773", "Intrusion Detected At left Window.");
      analogWrite(AlarmPin, 255);
      Serial.println("\nALARM now ACTIVE");
      sendSMS("07062174135", "Intrusion Detected At Front Entrance.");
      sendSMS("09033827773", "Intrusion Detected At Front Entrance.");
    analogWrite(AlarmPin, 255);
    Serial.println("\nALARM now ACTIVE");
     sendSMS("07062174135", "Intrusion Detected At Right Window.");
     sendSMS("09033827773", "Intrusion Detected At Right Window.");
   //check when it is dark
       if(ldrLeftSense < 950) {
         digitalWrite(AlarmPin, HIGH);
    Serial.println("\nALARM now ACTIVE");
    sendSMS("07062174135", "Laser Tripped At Right Fence Side.");
    sendSMS("09033827773", "Laser Tripped At Right Fence Side.");
  if(ldrRightSense < 950){
      digitalWrite(AlarmPin, HIGH);
    Serial.println("\nALARM now ACTIVE");
     sendSMS("07062174135", "Laser Tripped At Left Fence Side.");
     sendSMS("09033827773", "Laser Tripped At Left Fence Side.");

  if(ldrFrontSense < 950){
   digitalWrite(AlarmPin, HIGH);
    Serial.println("\nALARM now ACTIVE");
     sendSMS("07062174135", "Laser Tripped At Front Fence Side."); 
     sendSMS("09033827773", "Laser Tripped At Front Fence Side.");
     if(Armed == 0){
      Serial.println("\n Not Armed");
analogWrite(laserActivePin, 0);
digitalWrite(AlarmPin, LOW);
   Serial.println("LASER OFF");
caller = "";

 void sendSMS(char receiver[11], char content[140])

void updateSerial()
  while (Serial.available()) 
    cell.write(;//Forward what Serial received to Software Serial Port
 Serial.write(;//Forward what Software Serial received to Serial Port

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {

  uint8_t x = 0,  answer = 0;
  char response[100];
  unsigned long previous;

  memset(response, '\0', 100);    // Initialice the string


  while ( cell.available() > 0);   // Clean the input buffer

  cell.println(ATcommand);    // Send the AT command

  x = 0;
  previous = millis();

  // this loop waits for the answer
  do {
    // if there are data in the UART input buffer, reads it and checks for the asnwer
    if (cell.available() != 0) {
      response[x] =;
      // check if the desired answer is in the response of the module
      if (strstr(response, expected_answer) != NULL)
        answer = 1;
    // Waits for the asnwer with time out
  } while ((answer == 0) &amp;&amp; ((millis() - previous) < timeout));

  return answer;

Leave a Reply

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