1

So, this motion sensor works when it is taped to my desktop computer...but when I move it to the wall, specifically a higher spot on the wall, it just keeps giving back an input signal. So here is a script I am using:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
PIR_PIN = 2
GPIO.setup(PIR_PIN, GPIO.IN)
i = 0
try:
        print("PIR Module Test (CTRL+C to exit)")
        time.sleep(2)
        print("Ready")
        while True:
                if GPIO.input(PIR_PIN):
                        i = i + 1
                        time.sleep(1)
                        print(i)

except KeyboardInterrupt:
        print("Quit")
        GPIO.cleanup()

Simple and straight forward.

This is the output

pi@raspberrypi:~ $ python motion.py
PIR Module Test (CTRL+C to exit)
Ready
1
2
3
4
5
6
7
8
9

and so on. So when I move the location of the sensor in a higher spot in the room, the sensor just keeps going off. I'm trying to understand why.

1
  • try to adjust the sensitivity with potentiometer present on the sensor..
    – lex
    Jan 14, 2022 at 3:34

2 Answers 2

0

The code itself is pretty fine. I have just checked, and it looks your issue is very similar the one that described here as the modules are pretty similar. Hence, try to increase your delay before to while loop to 1 min to see if it helps.

For these kind of questions please include a diagram that shows how you connected your sensor module, and a datasheet of the module so we can check specs.

1
  • I followed what the poster did and it didn't help me. It temporarily helps, but not for long. Feb 20, 2021 at 9:26
0

If anyone is having problems with this, it was because the sensor was placed too close to the RPi. I had to extend the wiring and move it a good 5 feet away. This solved the problem, mostly, although it still exhibited odd behavior.

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.