D-0005: Difference between revisions

From 52Pi Wiki
Jump to navigation Jump to search
Line 1: Line 1:
==PIR Sensor==
==PIR Sensor==
==Description==
==Description==
PIR sensor called: PIR motion sensor.<br>
PIR stands for Pyroelectic Infrared Radial Sensor or Passive Infrared Sensor. <br>
PIR stands for passive infrared. This motion sensor consists of a fresnel lens, an infrared detector, and supporting detection circuitry.<br>
PIR is an electronic sensor which detects the changes in the infrared light across certain distance and gives out an electrical signal at its output in response to a detected IR signal.<br>  
The lens on the sensor focuses any infrared radiation present around it toward the infrared detector.<br>
It can detect any infrared emitting object such as human beings or animals if it is the range of the sensor, or moves away from the range, or moves within the range of the sensor.<br>
Our bodies generate infrared heat, and as a result, this heat is picked up by the motion sensor.<br>  
The PIR sensor module can be divided in to two parts an infrared sensitive crystal and the processing circuit. <br>
The sensor outputs a 5V signal for a period of one minute as soon as it detects the presence of a person. <br>
It offers a tentative range of detection of about 6–7 meters and is highly sensitive. <br>
When the PIR motion sensor detects a person, it outputs a 5V signal to the Raspberry Pi through its GPIO and we define what the Raspberry Pi should do as it detects an intruder through the Python coding. <br>
[[File:PIRsensor.jpg|left|500px]]
[[File:PIRsensor.jpg|left|500px]]
<br style="clear:both;">
<br style="clear:both;">

Revision as of 18:00, 18 March 2020

PIR Sensor

Description

PIR stands for Pyroelectic Infrared Radial Sensor or Passive Infrared Sensor.
PIR is an electronic sensor which detects the changes in the infrared light across certain distance and gives out an electrical signal at its output in response to a detected IR signal.
It can detect any infrared emitting object such as human beings or animals if it is the range of the sensor, or moves away from the range, or moves within the range of the sensor.
The PIR sensor module can be divided in to two parts an infrared sensitive crystal and the processing circuit.

PIRsensor.jpg


Features

  • Easy to assemble
  • 5V signal
  • Adjustable sensitivity
  • Compatible with most MCU or Development Board

Specifications

Gallery

Package Includes

  • 1 x PIR motion Sensor

How to build a circuit

  • Connect Raspberry Pi GPIO to the PIR motion sensor as per the connection diagram below:
Pirdiagram.jpg


How to code in Python

  • Typing following code to install RPi.GPIO python liberary.
 
sudo apt-get update 
sudo apt-get -y install python3-RPi.GPIO   
or 
sudo pip3 install RPi.GPIO
  • Edit a file named: pir.py and copy following code and save it.
import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)         #Read output from PIR motion sensor
GPIO.setup(3, GPIO.OUT)         #LED output pin
while True:
    i=GPIO.input(11)
    if i==0:                 #When output from motion sensor is LOW
        print "No intruders",i
        GPIO.output(3, 0)  #Turn OFF LED
        time.sleep(0.1)
    elif i==1:               #When output from motion sensor is HIGH
        print "Intruder detected",i
        GPIO.output(3, 1)  #Turn ON LED
        time.sleep(0.1)
  • Run it in a terminal
python3 pir.py

Keywords

  • PIR motion sensor, Raspberry Pi 4B, PIR