I’m having some false positives on a PIR sensor (HC-SR501), but with a slightly different set up to the previous questions on the topic I have found.
I already had one PIR sensor attached to my raspberry pi and it was working fine. I had some issues with regular false positives, which I put down to the wi-fi or bluetooth. Fortunately, I didn’t need either, so they are disabled.
Having added a second PIR sensor, things seemed to work fine for a while. Checking the logs in the morning, I would have no false positives for the entire night.
However, recently I’ve started getting regular false positives on the newer PIR sensor. The strange thing is that it doesn’t happen to the first one. It also seems a bit weird that I didn’t have problems for a few weeks and then they just started out of the blue.
To be more specific, I get two false positives within the same second, then a third one 17 seconds later. These three false positives repeat every 170 seconds.
I’ve checked the wiring to make sure nothing is loose and I’ve tried changing from GPIO 21 to GPIO 4 in case that made a difference. Again, the wifi and bluetooth are off and the first PIR sensor is unaffected. They are near each other (a foot or two apart) but pointing in different directions. Changing the sensitivity and time delay seems to make no difference. Any ideas what could be causing the issue?
For information, my code for testing:
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
import datetime
GPIO.setmode(GPIO.BCM)
PIR_PIN1 = 7
PIR_PIN2 = 4
GPIO.setup(PIR_PIN1, GPIO.IN)
GPIO.setup(PIR_PIN2, GPIO.IN)
def MOTION(PIR_PIN):
print("Motion detected on gpio {}!".format(str(PIR_PIN)))
print(datetime.datetime.now())
print("PIR Module Test (CTRL+C to exit)")
time.sleep(2)
print("Ready")
try:
GPIO.add_event_detect(PIR_PIN1, GPIO.RISING, callback=MOTION)
GPIO.add_event_detect(PIR_PIN2, GPIO.RISING, callback=MOTION)
while 1:
time.sleep(100)
except KeyboardInterrupt:
print("Quit")
GPIO.cleanup()
Some output:
PIR Module Test (CTRL+C to exit)
Ready
Motion detected on gpio 7! < This is when I'm actually in the room
2020-02-16 09:42:21.120976
Motion detected on gpio 4!
2020-02-16 09:43:42.275443
Motion detected on gpio 4!
2020-02-16 09:43:42.275770
Motion detected on gpio 4!
2020-02-16 09:43:59.228590
Motion detected on gpio 4!
2020-02-16 09:46:49.429935
Motion detected on gpio 4!
2020-02-16 09:46:49.430270
Motion detected on gpio 4!
2020-02-16 09:47:06.401903
UPDATE: Seems the delay can between false positives. I think I must have done this when fiddling with the time delay. It remains consistently two false positives in the same second, followed by another shortly after, with a longer pause before the next set of three.
Categories: Uncategorized
/boot/config.txt
. – joan 52 mins ago