Advanced search FAQ Register Login

It is currently Tue Jan 23, 2018 12:34 am

 

Postby tommythecoat » Fri Aug 05, 2016 11:31 am

Hello,

Firstly, I'm new to the Raspberry Pi and programming in general so please forgive any seemingly stupid or simple questions!

Secondly, I have recently purchased a PIR sensor for my Pi as a part of an ongoing project I'm working on. I've managed to get the sensor set up and working but it seems to just constantly detect motion even when there is no motion to be detected.

I've tested it using:

from gpiozero import MotionSensor

pir = MotionSensor(4)
while True:
if pir.motion_detected:
print("Motion detected!")


and when the command is run it just constantly detects motion (about 2000 lines of motion detected in seconds).

I've also set it up to work with the camera module using the following:

from gpiozero import MotionSensor
from picamera import PiCamera

camera = PiCamera()
pir = MotionSensor(4)
while True:
pir.wait_for_motion()
camera.start_preview()
pir.wait_for_no_motion()
camera.stop_preview()


but it starts recording immediately (I'm assuming because it instantly detects motion even though there has been none).

Have I gone wrong somewhere or is my sensor faulty?

Thanks in advance.

tommythecoat
n00b

Posts: 3

Joined: Fri Aug 05, 2016 11:25 am

Postby Dave » Fri Aug 05, 2016 11:48 am

Have you tried adjusting the sensitivity of the sensor?

Check out my post here for a labelled picture - technical-support/infrared-sensor-of-raspberry-pi-workshop-kit-not-working-t312.html?hilit=sensor#p1260

Dave
ModMyPi

User avatar

Posts: 2083

Joined: Wed Jul 22, 2015 11:36 am

Forum Administrator & Technical Support

Postby tommythecoat » Fri Aug 05, 2016 11:53 am

I have tried adjusting both the potentiometers and it hasn't helped.

Thanks for the prompt response

tommythecoat
n00b

Posts: 3

Joined: Fri Aug 05, 2016 11:25 am

Postby Dave » Fri Aug 05, 2016 1:05 pm

Ok, have you read through our motion detection guide? https://www.modmypi.com/blog/raspberry- ... -detection

There's some basic sample code which might be worth a try.

Dave
ModMyPi

User avatar

Posts: 2083

Joined: Wed Jul 22, 2015 11:36 am

Forum Administrator & Technical Support

Postby mnskmobi » Sat Sep 30, 2017 8:39 am

I realise that the OP is from 12 mths ago but in case anyone else comes across this post it is recommended that the PIR be given up to 60 seconds to stabilise when initially given power. This pause is not in the OP's code and may be the cause of the false positive readings.

mnskmobi
n00b

Posts: 1

Joined: Sat Sep 30, 2017 8:32 am

Who is online

Users browsing this forum: No registered users and 1 guest

Board index

The teamDelete all board cookies • All times are UTC [ DST ]