Hi,
This is my first post on this forum. I am trying to set up a PIR sensor (HC-SR501) on a Photon, but in addition to it responding correctly to movement I keep getting false alarms exactly every 2 minutes. I have connected the bottom pin of the group of three pins at the top of the PIR to the photon’s 3.3v and removed the jumper. I have tried powering from a battery pack too, but the false alarms are still there.
I tried connecting a second PIR so that both had to be activated, but this made no difference. Here’s my code:
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
void setup() {
pinMode(D2, INPUT);
pinMode(D3, INPUT);
pinMode(D7, OUTPUT);
}
void loop() {
digitalWrite(D7,LOW);
if (digitalRead(D2) == HIGH && digitalRead(D3) == HIGH) {
digitalWrite(D7,HIGH);
Particle.publish("PIR", "MOVEMENT DETECTED PIR", 60, PRIVATE);
while (digitalRead(D2) == HIGH);
}
}
I would appreciate any input.
Thanks,
Ben