Posts: 12
Joined: Sat Jan 03, 2015 7:50 pm

strange behavior of MotionSensor

Wed Jan 24, 2018 8:08 am

in the following code - as testcode in a larger code for using a raspberry pi 3 with a PIR and NoIR camera as home surveillance -
the function

Code: Select all

gets executed spontaneously, first between 60 and 105 seconds after initiating the script and then
also spontaneously every 120 seconds mixed with function executions by a regular PIR response
Very, very strange ???? (for somes reasons there are no indentations stored in the previewversion)

from gpiozero import MotionSensor
from signal import pause
import sys, time, smtplib
pir = MotionSensor(11)

count = 0
def on_motion():
global count
count += 1
t = time.strftime('%Y_%m_%d-%H:%M:%S')

print('PIR 3 zum', count,'. Mal aktiviert am:', t)
if count%3 == 0:
print('180 sec Pause')
elif count > 6:
count = 0
pir.when_motion = on_motion
except KeyboardInterrupt:

Posts: 4807
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: strange behavior of MotionSensor

Wed Jan 24, 2018 11:17 am

It has been posted about a number of times on this forum were by PIR's are affected by the wifi signal of the pi3B's built in wifi.
The 2min cycle of false triggers is the common symptom reported. ... dPimV344vE
Remember we want information no help
The use of crystal balls & mind reading is not supported

Posts: 12
Joined: Sat Jan 03, 2015 7:50 pm

Re: strange behavior of MotionSensor

Thu Jan 25, 2018 2:06 pm

well thank you. In the meantime I found those reports and can confirm that
in removing the W-LAN adapter from the Raspberry by an USB cable - in my
setting approx. 1 meter - that trigger effect is eliminated.

The in other posts mentioned connection length between the Raspberry and the PIR
presumably acting as an antenna has proven unimportant down to 18 cm which is the
length of my connection wires of the shelf.

That means - at least in my case - you cannot use a Raspberry Pi 3 with a built-in
W-LAN adapter for a house surveilance device unless it is possible to
deactivate the built-in W-LAN adapter and use an external one instead which I do not know
how to do it.

The first time I initiated my script I got 2 PIR triggers in short succession and therefore, it is
probably a good idea to put a 100kOhm resistor between output/PIR and ground.

Posts: 3406
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: strange behavior of MotionSensor

Thu Jan 25, 2018 2:24 pm

It may be possible to avoid this sensitivity to Wi-Fi by filtering on the PIR modules or using different modules. Maybe you could use wireless PIRs and a receiver on the Pi. Maybe you can use electrical isolation with an opto isolator on the signal and isolated DC-DC module, separate PSU or even a battery for test purposes.
Ferrites on the cables might help. In-line inductive chokes or screened cable might help. Consider twisted pair cable and differential line driver/receiver.
Dealing with such interference issues can be very complex. I think I'd start by powering the PIR from a battery pack on short wires and with an LED to indicate if it triggers and see if that independent unit is reliable on it's own and with Wi-Fi active nearby. If that works pay attention to the connection to the Pi, supply and signal.

Return to “Python”