HC-SR501 pyroelectric infrared motion sensor modules

The HC-SR501 Pyroelectric Infrared Motion Sensor Module

HC-SR501 Pyroelectric Infrared Motion Sensor modules are passive infrared electronic sensors that are used to detect motion.

Introduction to HC-SR501 pyroelectric infrared motion sensor modules

The HC-SR501 Pyroelectric Infrared Motion Sensor module is a passive infrared sensor which functions as an adjustable automatic motion detector. They are referred to as PIR, ‘Passive Infrared’, ‘Pyroelectric’ or ‘IR motion’ sensors. IR uses heat to detect motion and has a high sensitivity and reliability

The output is given digitally as a difference in voltage (HIGH vs. LOW — sensing on HIGH) where the change in voltage can then be used by a microcontroller (e.g. Arduino, ESP8266s and ESP32s) using a digital read pin.

Depending on the variation of the module, some are purely triggered (as a short burst – e.g. some normal versions and the ‘mini’ version), while others have an adjustable time delay, trigger delays (i.e. the time the voltage stays high), motion sensitivity and repeatability (non vs. repeatable) jumpers.

Sample uses and alternatives

These modules are probably mostly used in security projects for motion detection. Other motion detection modules include Laser Transmitter Receiver modules.

HC-SR501 pyroelectric infrared motion sensor module specifications

Pins: 3. Pwr, Out, Gnd (some modules are marked) – some modules might have wires pre-attached. The middle pin is usually Out. When holding upside down with pins towards you – Gnd is right, Pwr is left.
Trigger mode (digital read): HIGH w/ movement, LOW w/o movement
Input voltage: 3.3 ~ 20 V DC
Quiescent current: < 65 μA
Working current: 65 mA
Level output: 3.3 V DC high, 0V low
Time delay: 0.3 s to 300 s (adjustable)* **
Sensing block time: 0.2 s**
Trigger: L can not be duplicated, H can be repeated (usually default)**
Sensing range: 3 – 7 m & 100° – 120° angle* **
Working temperature: -15 to +70 °
PCB dimensions: 32 x 24 mm or 32 x 26 mm*, screw pitch 28 mm, screw aperture 2 mm
Sensor lens dimensions: 23 x 23 x 15 mm (removable)
Breadboard friendly: na

*Range and/or ** ability depends on model

Example code for the Arduino IDE and HC-SR501 PIR motion sensor modules

HC-SR501 PIR motion sensor modules are easy to connect to a microcontroller such as an Arduino using a digital pin. Here is an example of the code that can be used with the Arduino IDE:

// HC-SR501 PIR motion sensor connected to digital pin 2
const int pirPin = 2;
bool motionDetected = false;

void setup() {
  pinMode(pirPin, INPUT); // set PIR pin as input
  Serial.begin(9600); // initialize serial communication
}

void loop() {
  motionDetected = digitalRead(pirPin); // read PIR value

  if (motionDetected == HIGH) { // if motion is detected
    Serial.println("Motion detected!"); // print message to serial monitor
  } else { // if no motion is detected
    Serial.println("No motion detected."); // print message to serial monitor
  }
  
  delay(500); // wait for 500 milliseconds before reading PIR value again
}

In this example, the HC-SR501 PIR motion sensor is connected to digital pin 2 on the Arduino board.

The setup() function sets the PIR pin as an input and initializes the serial communication.

In the loop() function, the PIR value is read using the digitalRead() function and stored in the motionDetected variable. If motion is detected, the message “Motion detected!” is printed to the serial monitor using the Serial.println() function. If no motion is detected, the message “No motion detected.” is printed.

The delay() function is used to wait for 500 milliseconds before reading the PIR value again. This delay can be adjusted based on the specific application.

Power requirements

Even in their working state, HC-SR501 Pyroelectric Infrared Motion Sensor modules are ultra-low power consumers. At rest, currents below 65 μA are consumed and when working, 65 mA is consumed.

Voltage requirements are reported to be between 4.5 – 20 V AC (module dependent), making it perfect for, for example, Arduino microcontrollers. By looking at the datasheet, internally the HC-SR501 Pyroelectric Infrared Motion Sensor module uses 3.3 V AC, meaning these modules can also be powered by microcontrollers such as ESP8266s and ESP32s.

Repeatability

Ability is dependent on the variation of the module and is controlled either by a PCB jumper or by connecting solder pads. When holding upside down with pins towards you, the mode pins are situated in the top right corner.

The default mode (usually) is the repeatable trigger mode (H-mode) where after motion is sensed, the voltage will only drop after movement has stopped. The non-repeatable mode (L-mode or auto-reset mode) does not allow a repeat trigger and the voltage is dropped as soon as the delay time is over.

Sensing range

Motion sensitivity or adjustable sensing range is available on some HC-SR501 Pyroelectric Infrared Motion Sensor modules. If present, it is controlled by one of, or an adjustable variable resistor (orange/yellow) and is indicated by Sx.

Looking at the back, resisters facing towards you, the sensitivity is increased by turning it clockwise and vice versa.

Time delay

The time delay function also seems not to be available on all variations. As with the sensing range, the time delay is also controlled by one of, or an orange/yellow resister (indicated by Tx).

Looking again at the back, resisters facing towards you, the time delay is increased by turning it clockwise and vice versa. The time delay range is variation specific and ranges from 0.3 s to 16 s whereas others are for example 3 to 300 seconds.

Sensing block time

This is the time the module, after being triggered will not be open for another induction. In other words, the time the voltage will stay high. The default sensing block time is 0.2 s.

Photosensitive control

An additional photosensitive control (chip/jumper/module?) can be asked for and soldiered on manually (CDS) to some HC-SR501 Pyroelectric Infrared Motion Sensor modules, where the amount of light (i.e. day vs. night) entering an eye can be used as part of the logic to reserve/prevent or trigger a voltage position.

Conclusion

HC-SR501 Pyroelectric Infrared Motion Sensor modules are passive infrared sensors which use heat to detect motion.

Leave a Reply

Your email address will not be published. Required fields are marked *