So I bought three HC-SR501 PIR and all of them keep trigging (high) every single 60 second on the dot. I don't know what I am doing wrong. The PIR does detect motion when a person is moving but it will also still trigger on the same second, every 60 second. I am using raspberry pi 4 with Raspbian 32 Bullseye OS. The only hardware I am using are the PIR sensor HC-SR501, raspberry pi 4 (with a case), 24 AWG jumper cable (that connects the PIR to the PI), and power to the PI. The things I have tried so far to fix this issue, but with no avail are:
- Fixing my python code
- Using different GPIO pins
- Using the other 5V pin
- Changing the delay settings on the PIR
- Changing the sensitivity settings PIR
- Changing the single trigger mode/repeatable trigger mode on the PIR(I am wanting to use the single trigger mode)
- Shorten the 24 AWG jumper cable from 12 inches to ~6 inches
- Changing to different house outlet for the power to raspberry pi
- Changing the power cord of the raspberry pi
- sudo apt-get update and also upgrade
This is my code:
import RPi.GPIO as GPIO
import time
from datetime import date
PIR = 21
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR, GPIO.IN)
count = 1
try:
while True:
if GPIO.input(PIR) == 1:
today = date.today()
print("Motion Detected event #: ", count)
count = count + 1
print("Today's date: ", today)
timeday = time.strftime("%H:%M:%S")
print("Time: ", timeday)
print("----------------------------------------------")
time.sleep(1)
else:
#print("No motion detected")
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
This is my output being trigger every 60 second without motion at all (note even if there is motion, it'll still trigger every 60 second, in this case the 38th second on the dot):
How do I get this to stop triggering every single 60 second when there is no motion at all. I only want it to trigger when there is motion being detected.
apt-get
- just useapt