GSM-BASED MOTION DETECTOR WITH DEEP SLEEP

In this tutorial let’s build a gsm-based motion detection device. That is this device will notify you by a call in case of any movement. This is a portable device you can place it in anywhere. It has deep-sleep mode. That means your battery will last for a long time.

CIRCUIT DIAGRAM

CODE

#include <SoftwareSerial.h>
SoftwareSerial GSM(12, 13); // TX AND RX PINS

char phone_no[] = "+91XXXXXXXXX"; // REPLACE THIS NUMBER WITH YOUR NO(FOR ALERT)

void setup()
{
  Serial.begin(9600);
  GSM.begin(9600);
  Serial.println("Initializing....");
  initModule("AT", "OK", 1000);
}

void loop()

  {
    callUp(phone_no);
    delay (2000);
   ESP.deepSleep(0);
  }



void callUp(char *number) {
  GSM.print("ATD + "); GSM.print(number); GSM.println(";"); //THIS AT COMAND IS FOR MAKING CALLS
  delay(20000);
  GSM.println("ATH"); //TO CUT CALL
  delay(100);
 
}


void initModule(String cmd, char *res, int t) {
  while (1) {
    Serial.println(cmd);
    GSM.println(cmd);
    delay(100);
    while (GSM.available() > 0) {
      if (GSM.find(res)) {
        Serial.println(res);
        delay(t);
        return;
      } else {
        Serial.println("Error");
      }
    }
    delay(t);
  }
}

Comments (2)

  1. I want to buy this motion sensor call alert
    7008503080

  2. Sir, how can i connect it to the battery?

Leave a comment