Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] False alarm in PIR sensor HC-SR501 with Arduino

Status
Not open for further replies.

ravi.2k17

Advanced Member level 4
Joined
Sep 30, 2019
Messages
111
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
874
Hi,

I am using PIR Sensor HC-SR501 with Arduino given in below link. However I get continuously multiple false alarm.
what is the problem here? how can I fix this?


Thanks.
 

The PIR sensors are not really from the best devices. Perhaps you made a mistake in the programming and set the sensor to trigger an alarm at a very small movement. This requires testing. Please check if you have followed the tutorial exactly.
 

The PIR sensors are not really from the best devices.
What do you mean by this? do you want to say that PIR is not a correct choice for anti-theft alarm or motion detection?

Perhaps you made a mistake in the programming
Below is my code which i copied from a the above given link. what seem to be problem here. as per my understating sensitivity depends on only
potentiometer setting of the sensor (not on your code) to which i have configured for minimum sensitivity.


Code:
#define pirPin 2
int calibrationTime = 30;
long unsigned int lowIn;
long unsigned int pause = 5000;
boolean lockLow = true;
boolean takeLowTime;
int PIRValue = 0;

void setup() {
   Serial.begin(9600);
   pinMode(pirPin, INPUT);
}

void loop() {
   PIRSensor();
}

void PIRSensor() {
   if(digitalRead(pirPin) == HIGH) {
      if(lockLow) {
         PIRValue = 1;
         lockLow = false;
         Serial.println("Motion detected.");
         delay(50);
      }
      takeLowTime = true;
   }
   if(digitalRead(pirPin) == LOW) {
      if(takeLowTime){
         lowIn = millis();takeLowTime = false;
      }
      if(!lockLow && millis() - lowIn > pause) {
         PIRValue = 0;
         lockLow = true;
         Serial.println("Motion ended.");
         delay(50);
      }
   }
}
 
Last edited by a moderator:

If I were you, and if I didn't have the resources to analyze the sensor signal (eg oscilloscope), before trying to debounce or filter the sensor signal, I would reflect it to an LED to understand how it behaves in the presence of the object motion. You are using the serial only to send the result of the algorithm, and this does not help to understand its "malfunctioning".
 

If I were you, and if I didn't have the resources to analyze the sensor signal (eg oscilloscope), before trying to debounce or filter the sensor signal, I would reflect it to an LED to understand how it behaves in the presence of the object motion. You are using the serial only to send the result of the algorithm, and this does not help to understand its "malfunctioning".

does it mean I have to remove my arduino and connect PIR sensor with LED and test it's behavior first ? as a beginner i have never used oscilloscope. is it necessary to use here for fault detection?

i have unit tested my pir sensor, just by using battery and led but still i see it is not working as expected. it gives false positive and false negative.
so what are the options i am left with? do i need to replace my existing pir sensor (which means i have to purchase new one) or any other electrical component such as transistor , diode need to be used for this testing? i have tried with potentiometer settings but even failed. below circuit i used for testing.

1599980916659.png
 
Last edited by a moderator:

i have unit tested my pir sensor, just by using battery and led but still i see it is not working as expected. it gives false positive and false negative. so what are the options i am left with?

So, it's clear that before working with the above code you need to setup the mechanical apparatus and adjust its sensitivity accordingly, as you may have already realized, its operation is closely related to positioning, angle and distance from the target, surelly tests on breadboard will not represent the expected behavior perceived in the actual application.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top