tomxi
Posts: 10
Joined: Mon Jun 01, 2015 12:58 pm

weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 1:07 pm

Hi, I have a raspi B and have connected a cheap ebay PIR sensor like the one in this article http://www.raspberrypi-spy.co.uk/2013/0 ... pi-part-1/ and also the raspi camera board.

I use the code in the linked article to detect motion and take a photo, very similar to the code here
viewtopic.php?p=757955#p757955

One problem: the PIR is also triggered when I access the pi over wifi (I have plugged in a small usb wifi module) and do something, like navigate to the folder of camera images. This happens every time. I have tried changing the two hardware knobs on the PIR (sensitivity and time) but the problem is still there. If I increase the time knob much the PIR stops detecting anything. If I decrease it again I'm back with the described problem. Changing the sensitivity knob makes no difference.

I have connected the PIR directly to the raspi (5V, ground, and and GPIO 8). Do I need to put something inbetween? A resistor? If so what value?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 5:32 pm

As I see it there are two possible causes of the issue you are seeing: power blips caused by the wifi dongle drawing down the 5v supply or RF interference from the WIFI affecting the PIR.

To fix the power issue you could try adding a capacitor to the 5v supply to the PIR.

To solve RF interference try a sheet of tinfoil.
Doug.
Building Management Systems Engineer.

tomxi
Posts: 10
Joined: Mon Jun 01, 2015 12:58 pm

Re: weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 6:24 pm

Any rough idea on what capacitator to try that with (don't know the first thing about capacitators I'm afraid)?

You mean tinfoil over the PIR? Like a small... tinfoil hat. I'll give that a try.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 6:58 pm

Yes, a mini tinfoil hat should be an easy proof either way.

I'm not a 100% sure with capacitor values. I'm sure someone else will have a suggestion.
Doug.
Building Management Systems Engineer.

tomxi
Posts: 10
Joined: Mon Jun 01, 2015 12:58 pm

Re: weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 9:46 pm

I tried shielding the PIR with tinfoil but it made no difference. Will try a capacitator, but would need pointers from someone on what to try.

User avatar
jbeale
Posts: 3315
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: weird problem: PIR sensor positive on wifi activity

Mon Jun 01, 2015 10:32 pm

If it's RF getting into the PIR, you can try to separate the two devices more. For example, use a USB extender cable to put the wifi dongle some distance away.
If it's DC power spikes, some capacitor on the +5V line like 10 uF to 100 uF ought to help. Or even better, just for testing, use a completely separate +5V supply to the PIR sensor.

tomxi
Posts: 10
Joined: Mon Jun 01, 2015 12:58 pm

Re: weird problem: PIR sensor positive on wifi activity

Tue Jun 02, 2015 4:11 pm

jbeale wrote:If it's RF getting into the PIR, you can try to separate the two devices more. For example, use a USB extender cable to put the wifi dongle some distance away.
That did the trick it appears! I put an old passive usb hub with a 10 cm long wire between the raspi and the usb wifi adapter and that was enough. I will test drive this more to see if it really solved the issue.

User avatar
jbeale
Posts: 3315
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: weird problem: PIR sensor positive on wifi activity

Tue Jun 02, 2015 4:45 pm

Glad to hear you've got an apparent solution. Note, the passive hub probably has its own capacitors on the +5V power line, so it might be helping with either a DC glitch (added capacitance) or a RF interference problem (added distance). Or both at once.

tomxi
Posts: 10
Joined: Mon Jun 01, 2015 12:58 pm

Re: weird problem: PIR sensor positive on wifi activity

Thu Jun 04, 2015 8:20 pm

I should have written that I also tried using a 1 meter usb extension cable. When I plug the wifi adapter into the extension cable and move the adapter close to the PIR I get the described problem. When I move it away ( ~ 20 cm is enough) the problem goes away. So the cause was likely RF interference.

scai
Posts: 1
Joined: Sun Feb 26, 2017 9:26 am

Re: weird problem: PIR sensor positive on wifi activity

Sun Feb 26, 2017 9:35 am

I have exactly the same problem with a Raspberry PI Model B, an edimax EW-7811UN wifi dongle and an HC-SR501 PIR sensor.

Putting some tinfoil between the Pi and the PIR seems to resolve the issues for me. However I will look for a USB extension cable to be on the safe side.

Thanks for the solution!

User avatar
omegaman477
Posts: 27
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: weird problem: PIR sensor positive on wifi activity

Tue Feb 28, 2017 2:37 pm

Most likely the PIR is tripping due to RF interference. A common problem with the cheap ones. Decouple its PSU.
..the only thing worse than a stupid question is a question not asked.

jkw
Posts: 12
Joined: Thu Oct 02, 2014 5:20 pm

Re: weird problem: PIR sensor positive on wifi activity

Tue Mar 28, 2017 1:53 pm

I had the same problem with a esp8266 and a pir and can confirm that its the wifi signal. I've tried DC decoupling, buffering and scoped the signals and the only thing that helped was physical distance between the wifi module and the pir ..

manunle
Posts: 1
Joined: Mon Aug 14, 2017 12:27 pm

Re: weird problem: PIR sensor positive on wifi activity

Sun Dec 31, 2017 7:48 pm

I have built several camera's using raspberry pi zeros. They consist of a pi zero, a PIR sensor and an adjustable power module set at 5 volts. I run a 24 volt power supply to power all the camera's. I have been trying to fit them in smaller and smaller boxes but I have found that with the smaller ones where the pi is packed close to the PIR sensor, I have this problem. Sometimes the problem won't show up for several days. Sometimes showing up as false positives just when copying video's off of the camera through the wifi. Sometimes as just a false positive every two minutes like clockwork. I have come to the conclusion that all the problems are RF related. Different things seem to solve the problem. One insistence I relocated the pi to the back of the case, as far from the PIR as possible. One i just reoriented the pi by turning it over. Not sure why that fixed it but it has worked ever since. I tried tinfoil on some and it didn't work. The latest one, it did. So far I have five cameras that use PIR sensors. This has happened on three of them. If I build any more, I will build them with this in mind. Keep the pi as far from the sensor as possible and shield the sensor.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 9814
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: weird problem: PIR sensor positive on wifi activity

Sun Dec 31, 2017 9:07 pm

Given that most PIR (passive Infra-Red) devices use an open-collector output, and the only pull-up resistor, the input has to hold the input high when the PIR doesn't pull it low, is probably the very weak software controlled internal pull-up (which is something like 50K) and given the long cables (antenna's) used, it is no wonder the input is so sensitive to radio disturbance.

So to increase its ability to withstand EMC interference from the WiFi signal, you should add a much stronger pull-up to 3.3 Volt, something like 4.7 Kilo-Ohm should work.

tioser
Posts: 2
Joined: Sun Jan 14, 2018 11:12 pm

Re: weird problem: PIR sensor positive on wifi activity

Sun Jan 14, 2018 11:26 pm

I found this thread because I also have the same "false positive" problems with this PIR sensor. In my case, the sensor is triggered by a 3G/GSM module that I use, which must be placed in the same small case with the PIR sensor, for my project to be complete. Imagine how greater the inteference is from 3g modules than wifi ones, since the current draw can spike to 2 Amps when transmitting! I know, the frequency band is different but it still triggers it... I tried everything except the tinfoil solution, but the previous post from mahjongg sounds more elaborate and I really want to try it. My question is, which pull-up resistor you mean??? I found a schematic diagram of the PIR module here (page 2) https://www.mpja.com/download/31227sc.pdf
Would you be kind enough to let us know which one you mean? Or anybody? :)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 9814
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: weird problem: PIR sensor positive on wifi activity

Mon Jan 15, 2018 12:51 am

This particular PIR detector has a 3V3 push-pull compatible logic output, it does NOT have, as most PIR detectors do, have an open collector output, so it does NOT need a pullup resistor.
That said the output is "short circuit" protected with a 1K resistor, so it does not have a very low output impedance.
My proposal would be to use shielded wire, or a twisted wire pair to connect the output and GND wires.
I would also recommend placing a filter cap (100nF between the GPIO input and GND) close to the PI.

tioser
Posts: 2
Joined: Sun Jan 14, 2018 11:12 pm

Re: weird problem: PIR sensor positive on wifi activity

Wed Jan 17, 2018 1:57 pm

Thank you very much mahjongg for sharing this valuable info.
Unfortunately for me, neither shielded nor twisted pair wires worked. I used proper shielded wire from cellular phone antenna, just to be sure. I also had a filter cap in place from the beginning, so this didn't help either. Now the fun part... tinfoil worked! I didn't want to believe that just a piece of tinfoil covering the sensor's pcb and connected to the ground could actually work but there it is. The problem must be in the pcb itself, where the copper from the output must be long enough to form a perfect "receiving" antenna for high frequency transmissions...
When the antenna is a bit further from the PIR sensor, there is no inteference. When I put it in place (where it's supposed to be fitted in the case for my project), unfortunately, there is interference, but not always. And this leads me to my next question...
Do you know a better PIR sensor that can be easily connected to a Pi or arduino and not give us these kind of headaches? I really don't mind the price being higher (of course it will be), I just need a trustworthy PIR sensor (in module form if possible so that can be embedded to anything).
Thanx again and really looking forward to your reply.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 11 guests