Raspberry Pi and hc-sr505 Mini PIR Motion Sensor

The HC-SR505 Mini PIR Motion Sensor is based on infrared technology and it can automatic control by itself with high sensitivity and high reliability. Because of the minimum size and low-power operation mode, it widely used in various of automatic electronic equipment, especially battery-powered automatic products.

It works similar to the larger hc-sr501 which is commonly used in many projects

Technical parameters:
1. Operating Voltage Range: DC4.5-20V
2. Static current: <60uA
3. Output level: High 3.3V / Low 0V
4. Trigger: repeatable trigger (default)
5. Delay time: 8S + -30%
6. PCB Dimensions: 10 * 23mm
7. Induction angle: <100 degree cone angle
8. Induction distance: 3 meters
9. Working temperature: -20 – +80 degrees
10. Sensor Lens Dimensions: Diameter: 10mm (default)

Very simple to use, the code below shows a simple sketch. As you can see it simply a case of reading the output and if it goes high then the PIR has detected something

Layout

 

 

Code

[codesyntax lang=”python”]

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
PIR_PIN = 21
GPIO.setup(PIR_PIN, GPIO.IN)

def MOTION(PIR_PIN):
print “Motion Detected!”

print “PIR Module Test (CTRL+C to exit)”
time.sleep(2)
print “Ready”

try:
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
while 1:
time.sleep(100)

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

[/codesyntax]

 

Output

 

 

Link

A low cost module this one, you can pick these up for about $2 a piece

HC-SR505 Mini Infrared PIR Motion Sensor Precise Infrared Detector Module

Related posts

TLV493D magnetic sensor and Raspberry Pi 4 python example

SHT40 Digital Humidity Sensor and Raspberry Pi 4 python example

LTR390 UV Light Sensor a Raspberry Pi 4 in python

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More