Two PIR motion sensors (HC-SR501) connected to the same input

Hello

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)?

I can not find any similar solution in Google

You can use an OR gate IC.

Two diodes also make for a great OR gate.

wvmarle:
Two diodes also make for a great OR gate.

Oh yes, that should solve the issue for you. Just add a diode to each of the PIR outputs.

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.

Any more idea?

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.

boolean alarmState = false;

if(analogRead(A0) > 100) alarmState = true;
else alarmState = false;

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..

I found the solution.

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.

Thanks for your time.

That's interesting, and not normal for open collector outputs so maybe your PIR have a different output?

1M is really weak for pull-down and may give rise to false triggers due to electrical interference. Better use something like 10k.

wvmarle:
That's interesting, and not normal for open collector outputs so maybe your PIR have a different output?

Interesting...

wvmarle:
1M is really weak for pull-down and may give rise to false triggers due to electrical interference. Better use something like 10k.

I have tried to use 10K, but then the signal drops to 2.16V. I worry that it could be to close to threshold level.

If I use 1M there is 3V when the signal is triggered.

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.

schematic.png

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.

That should do the job indeed.