0

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:

  1. Fixing my python code
  2. Using different GPIO pins
  3. Using the other 5V pin
  4. Changing the delay settings on the PIR
  5. Changing the sensitivity settings PIR
  6. Changing the single trigger mode/repeatable trigger mode on the PIR(I am wanting to use the single trigger mode)
  7. Shorten the 24 AWG jumper cable from 12 inches to ~6 inches
  8. Changing to different house outlet for the power to raspberry pi
  9. Changing the power cord of the raspberry pi
  10. 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):

enter image description here

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.

4

1 Answer 1

0

You need to look at your environment to find the cause of the regular pulse.

I suggest you leave monitor.py running for 5 minutes. Perhaps lots of GPIO are affected.

This requires the pigpio daemon to be running (sudo pigpiod).

I also suggest you run piscope.

.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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