I need to connect to my Arduino nano two PIR motion sensors.
But I can't connect them to separate pins because I use previous wire setup with only 2 wires.
So, my idea is to connect the parallely with same signal wire, same ground wire and independent VCCs.
I have tried to do that like on the sketch but it works only if two sensor are triggered at the same time like AND function. When one sensor is triggered I measure 1,8V between GROUND and SIGNAL wires. If two sensor are triggered there is 3,5V and then it works.
Anyone have a solution how to connect them with two wires in order to run my action if any of them is triggered or two of them at the same time (like OR)?
wvmarle:
Two diodes also make for a great OR gate.
I have tried this solution with two 1N4007 diodes but it doesn't works. If I have 2 diodes connected to each sensor's only one works. The second one is triggered too but a signal is lost after a diode. If I disconnect the first one, the second works fine.
Switch points of a 5volt Arduino, according to datasheet, are 0.3VCC (1.5volt) and 0.6VCC (3volt).
The 3.3volt output of a PIR sensor is just enough for a reliable HIGH on the pin.
Using a diode 'OR' reduces that PIR output voltage to below that HIGH switchpoint, and things could get unreliable. Schottky diodes might just do it.
A better solution is to join the outputs of the PIR sensors and use an analogue input with a threshold of 100 or so.
Another way is adding an NPN transistor between the PIR sensors and digital input.
Join the PIR outputs, and connect them to the base of a small NPN transistor.
Emitter to ground, collector to a digital input with PULLUP enabled in pinMode.
Reverse logic now. A LOW on the pin is alarm, a HIGH is not.
Leo..
It looks strange for me from the beginning, and I could not explain why it can not work.
The solution was very simple. Pull down resistor instead of Pull up... Funny, but I don't know why I have started with pull-up. I think I have seen example with connected PIR this way.
So, I have just put 1Mohm resistor as a pull-down and disabled internal arduino pull-up.
Now I can multiply PIRs on the same line as many as I want.
Something fishy going on here. All HC-SR501 PIR sensors I know are active HIGH,
are 3.3volt logic, and have a digital output with 1k2 or 1k5 resistor in series.
The things I suggested in post#5 should work.
It's also wise to turn the 'time' pot fully anti-clockwise, and leave the 'sensitivity' pot in the middle.
So release time of the PIR is shortest, and any timing can be done with the Arduino.
Leo..
Maybe you should look into an OR gate IC after all.
Or the transistor circuit as suggested by @Wawa in #5. This also allows you to connect many PIRs to the same pin, when any of them goes high, the signal goes low. As long as your modules have the resistor on the output, no extra external components needed other than these transistors.
To make it more clarify I attached the sketch.
I used 100k resistor, and it works. With this resistor there is 2.85V signal level.
And last thing, actually there are chinese clone of HC-SR501 named RCW-0506. Looks very similar, but there is no jumper for the trigger mode. It always works with continious HIGH signal for delay which is set.
Or, maybe it's not a clone and works different...
What do you thing about the sketch? As I've said: It works!.
It may work, but it's out of spec. A high is guaranteed at 3V, not at 2.85V. You don't need much in the way of disturbance (or a slightly poor contact) to go below the threshold of your particular processor and have it fail, maybe sometimes record the signal and sometimes not.
So be aware that the moment you get such behaviour it's the hardware that needs fixing, not the software.
For any permanent installation you should really consider the transistor or OR gate methods.
Ok, currently I use a BC417 NPN transistor , 2 diode 1N4007 and the external 10k pull-up resistor.
The action is triggered by the LOW state. Then I have got 0,6V at LOW, and 4,2V at HIGH state.
It seems to me there shouldn't be triggering level problem.