Two PIR with relay triggering each other

Hi,

I'm working on a project with a nano, a couple of SR505 PIR sensors, an LDR and a relay to turn on an LED strip on movement. So the Arduino checks the input from either sensor, and activates the relay on movement. The PIRs themselves seems to have about 7 second built-in timer when going from HIGH to LOW, but just as they switch to LOW and turn off the relay, they turn right back on, even when there's no movement. Sometimes it just the one which goes to LOW, but then they "flip" each other, just as the other one goes to LOW, the first one goes back to HIGH, which activates the relay again. If that makes sense?
A snippet of the log:
PIR1: 1 | PIR2: 1 | Relay: ON
PIR1: 0 | PIR2: 1 | Relay: ON
PIR1: 0 | PIR2: 1 | Relay: ON
PIR1: 0 | PIR2: 0 | Relay: OFF
PIR1: 1 | PIR2: 1 | Relay: ON

Diagram is below. The code is pretty simple, just read all input pins, if LDR is LOW, then check either PIR and activate relay if either one is high. And turn off relay one ELSE.

1 Like

I'm guessing the relay may be screwing something up when switching? The whole thing is pretty compact as it will be housed in the same case for outside-use.

what it the relay power supply - just the Arduino USB?
if so the relay switching could be causing power supply problems which upsets the Arduino and/or the PIRs
try an external power supply for the relays?
also what are the relays controlling? iswitching on/off inductive devices such as motors or pumps can cause problems

Yes, the relay is getting 5v power from the Arduino. I'll try to wire it to an external power supply. I'll need one anyways, as I'll have a power bank powering the external LED strip, which is what the relay will be turning on/off.

Wiring the relay to it's own power source did the trick, thanks for the tip!
Next up is connecting the LED strips, and seeing how much power is all eats up. And whether it draws enough to keep the power bank supplying power.

Hm, nope. After letting it sit for a while, the same thing occurred. I tried to put a diode between the relay and power input, to try and prevent the reverse surge, but that didn't do any difference.

I think I'll try to find a SSR instead, as that reportedly should have as much noise or any surges.

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