From 52Pi Wiki
(Redirected from PIR Sensor SKU: D-0005)
Jump to navigation Jump to search

PIR Sensor

Rti 3.jpg


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.



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


  • Components Definitions
Rti 8.jpg


  • Operating Voltage: 5V`20V
  • Current consumption: 65 mA when it detects any change in IR light.
  • Output Voltage:When the module detects a motion of infrared the output goes HIGH at 3.3 V, if the module detects no motion it goes LOW or 0 V after a fixed period.
  • Delay time: A knob is provided to adjust the time for the output to stay HIGH after detecting the IR. This is time period can be adjusted from 5 seconds to 5 minute.
  • Sensitivity Range: The angle of the detection area is around 110 degree cone. A knob is given to adjust the sensitivity; we can vary from 3 meter to 7 meters perpendicular to senor. The sensitivity reduces as we move either sides of the sensor.
  • Operating Temperature: The HC-SR501 has an impressive operating temperature ranging from -15 to +70 degree Celsius.
  • Quiescent current: The Quiescent current is the current consumed from the supply, when the sensor is not detecting any motion or when it is in idle. It consumes less than 50 uA, which makes the sensor battery friendly.
  • Trigger modes: The PIR module has two trigger modes: Single trigger / non-repeat mode and repeat trigger. These two modes can be access by changing the jumper position given in the module.
  • Single Trigger Mode / Non-repeat Mode:When the PIR sensor is set in single trigger mode (and the timer knob / delay time is set for 5 seconds (say)), when a human is detected the output turns HIGH for 5 seconds and turns LOW.
  • Repeat Trigger Mode: When the PIR sensor is set in repeat trigger mode, when a human is detected the output turns HIGH the timer counts for 5 seconds, but when another human is detected with in those 5 seconds the timer reset to zero and counts another 5 seconds after 2nd human is detected.
  • Block Time: The block time is the time interval where the sensor is disabled or will not detect motion.
    • The block time for HC-SR501 is 3 seconds by default.
    • This occurs after the delay time (which was set by timer knob) the output goes LOW for 3 seconds; during this interval no motion will be detected.
    • After the 3 seconds (LOW) the sensor will be ready to detect motion again.In other words, when the sensor detects motion the output goes HIGH, the output remains HIGH as per the timer knob (say 5 seconds), after 5 seconds the PIR sensor goes LOW, the LOW signal will remain for 3 seconds regardless of the new motion if any.
  • Dimensions of the module: The sensor is compact enough to hide from people’s view so that it won’t affect decorates etc. It measures 32 mm x 24 mm.
  • Lens Size: The white dome structure which encloses the pyroelectric sensor is called Fresnel lenses, which increase the detection range and it looks opaque. It measures 23 mm in diameter.


Rti 1.jpg
Rti 3.jpg
Rti 5.jpg

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:

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   
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.setup(11, GPIO.IN)         #Read output from PIR motion sensor
GPIO.setup(3, GPIO.OUT)         #LED output pin
while True:
    if i==0:                 #When output from motion sensor is LOW
        print "No intruders",i
        GPIO.output(3, 0)  #Turn OFF LED
    elif i==1:               #When output from motion sensor is HIGH
        print "Intruder detected",i
        GPIO.output(3, 1)  #Turn ON LED
  • Run it in a terminal
python3 pir.py


  • PIR motion sensor, Raspberry Pi 4B, PIR