4

I have a passive infrared sensor attached to a Raspberry Pi. Namely this model which has digital output in addition to the analog one so it can be attached directly to Raspberry Pi.

The data pin is an open collector which is pulled low when the PIR senses movement.

The problem is that when the CPU load goes high, the data pin also goes low for some reason.

Edit added paragraph:
The sensor is hooked on from the Raspberry 5V rail to VCC, from a GPIO with pull-up enabled to the data pin and from ground to ground. According to the sensor datasheet VCC can be from 3 to 12V, so I chose the 5V over 3.3V because it's directly connected to the power supply.

I have tried the Raspi internal pull-up, as well as an external one, but that doesn't make a difference. I also looked into filtering the signal in software, but the signal during high CPU loads barely looks different from a signal triggered by movement.

Do you think this is due to increased current draw of the Raspi when the CPU load is high (I have a 2A power supply)? If this is the case will using a separate power supply for the PIR make a difference if it is plugged into the same mains power rail as the Raspi? Could putting a capacitor in the VCC line to the sensor make a difference? Or should I use a capacitor to make a low-pass filter on the signal line?

Please excuse my limited knowledge of electronics.

Andy
  • 41
  • 2

2 Answers2

3

Since your PIR sensor is rated for 3 to 12V VCC, it should withstand much larger voltage drops than your RPi would survive: an RPi would certainly reboot when the power supply drops below 3.5V. Since that is not happening, I believe PSU issues can be ruled out.

Considering it's a PIR sensor, one possibility comes to mind. During CPU load peaks, the chip on the RPi board heats up considerably (to 60°C or more) in a matter of seconds. If your board is within the field of view of the sensor, the chip might produce enough IR radiation to confuse it and result in a movement detection. PIR sensors don't track objects, they only observe IR patterns, so a new hot object in their view might as well qualify as a movement.

Putting your RPi in an opaque box should help. For short CPU load spikes, even putting a large enough heatsink on the chip may be enough.

If heat is not the root cause and you're convinced the issue is power-related (can be easily confirmed by using a separate power supply for the sensor), using a decoupling capacitor is a natural starting point. Such a cap should always be placed on the power line. Adding a low-pass filter on the signal line would interfere with normal operation and may even be forbidden by the datasheet, as many devices become unstable if they have to drive a large capacitive load. Another idea is to add a Schottky diode before the cap, so it is not drained by the CPU during load spikes:

schematic

simulate this circuit – Schematic created using CircuitLab

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
  • I think we can rule out the chip's heat as the source for the reasons I explained in my answer below. What it misses is an explanation for why the capacitor solves the problem. I will be glad to grant you the bounty if you can explain this. – Gnurou Mar 03 '17 at 04:22
  • 1
    @Gnurou What you have in your answer is an IR receiver (which senses modulated IR signal from a remote), and the OP claims he has a PIR sensor (which reacts to IR from human body). – Dmitry Grigoryev Mar 03 '17 at 08:32
1

I have the same problem as OP, using a Raspberry Pi model B and a RPM6938 IR sensor. My circuit setup is similar, and I observed the same behavior: as the CPU load goes up, the data pin arbitrarily goes low. This also happens when the CPU is idle, although at a lower rate.

I think we can rule out the chip heat as the source of the interference, since the sensor reacts to IR modulation. And the problem goes away if I use an independent 5V source for the circuit.

I tried placing a capacitor in parallel to the sensor's power and ground lines, and this has fixed the issue - no interference at all no matter the CPU load, the pin only goes down when I point an IR remote at the sensor. I have represented the sensor as a LED in the schematics below:

schematic

simulate this circuit – Schematic created using CircuitLab

My understanding of circuits is too limited for me to explain why this yields the expected behavior, though.

Gnurou
  • 61
  • 5
  • 1
    Bypass caps are known to help with all sorts of power glitches. In your case specifically, the IR receiver shall be powered by at least 4.5V (as opposed to 3V in the original question), while an RPi is known to survive under-voltage down to 4.1V, so it's totally plausible that your cap is filtering out short under-voltage spikes, improving the stability of the receiver. – Dmitry Grigoryev Mar 03 '17 at 08:40
  • Thanks for the details. As this is also a possible solution to OP's problem, can you add this explanation to your answer so I can grant you the bounty? – Gnurou Mar 03 '17 at 08:47