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
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
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()
A low cost module this one, you can pick these up for about $2 a piece