Arduino Projects

Arduino Laser-Based Intrusion Detection System: Anti-Burglar with GSM Control

In today’s world, security has become a paramount concern for homeowners. With the rise in home automation technologies, protecting your home has never been easier or more innovative. Imagine having a security system so sophisticated that it uses lasers to detect intruders, yet so simple that you can build it yourself using an Arduino and a GSM module. Sounds like something out of a spy movie, right? Well, it’s not. In this guide, we’ll walk you through how to build a laser-powered anti-burglar system that leverages the power of Arduino and GSM technology to keep your home safe. Whether you’re a seasoned DIY enthusiast or a beginner looking to dabble in home automation, this project is perfect for you. Let’s dive in!

What is a Motion Sensor Based, Laser-Powered Anti-Burglar System?

Anti-burglar detection system

At its core, a laser-powered anti-burglar system is a security setup that uses laser beams to create an invisible fence around your home. The idea is simple: laser lights travel in a straight line, and when this line is interrupted—say, by a person or object—the system detects the break and triggers an alarm. The beauty of this system lies in its simplicity and effectiveness.

It is upgraded up a notched when a motion sensor module, PIR sensors are added to detect human proximity at hours when there supposed to be no one around the vicinity. By integrating it with an Arduino board and a GSM module, we took this project to the next level by enabling remote monitoring and control through the use of calls and SMS commands to activate and deactivate it.

Read Bimodal Biometric-based Surveillance System

Components You’ll Need

Before we get into the nitty-gritty of building the system, let’s talk about the components we used for the project design:

  • Arduino Standalone Uno Board: The brain of the operation, responsible for processing data from the sensors and controlling the system.
  • Laser Torches: These create the laser beams that will act as tripwires.
  • Light Dependent Resistors (LDRs): These sensors detect the presence or absence of laser light.
  • SIM800L GSM Module: This module allows the system to send and receive SMS messages for arming, disarming, and alerting the user.
  • Single Channel Relay Module: Used to control the laser torches and other components.
  • Power Supply: We used a 5V power supply module to power the Arduino and all connected components and modules.
  • Wires and Connectors: For connecting everything together.
  • Resistors: To stabilize and manage current in the circuit.
  • PIR Sensor Module: this module is to detect motion of an intruder even when he or she evades the tripwire systems

How Does the Laser-Powered Anti-Burglar System Work?

The concept is straightforward. The laser torches are positioned to shine directly onto LDRs, creating an invisible barrier around the perimeter of your model home. As long as the laser light is uninterrupted, the LDRs will register a high level of brightness, and the Arduino will record this as a safe state. However, if someone or something blocks any of the laser beams, the LDRs will detect a drop in brightness, signaling the Arduino that the system has been tripped.

The house model for the project design

Also, if the burglar was able to maneuver the tripwire and didn’t interrupt any of the laser torch on each sides, the PIR motion sensor would be trigger of such motion when this happens. This is where the GSM module comes into play. Once the system detects a breach, the Arduino sends a signal to the GSM module, which then sends an SMS alert to the designated phone numbers, informing them of the intrusion. Also an alarm goes off that deters the burglary act further. Additionally, the system can be armed or disarmed remotely via SMS or phone call, making it incredibly versatile and user-friendly.

Step-by-Step Guide to Building the System

How the anti-burglar system works

Now that you understand the basic concept, let’s break down the steps to build this laser-powered anti-burglar system.

The Schematic Diagram of the Laser-Powered Anti-Burglar Detection System Design

schematic diagram of the Laser-Powered Anti-Burglar System

The schematic diagram is shown above, you can view the bread board version below.

Step 1: Setting Up the Arduino and GSM Module

Schematic diagram of the Anti-burglary system design

We began by setting up our Arduino Uno standalone board. We connected the SIM800L GSM module to the Arduino standalone board using the software serial communication. The GSM module will be responsible for sending and receiving both call and SMS commands. We made sure to insert a SIM card into the module and connect it to the Arduino using jumper wires.

Read also The Women’s Suffrage Movement.

  • VCC to 5V (Arduino)
  • GND to GND (Arduino)
  • TX to Pin D11 (Arduino Rx)
  • RX to Pin D12 (Arduino Tx)

This setup allows the Arduino to communicate with the GSM module, enabling remote control capabilities.

Step 2: Configuring the Laser and LDR Sensors

The Four LDR sensors and four lasers used for the tripwire system

Next, we positioned the laser torches and LDRs around our model home. The lasers should be set up so that their beams shine directly onto the LDRs. Each LDR will need to be connected to the Arduino to monitor the light intensity on the Light dependent resistors (LDRs).

  • We connected the LDRs to the analog pins (A0, A1, A2, A3 and A4) on the Arduino standalone board.
  • On the other end of the LDR was connected to a resistor of 10k ohms and then to GND.

This configuration ensures that the LDRs are correctly positioned to detect any interruption in the laser beams.

Step 3: Calibrating for Day and Night Conditions

One of the unique features of this system is its ability to work both during the day and at night. To achieve this, we needed to calibrate the LDRs for different light conditions. During the day, ambient light might affect the LDR readings, so we used an additional LDR to monitor the overall light level.

  • We placed the ambient light LDR in an area that receives consistent daylight. That is at the rooftop of the home model.
  • We used this reading from this LDR to adjust the sensitivity of the corner LDRs.

This ensures that the system remains effective regardless of the time of day.

Image on WordPress Post Not Showing on Frontend – Image Error Solved

Writing the Arduino Code

The heart of this project is the Arduino code, which ties all the components together. The code will:

  • Monitor the LDRs for changes in light intensity.
  • Trigger the alarm and send an SMS alert via the GSM module if an interruption is detected.
  • Trigger the alarm and send SMS alert via the GSM module if the motion sensors are activated.
  • Allow remote arming and disarming of the system via SMS and phone call.
#include <SoftwareSerial.h>
#include <EEPROM.h>

// Configure software serial port
SoftwareSerial mySerial(11, 12);

String CellNumtemp, textMessage;
String CellNum;
String admin1 = "+2347062174135";

boolean Armed = EEPROM.read(0);
char checkStatus;  //

int pirPin1 = 5;
int pirPin2 = 6;


int ldrRoofPin = A5;
int ldrFrontPin = A1;
int ldrleftPin = A2;
int ldrRightPin = A3;
int ldrBackPin = A0;

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

int ldrTopSense, ldrBackSense, ldrLeftSense, ldrRightSense, ldrFrontSense;

int pirRead, pir2Read;

// Variables will change:
int ledState = LOW;
unsigned long previousMillis = 0;  // will store last time LED was updated

// constants won't change:
const long interval = 1000;

boolean night, day;

String number = "+2348114180467";  //-> change with your number
String showMessage;
char mode = 'r';

String message1 = "Command Received. System Armed";
String message2 = "Command Received. System Disarmed";
String message3 = "Command Received, System is ";
String message4 = "Alert!!, Alert!!! System is Breached! ";
String message5 = "Alert!!, Alert!!! System Motion is triggered! ";
String message6 = "I am sorry but you don't have admin power hence you can't make such commands. Thank you. ";

String systemStatus = "";

String nullMessage = "is UNSUCCESSFUL";

void setup() {
  //tell MCU ur outputs
  pinMode(laserActivePin, OUTPUT);
  pinMode(AlarmPin, OUTPUT);

  //tell MCU ur inputs
  pinMode(pirPin1, INPUT);
  pinMode(pirPin2, INPUT);


  //off Alarm
  digitalWrite(AlarmPin, LOW);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Serial begin ok");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("AT");
  delay(10);

  disarmSensors();
}

int readLdrSensors() {
  ldrTopSense = analogRead(ldrRoofPin);
  ldrLeftSense = analogRead(ldrleftPin);
  ldrRightSense = analogRead(ldrRightPin);
  ldrFrontSense = analogRead(ldrFrontPin);
  ldrBackSense = analogRead(ldrBackPin);

  return ldrLeftSense, ldrRightSense, ldrFrontSense, ldrTopSense, ldrBackSense;
}

bool nightAndDay() {
  readLdrSensors();
  if (ldrTopSense <= 500) {
    day = true;
    night = false;
  } else if (ldrTopSense >= 500) {
    day = false;
    night = true;
  }
  return night, day;
}


bool checkMotion() {
  for (int i = 0; i < 25; i++) {
    int pirRead = digitalRead(pirPin1);
    //Serial.println(pirRead);
    if (pirRead == 1) {
      return true;
    } else {
      return false;
    }
  }
  delay(500);
}


bool checkMotion2() {
  for (int i = 0; i < 25; i++) {
    int pir2Read = digitalRead(pirPin2);
    //Serial.println(pirRead);
    if (pir2Read == 1) {
      return true;
    } else {
      return false;
    }
  }
  delay(500);
}


int armSensors() {
  Serial.println("\nArmed");
  Armed = 1;
  EEPROM.update(0, Armed);
  return Armed;
}

int disarmSensors() {
  Serial.println("\nSensors Disarmed");
  analogWrite(laserActivePin, 0);
  digitalWrite(AlarmPin, LOW);
  Serial.println("LASER OFF");
  Armed = 0;
  EEPROM.update(0, Armed);
  return Armed;
}

char burglarDetect() {
  armSensors();
  readLdrSensors();
  nightAndDay();

  if ((night == true) && (day == false)) {
    analogWrite(laserActivePin, 255);
    digitalWrite(AlarmPin, LOW);
    Serial.println("LASER ON");

    if ((checkMotion2() == true) || (checkMotion() == true) || (ldrBackSense <= 500) || (ldrFrontSense <= 500) || (ldrLeftSense <= 500) || (ldrRightSense <= 500)) {
      digitalWrite(AlarmPin, HIGH);
      checkStatus = 'd';
      Serial.println("Sensors triggered at night!");
    }
  }

  else if ((night == false) && (day == true)) {
    analogWrite(laserActivePin, 0);
    digitalWrite(AlarmPin, LOW);
    Serial.println("LASER OFF");
    digitalWrite(AlarmPin, LOW);
    if ((checkMotion2() == true) || (checkMotion() == true)) {
      digitalWrite(AlarmPin, HIGH);
      checkStatus = 'e';
      Serial.println("Motion Sensors triggered!");
    }
  }

  else {
    Serial.println("Quite as the grave");
  }
 
  Serial.print("pir 1: ");
  Serial.print(checkMotion());
  Serial.print(" Pir 2: ");
  Serial.println(checkMotion2());  //
  Serial.println("Night: " + String(night) + " Day " + String(day));
  Serial.println("Top: " + String(ldrTopSense) + " left: " + String(ldrLeftSense) + " Right: " + String(ldrRightSense) + " Back: " + String(ldrBackSense));
  delay(500);
   return checkStatus;
}

void loop() {
        //burglarDetect();
  unsigned long currentMillis = millis();
   if (currentMillis - previousMillis >= interval) {
         previousMillis = currentMillis;
     if (ledState == LOW) {
       ledState = HIGH;
        checkIncomingSMS();
     }
     else {
       ledState = LOW;
           SendMessage();
     }
   }
}

// check if there are incoming SMS
String checkIncomingSMS() {
  // AT command to set mySerial to SMS mode
  mySerial.print("AT+CMGF=1\r");
  delay(100);
  // Read the first SMS saved in the sim
  mySerial.print("AT+CMGR=1\r");
  delay(10);
  // Set module to send SMS data to serial out upon receipt
  mySerial.print("AT+CNMI=2,2,0,0,0\r");
  delay(100);
  if (mySerial.available() > 0) {
    textMessage = mySerial.readString();
    //save the phone number of the senders in a string (country code)
    CellNumtemp = textMessage.substring(textMessage.indexOf("+234"));
    CellNum = CellNumtemp.substring(0, 14);
    Serial.print(" phone ");
    Serial.print(CellNum);
    Serial.print(" ");
    Serial.println(textMessage);
    delay(10);
        if(CellNum == admin1){
    if (textMessage.indexOf("Arm") >= 0) {
      burglarDetect();
      checkStatus = 'a';
    }

    if (textMessage.indexOf("Disarm") >= 0) {
      disarmSensors();
      checkStatus = 'b';
    }

    if (textMessage.indexOf("Status") >= 0) {
      checkStatus = 'c';
    }
  }
        else if(CellNum != admin1){
          if ((textMessage.indexOf("Status") >= 0) || (textMessage.indexOf("Disarm") >= 0) || (textMessage.indexOf("Arm") >= 0)){
          checkStatus = 'f';
        }
        }
  }
  CellNumtemp = "";
  textMessage = "";
  mySerial.print("AT+CMGD=1\r");
  mySerial.print("AT+CMGD=2\r");
  return CellNum;
}


void dummy() {
  mySerial.println("AT+CMGF=1");  //Sets the GSM Module in Text Mode
  delay(200);
  mySerial.println("AT+CMGS=\"" + CellNum + "\"\r");  //Mobile phone number to send message
  delay(200);
}

void SendMessage() {
  Serial.print("Got phone: ");
  Serial.println(CellNum);
  Serial.println(" Arm State: " + String(Armed));
  if (Armed == 1) {
    systemStatus = "ACTIVE";
    burglarDetect();
  } 
  else if (Armed == 0) {
    systemStatus = "OFF";
  }
  switch (checkStatus) {
    case 'a':
      dummy();
      mySerial.println("Hello," + message1);
      break;
    case 'b':
      dummy();
      mySerial.println("Hello," + message2);
      break;
    case 'c':
      dummy();
      mySerial.println("Hello," + message3 + systemStatus);
      break;
    case 'd':
      dummy();
      mySerial.println("Alert!," + message4);
      break;
    case 'e':
      dummy();
      mySerial.println("Alert!," + message5);
      break;
    case 'f':
      mySerial.println("Hello," + message6);
      break;
  }
  updateSerial();
  delay(100);
  mySerial.println((char)26);  // ASCII code of CTRL+Z
  delay(200);
  checkStatus = 'z';
}

void updateSerial() {
  delay(5);
  while (Serial.available()) {
    mySerial.write(Serial.read());  //Forward what Serial received to Software Serial Port
  }
  while (mySerial.available()) {
    Serial.write(mySerial.read());  //Forward what Software Serial received to Serial Port
  }
}

Read also Flirt Like a Pro: Mastering the Art of Body Language

Explanation of the Arduino Code (SMS Command only)

This Arduino code is designed for a laser-powered anti-burglar system that utilizes various sensors, such as PIR (Passive Infrared) sensors and LDRs (Light Dependent Resistors), to detect motion and light levels. The system includes GSM functionality for remote control and alerts via SMS. The code starts by configuring the necessary pins for inputs and outputs, initializes serial communication, and reads stored settings from EEPROM to determine whether the system is armed or disarmed upon startup.

In the setup function, the system initializes the serial ports, sets pin modes for the sensors and outputs, and disarms the sensors by default. The loop function periodically checks for incoming SMS messages and determines whether to arm, disarm, or check the status of the system based on commands sent via SMS. The code includes functions to handle the reading of light and motion sensors, enabling the system to differentiate between day and night, and activate or deactivate the laser and alarm accordingly.

When the system is armed, the burglarDetect function continuously monitors the sensors. If it detects motion or a significant change in light levels, it triggers the alarm and sends an alert message. The system’s response varies based on whether it is day or night, using different sensors to determine if a breach has occurred. SMS commands are processed in the checkIncomingSMS function, which verifies the sender’s number and executes the corresponding action, either arming, disarming, or reporting the system’s status.

Finally, the SendMessage function sends SMS responses based on the current status of the system and any detected breaches. The code includes safeguards to prevent unauthorized users from controlling the system, ensuring that only predefined admin numbers can arm or disarm the system. The use of EEPROM ensures that the system remembers its armed state even after a power cycle. Overall, the code provides a robust framework for a remote-controlled, sensor-based security system.

Testing the System

Before we finalized our setup, we began to test the system to ensure everything works as expected. We simulated an intrusion by interrupting one of the laser beams and observe whether the LDRs detect the change and trigger the alarm. Also, by triggering the motion sensors too placed at the various blind spot positions. This evidently worked as we programmed it as shown in the YouTube video above. We equally tested the SMS functionality by arming and disarming the system remotely.

See also 5 Weird Facts About the World’s Smallest Organism: Tardigrades

Fine-Tuning and Adjustments

To get the code for both the SMS and Call commands, you can send us a message here on WhatsApp. We will be delighted to forward it to you. Alternatively, you can head over to the GitHub repo to download a free version of it. However, talk with us can enhance your chances of using the project and perhaps getting some of your questions answered.

Once the basic setup is working, you can fine-tune the system. Adjust the threshold values for the LDRs to optimize performance, and ensure the laser beams are accurately aligned with the sensors. You might also consider adding additional features, such as a siren or integration with other home automation systems.

Advantages of a Laser-Powered Anti-Burglar System

There are several reasons why a laser-powered anti-burglar system is an excellent choice for home security:

  • Precision: Lasers provide a high level of accuracy in detecting intrusions, reducing false alarms.
  • Cost-Effective: The components needed for this system are affordable, making it accessible for DIY enthusiasts.
  • Scalability: You can easily expand the system by adding more laser torches and LDRs to cover a larger area.
  • Remote Monitoring: The integration of a GSM module allows you to monitor and control the system remotely, providing peace of mind when you’re away from home.

Potential Challenges and How to Overcome Them

While the system is effective, there are a few challenges you might encounter:

  • Alignment Issues: Proper alignment of the lasers and LDRs is crucial for the system’s success. Take your time during the setup to ensure everything is perfectly aligned.
  • Interference: Ambient light, especially sunlight, can interfere with the LDR readings. Calibrating the system for day and night conditions can mitigate this issue.
  • Power Supply: Ensure that your power supply is stable and sufficient to run all components, especially if you’re adding more sensors or features.

Expanding the System: What’s Next?

Once you’ve mastered the basic setup, you can explore expanding the system with additional features:

  • Siren Integration: Add a loud siren to deter intruders once the system is tripped.
  • Wireless Communication: Incorporate wireless communication modules like Bluetooth or Wi-Fi to extend the system’s capabilities.
  • Camera Integration: Pair the system with a camera module to capture images or videos of the intrusion for evidence.

Conclusion

Building a laser-powered anti-burglar system with Arduino and GSM control is not just a fun and educational project—it’s a practical solution for home security. By following the steps outlined in this guide, you can create a robust security system that’s both cost-effective and easy to manage. Whether you’re looking to secure your home, a model house, or just want to experiment with Arduino projects, this system offers a versatile and scalable solution. So, why wait? Start building your own laser-powered security system today!

Frequently Asked Questions (FAQs)

1. Can I use this system in a real house, or is it just for models? Yes, while this project is designed for a model house, you can scale it up for real-world use by using more powerful lasers and placing the LDRs strategically around your property.

2. What happens if someone tampers with the system? If someone tries to tamper with the system by cutting the power or blocking the lasers, the Arduino can be programmed to send an immediate alert via SMS, allowing you to take action.

3. How reliable is the SMS communication? The reliability of SMS communication depends on the GSM module and the network signal strength in your area. Ensure that your SIM card has sufficient balance and that the GSM module is in a location with good signal reception.

4. Can I add more laser beams to cover a larger area? Absolutely! You can add more laser torches and LDRs to cover additional entry points or a larger perimeter. Just make sure to adjust the Arduino code to accommodate the extra sensors.

5. How do I power the system? The system can be powered using a standard 9V battery or an external power supply. If you’re adding more components, consider using a more robust power source to ensure stability.

smartechlabs

Recent Posts

AI-Powered Soil Analysis for Precision Nutrient Management: Revolutionizing Agriculture

In the ever-evolving landscape of modern agriculture, artificial intelligence (AI) is emerging as a game-changing…

20 hours ago

IoT Applications in Enhancing Manufacturing Flexibility

The Internet of Things (IoT) is reshaping the way we live, work, and produce goods.…

20 hours ago

AI-Driven Process Optimization in Continuous Manufacturing

Introduction Have you ever wondered how some manufacturing industries consistently deliver high-quality products while minimizing…

21 hours ago

Implementing IoT for Real-Time Monitoring of Livestock Feed Intake

In the ever-evolving landscape of modern agriculture, the integration of Internet of Things (IoT) technology…

21 hours ago

Implementing IoT Solutions for Remote Equipment Diagnostics

Introduction Have you ever imagined diagnosing equipment issues without even being on-site? Welcome to the…

21 hours ago

Leveraging AI for Inventory Management in Smart Manufacturing

In the ever-evolving world of manufacturing, staying competitive means adopting innovative solutions to optimize every…

22 hours ago

This website uses cookies.