6. Building a Motion-Activated SMS and Call Alert System with DVR/NVR using arduino


Introduction :

    In this blog post, we'll walk you through the process of creating a motion-activated alert system using an Arduino and a SIM800L GSM module for CCTV Monitoring. This project allows you to receive SMS alerts and make calls when motion is detected. Whether you want to enhance your home security or monitor a specific area for movement, this DIY project can be a valuable addition to your toolkit.

Prerequisites :

    Before you begin, make sure you have the following components:

        1. DVR/NVR 

        2. Arduino uno board 

        3. SIM800L GSM module with SIM card.

        4. Jumper wires

        5. Power supply (12V 2A 

Setting Up Your Hardware :

    Start by connecting the components as follows:


        1. Connect the SIM800L module to the Arduino using SoftwareSerial. RX (Receive) pin of the module to pin 2 on the Arduino and TX (Transmit) pin to pin 3.
        2. Connect the DVR/NVR Alarm output to pin 4 on the Arduino.
        3. Make sure to provide power to the SIM800L module according to its specifications, and connect the grounds (GND) of all components together.

Motion Alarm setup in DVR / NVR : 

    To enable motion detection alarms on a DVR (Digital Video Recorder) / NVR (Network Video Recorder), you'll need to access the DVR's settings through its web interface or using a connected monitor and mouse. Here are the general steps to enable motion detection alarms on a  DVR:

1. Access the DVR's Interface (Login Page) :

     We can access the DVR's settings either through a web browser or by connecting a monitor and mouse directly to the DVR.

2. Login to the DVR :

     Enter the DVR's IP address in your web browser or use the mouse to navigate through the on-screen menu.
     Log in with your administrator username and password. 

3. Go to the Alarm Configuration :

      Once logged in, find the "Setup" or "Main menu" menu option.

4. Motion Detection Setup :

        In the Main menu, look for a section related to "Alarm" or "Event. Find the "Motion Detection" or "Video Detection" option.

5. Enable Motion Detection :

      Inside the Motion Detection settings, you should see options to enable or disable motion detection. Typically, there's an on/off switch or checkbox.

6. Adjust Sensitivity and Region :

       You can usually adjust the sensitivity of the motion detection to control how sensitive the system is to motion. Higher sensitivity will trigger more alarms for smaller movements.
     You may also have the option to define specific regions of the camera's view where you want motion detection to be active. This can help reduce false alarms.

7. Set Up Alarms :

      In the same Motion Detection settings, you can configure how the DVR responds to motion detection. This may include actions like sending email notifications, triggering alarms, or recording video when motion is detected.

8.  Save and Apply :

        After configuring the settings as desired, make sure to save your changes.

9. Test the Motion Detection :

       To ensure it's working correctly, you can test the motion detection by walking in front of the camera or triggering motion in the defined detection region.

10.  Exit and Reboot (if necessary) :

        Depending on the DVR model and firmware, you might need to exit the settings and reboot the DVR for the changes to take effect.

    Please note that the exact steps and terminology may vary depending on the specific model and firmware version of DVR / NVR. Refer to the user manual or documentation that came with your DVR / NVR for model-specific instructions if needed. Additionally, it's essential to set up motion detection carefully to avoid false alarms and ensure it meets your security needs.

Writing the Arduino Code :

    Now, let's write the Arduino sketch that will control the system. Below is the code:

c++
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);//RX,TX
const int signalpin = 4;
int signalpinState = 0;
int state = 0;

void SendSMS()
{
  Serial.println("Sending SMS...");
  mySerial.print("AT+CMGF=1\r");
  delay(100);
  mySerial.print("AT+CMGS=\"+918825XXXXXX\"\r");
  delay(500);
  mySerial.print("Motion Detected!!!");
  delay(500);
  mySerial.print((char)26);
  delay(500);
  mySerial.println();
  Serial.println("sms send");
  delay(10000);
  mySerial.println("AT");
  mySerial.println("ATD+ +918825XXXXXX;");
  Serial.println("Calling");
  delay(20000);
  mySerial.println("ATH");
  state = 1;
}

void setup()
{
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("Initializing...");
  delay(1000);
  mySerial.println("AT");
  Serial.println("AT");
  mySerial.println("AT+CMGF=1");
  Serial.println("AT+CMGF=1");
  delay(500);

  while (Serial.available()) {
    mySerial.write(Serial.read());
  }
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

void loop()
{
  pinMode(signalpin, INPUT);
  signalpinState = digitalRead(signalpin);
  delay(1000);
  if (signalpinState == HIGH && state == 0) {
    SendSMS();
    delay(60000);
  }
  if (signalpinState == LOW && state == 1) {
    state = 0;
  }
}


Understanding the Code :

    Let's break down the code:

        1. We use the `SoftwareSerial` library to communicate with the SIM800L module, allowing us to use pins 2 and 3 for this purpose. 

        2. The `SendSMS()` function sends SMS alerts and makes a call when motion is detected.

    3. In the `setup()` function, we initialize serial communication and send the initial AT commands to set up the SIM800L module. We also forward data between the Arduino and the module for monitoring.

      4. The `loop()` function continuously monitors the motion sensor. When motion is detected and the system is not in the alert state (`state == 0`), it calls `SendSMS()` to send an SMS and make a call. The system then waits for 60 seconds before checking for motion again.

NOTE :-

    1. Replace the `"AT+CMGS=\"+918825XXXXXX\"\r"` line in the `SendSMS()` function with the recipient's phone number you want to send alerts to.

      2.  Ensure you have a working SIM card inserted into the SIM800L module.

Testing and Deployment :

    Upload the code to your Arduino and test the system. When motion is detected, you should receive an SMS and a call on the specified phone number.

Important links :



Conclusion :

    In this blog post, we've demonstrated how to build a motion-activated alert system using an Arduino and a SIM800L GSM module. This project can be customized and expanded to suit your specific needs, whether it's for home security or other monitoring applications. Experiment with different sensors and notifications to create a comprehensive alert system tailored to your requirements.
Post a Comment (0)
Previous Post Next Post