PIR infrared sensor module is based on infrared technology, automatic control products. High sensitivity, high reliability, low power consumption, low voltage operation mode. Widely used in various auto-sensing electrical equipment, especially for battery-powered automatic control products.
Using PIR we can identify the motion and this sensor will transmit a signal for 3 sec so we need to do a program and detect the motion and as per your requirement you can activate or deactivate any functions like switching on camera when motion is detected.
I am going to use Raspberry Pi 2 For this small Project . In this Project i am designing and program to detect a motion and on basis of that alarm will be played for 1 minute.
Requirement :
2.Pyroelectric Infrared Pir Motion Sensor Detector Module
3.Computer With Putty Installed
Step 1.
Install any raspberry based Operating system with GPIO Package installed and as well as Python Installed. I am using OSMC.
Step 2.
Connect the PIR VCC,OUT,GND to Raspberry pi 5v,GPIO4,GND
VCC – > 5v
GND -> GND
OUT -> GPIO4 (Pin 7)
Step 3
Connect to raspberry pi using SSH (Putty For Windows)
Step4
Create a python program and copy bellow code .And after saving run the script with sudo permission
import RPi.GPIO as GPIO import time import os #GPIO Pin number where the sensor out is connected pin=4 GPIO.setmode(GPIO.BCM) GPIO.setup(pin,GPIO.IN) timer=0; switch_on=0; while True: time.sleep(1) sensor_input=GPIO.input(pin) if sensor_input == 1 : #Timer in seconds for activation timer = 60 if timer > 0 : timer = timer - 1 print "De-activating in :",timer,"secs" if switch_on!=1 : #If you want to output using 26 GPIO Remove below 2 lines comment #GPIO.setup(26, GPIO.OUT) #GPIO.output(26,1) switch_on=1 print "--- Switch Activated ---" else: if switch_on!=0 : print "Switch Deactivated" switch_on=0 #If you want to output using 26 GPIO Remove below 2 lines comment #GPIO.setup(26, GPIO.OUT) #GPIO.output(26,0)