top of page

How to make Motion sensor alert



Circuit:

Download Programming:


#include <SoftwareSerial.h>


//Alarm reciever's phone number with country code

const String PHONE = "Enter_Your_Phone";


#define rxPin 2 //GSM Module TX pin to Arduino 2

#define txPin 3 //GSM Module RX pin to Arduino 3

SoftwareSerial sim800(rxPin,txPin);


//the pin that the sensor is atteched to

int sensor = 11;


void setup() {

  pinMode(sensor, INPUT);

  Serial.begin(115200);


  sim800.begin(9600);

  Serial.println("SIM800L software serial initialize");


  sim800.println("AT");

  delay(1000);

}


void loop(){


while(sim800.available()){

  Serial.println(sim800.readString());

}

while(Serial.available()) {

  sim800.println(Serial.readString());

}

  int val = digitalRead(sensor);

  if (val == HIGH) {

    //state = HIGH;

    Serial.println("Motion detected!");

    Serial.println("calling....");

    delay(1000);

    sim800.println("ATD"+PHONE+";");

    delay(20000); //20 sec delay

  }

}




Demo Video:


100 views0 comments

Recent Posts

See All

Comments


bottom of page