Introduction
HC-SR501 PIR sensor is built around the BISS0001
Micro Power PIR Motion Detector IC.
It can be used as a standalone unit or connected to an PCB board like Arduino.
Specifications
Operating voltage | 4.5 – 20 V |
Quiescent current | 50 μA |
Level output | 3.3 / 0 V |
Trigger | L single trigger / H repeating trigger |
Delay time | 3 – 300 s |
Blocking time | 2.5 s (default) |
Measuring range | 3 – 7 m |
Measuring angle | < 110° cone angle |
Fresnel lens dimensions | 15 mm x 23 mm diameter |
Operating temperature | -15 – 70 °C |
How PIR works
PIR stands for Passive INfrared. A PIR motion sensors is made up by two main components:
- pyroelectric sensing element
- fresnel lens
The pyroelectric sensing element can detect infrared radiation.
All objects with a temperature above absolute zero (-273.15
°C
) emit heat energy in the form of infrared radiation.
A pyroelectric sensor has two rectangular slots in it, both made of a material that allows the infrared radiation to pass. Behind these, there are two separate infrared sensor electrodes:
- one produce a positive output
- the other, a negative output
The sensor needs both of them since it’s looking for a change in IR levels (and not ambient IR levels). If one half sees more or less IR radiation than the other, the output will swing high or low.
The on-board signal processing IC processes this signal and turns the output pin of the sensor HIGH
or LOW
accordingly.
The white dome in front of the sensing element is a fresnel lens. This lens focuses the infrared radiation onto the sensor.
Adjust the sensor
On the back of the board there are two potentiometers and a jumper.
Range
The HC-SR501
detection range goes from 3
meters up to 7
meters.
You can adjust the sensing distance by rotating the sensitivity potentiometer clockwise (increase) or counterclockwise (decrease).
Time-delay (Tx)
This potentiometer can be used to adjust the time that the output stays HIGH
for after motion is detected.
The delay goes from 3
seconds up to 300
seconds (5
minutes).
Turn the potentiometer clockwise to increase the delay and counterclockwise to decrease it.
Trigger selection jumper
The (yellow) jumper can be used to select one of the two trigger modes. It can be set to either:
- L - Single trigger: The output will turn
HIGH
as soon as motion is detected.
It will stayHIGH
for the time set by the potentiometer. Any movement during this period is not processed and does not restart the timer. - H - Repeating trigger: Every time motion is detected, the delay timer is restarted.
Standalone unit
Hardware requirements & setup
For most basic applications, you can use the HC-SR501
as a standalone unit.
The output signal will directly trigger components like relays or LEDs.
And that’s it: no code needed!
Arduino
Please refer to the official Getting Started guide to install the Arduino IDE on the OS you prefer.
Hardware requirements & setup
- Arduino Uno board or any Arduino-like board
HC-SR501
sensor- Hook-up wires of different colors
- Breadboard
The OUT
pin is connected to digital pin 8
but ou can connect it any digital pin.
Code
The code will read the state of the sensor (HIGH
or LOW
) and turn ON or OFF the built-in board LED
accordingly.
Moreover, it will print debugging-like messages to the Serial Monitor.
I suggest you to set the H mode (repeat trigger) and adjust the time-delay potentiometer to the lowest value.
The test code is HC-SR501-Test.ino
from arduino-projects GitLab repository.
The output will be like:
#HC-SR501: Motion detected
#HC-SR501: Motion ended
#HC-SR501: Motion detected
#HC-SR501: Motion ended
#HC-SR501: Motion detected
#HC-SR501: Motion ended
...
Conclusion
HC-SR501
needs some time to initialize and adjust to the infrared levels in the room.
This process takes approximately 1
minute when it is first powered up.
You should try to delete any motion in front of the sensor during this period.
Moreover, wind and a light source close to the sensor can cause interference.
Besides the delay-time (Tx
), the sensor also has a blocking-time (Ti
).
By default, the blocking time is 2.5
seconds (it’s not so easy to change).
Each time the output goes from HIGH
to LOW
, blocking period starts.
During this time period, the sensor will not detect any motion.
When designing a system based on the HC-SR501
, you will need to take Tx
and Ti
delay periods into account.
Documentation
Useful links:
- arduino-projects GitLab repository
- makerguides.com
- aliexpress.com