Sim 800L false trigger

In this code i add additional pir sensor after that , when sim800l received sms or call it start to make call without motion.
What is the reason for that


#include <SoftwareSerial.h>

//Alarm reciever's phone number with country code
const String PHONE = "Enter_Your_Phone";

//GSM Module RX pin to Arduino 3
//GSM Module TX pin to Arduino 2
#define rxPin 2
#define txPin 3
SoftwareSerial sim800(rxPin,txPin);

//the pin that the pir sensor is atteched to
int pir_sensor = 11;

int pir_sensor2 = 8;

void setup() {
  pinMode(pir_sensor, INPUT);  
pinMode(pir_sensor2, INPUT);   // initialize sensor as an input
  Serial.begin(115200);          // initialize serial

  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 val2 = digitalRead(pir_sensor);  // read sensor value
  if (val2 == HIGH) {                  // check if the sensor is HIGH
    //state = HIGH;
    Serial.println("Motion detected!");
    Serial.println("calling....");
    delay(1000);
    sim800.println("ATD"+PHONE+";");
    delay(20000); //20 sec delay
  }

int val = digitalRead(pir_sensor);  // read sensor value
  if (val == HIGH) {                  // check if the sensor is HIGH
    //state = HIGH;
    Serial.println("Motion detected!");
    Serial.println("calling....");
    delay(1000);
    sim800.println("ATD"+PHONE+";");
    delay(20000); //20 sec delay
  }

}

Hello

Can you be more specific about what is your problem? The less you are precise and the less you give us the elements to help you
Making REAL sentences is the minimum pls

Can you give us the reference of your PIR sensor? The schema of your arduino and so on

Your PIR has settings for one-trigger (until the object has moved out of range) and re-triggering (as long as the object is in range). You probably have your PIR set to re-trigger.

I moved your topic to an appropriate forum category @Haritha1995.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

1 Like

Actually when sms received to sim 800l module it suddenly show as "motion detect" in serial monitor and make calls. But the sensor is not out any signal i checked it with oscilascope. That happen after adding this part to the code.


}

  int val2 = digitalRead(pir_sensor);  // read sensor value
  if (val2 == HIGH) {                  // check if the sensor is HIGH
    //state = HIGH;
    Serial.println("Motion detected!");
    Serial.println("calling....");
    delay(1000);
    sim800.println("ATD"+PHONE+";");
    delay(20000); //20 sec delay
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.