2

I have a setup with a Raspberry PI model 3 a PIR sensor and a OEM HDTV Pi IR-Camera with two LED modules (pictures below).

I'm running a little Python script triggering a camera recording whenever the PIR sensor is detecting motion.

Now, the problem is that the sensor is detecting a lot of false positive motions. It seems to just trigger about every 30 seconds. I have tested the setup with two different PIR sensor but the issue remains.

I found out that the sensor seems to work ok as long as the camera is not being connected. Somehow the camera seems to interfere with the PIR sensor.

I'm no electronics expert so I'm kind of stuck and don't know what to do. Any help from you guys is highly appreciated.

Here's my Python script and some pictures of my setup:

from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime

sensor = MotionSensor(4)
camera = PiCamera()

while True:
    sensor.wait_for_motion()
    print("I can see you!")
    filename = "Intruder_{0:%Y-%m-%d_%H:%M:%S}.h264".format(datetime.now())
    camera.start_recording(filename)

    sensor.wait_for_no_motion()
    print("I don't see any motion")
    camera.stop_recording()

GPIO PIR sensor wiring PIR sensor settings Complete setup

4 Answers 4

1

You can reduce the sensitivity of the PIR sensor by turning the little yellow trimpot ("Phillips screw") anti-clockwise. On your photo it is the top one.

This adafruit overview could be helpful.

Make sure that no unwanted infrared transmitter triggers the PIR sensor, like LEDs or (television) remote control unit.

Regarding your python script: I would add camera.close() in a new line after camera.stop_recording(). And KeyboardInterrupt to stop the running script from command line by pressing ctrl+c:

from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime

sensor = MotionSensor(4)
camera = PiCamera()

while True:
    sensor.wait_for_motion()
    print("I can see you!")
    filename = "Intruder_{0:%Y-%m-%d_%H:%M:%S}.h264".format(datetime.now())
    camera.start_recording(filename)

    sensor.wait_for_no_motion()
    print("I don't see any motion")
    camera.stop_recording()
    camera.close()

    except KeyboardInterrupt:
        camera.close()
        exit()
8
  • Unfortunately this didn't resolve the problem. It's still triggering about every minute. Any other ideas?
    – tk78
    Commented Feb 23, 2018 at 10:37
  • "every 30 seconds" and now "every minute" - sounds like the trimpot has an effect. Have you terminated the script, added camera.close(), screw the trimpot a little bit, started the script and then checked the result or without stop/start?
    – Fabian
    Commented Feb 23, 2018 at 16:05
  • You're right. But the interference seems to be the problem. I.e. when the PIR measures it seems to be influence by the camera.
    – tk78
    Commented Feb 24, 2018 at 16:40
  • 1
    @Favian Ok, it was definitely the two IR LEDs screwing with the IR sensor. I removed both LEDs from the camera and voila. Everything working perfectly!
    – tk78
    Commented Feb 25, 2018 at 15:04
  • 1
    FYI: There was still another issue. Either WiFi or Bluetoot causes some fluctuation in power supply. Turned both off and the issue never occured again.
    – tk78
    Commented Mar 21, 2018 at 21:02
1

to help others with the triggerless PIR responses i can tell about my experiences: I have my Pi with PiCamera near the Front door, and outside is my PIR activated light. The Pi runs mjpeg-streamer constantly. When I start the app on my smartphone to view it, the Light switches on. Since I don't have ethernetwires near the front door, I used a Devolo Powerline Adapter set. When I started to send loads of data THAT triggered the PIR sensor. So, maybe you recognize yourself in this setup, or maybe you have another 'old' peace of electronics nearby? maybe the Pi power adapter is noisy? PIR sersors work on fairly low voltage and is (therefore) relatively sensitive for external noise as well.

1

Apparently the problem is noise on the PIR power line triggering the PIR. This can be caused by virtually any other device, even the MCU doing something. I have the same problem caused by the MCU going into sleep mode. Some suggest filters on the power line, some get away with delaying re-arming of the PIR until nothing else is happening which could cause a teeny spike. The latter is working so far for me.

0

I had the same issue and traced it down to electrical interference. I solved it on my three devices by adding a small 3D printed electrical shield over the back of the sensor, covering the child with copper tape and grounding the shield.grounded copper shield

I have the .stl file if anyone is interested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.