Help with PIR Motion Sensor

Hi,



I got a Seeduino + buzzer + PIR Motion Sensor. My code is pasted further below.



For some reason, the PIR seems inconsistent in its behavior. I start the system and it sees nothing (which is fine), then I walk up to it and it sometimes detects me, sometimes not. When it DOES detect me, it doesn’t stop even when I move away.



I assume its related to the holding time, but how do I verify? What’s the default holding time (I didn’t solder on a potentiometer or anything).



Code:

const int LED = 13;

const int PIR = A4;

const int BUZZER = A5;



void setup() {

pinMode(LED, OUTPUT);

pinMode(BUZZER, OUTPUT);

pinMode(PIR, INPUT);

Serial.begin(115200);

}



void loop() {

if (digitalRead(PIR)) {

Serial.println(“on…”);

digitalWrite(LED, HIGH);

digitalWrite(BUZZER, HIGH);

} else {

Serial.println(“off…”);

digitalWrite(LED, LOW);

digitalWrite(BUZZER, LOW);

}



delay(200);

}

BTW - I waited several minutes and the PIR sensor still hasn’t gone off after triggering (tried this several times)

Hi litelite,

I tried and succeeded, there are two suggestions:

Firstly, set the holding time longer, for example, 1s. And then put the PIR on you front, the effect will be better.

Yours,

Handson

What holding timer? The delay in the code itself? Or the timer on the PIR itself? If on the PIR itself, how do I change the timer?

Hi there,


  1. please change to delay(200) to delay(1000).
  2. for the PIR hardware, it uses TM2291, Pin3 and Pin4 can define the delay time as well. the delay time is Tx≈40000R1C1.



    here is the TM2291 reference circuit.





    here is the pir sensor circuit. the R6 is not placed(DNP). So only with R14(10K) resistor and 10nf capacitor. base on Tx≈40000R1C1=4s, we can add resistor on R6 place to reduce the resistor. thanks.