meta data for this page
LamaPLC: PIR sensors
A Passive Infrared (PIR) sensor is an electronic device that detects motion by sensing changes in infrared light (radiant heat) emitted by nearby objects like people, animals, or vehicles.
“Passive” means it emits no energy; it only detects infrared radiation, making it suitable for applications such as security alarms, automatic lighting, and motion-activated doors.
The HC-SR501 is a widely used, low-power Passive Infrared (PIR) motion sensor module designed to detect the movement of warm objects, such as humans or animals, by sensing changes in infrared radiation
The HC-SR505 Mini PIR Module is a much smaller version of the HC-SR501.
The AM312 PIR Sensor is another small-form-factor alternative often recommended over the HC-SR501 due to its lower power consumption and better electromagnetic interference resistance.
Panasonic EKMB/EKMC Series are professional-grade PIR sensors that offer superior reliability and extremely low power consumption (as low as 2 µA in standby mode) compared with generic HC-SR501 modules.
For most beginner hobbyist projects, the HC-SR501 offers great versatility because of its adjustable settings, while the HC-SR505 and AM312 are excellent for size-constrained, simple applications. For professional or battery-critical applications demanding high reliability, the Panasonic EKMB/EKMC series is a superior, albeit more expensive, option.
If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.
Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.
HC-SR501 PIR sensor
The HC-SR501 PIR sensor module features a 3-pin connector. Because the labels on the circuit board are often hidden underneath the white Fresnel lens, it is important to orient the module correctly when identifying pins.
Standard Pinout
When looking at the back of the board (the side with the components and adjustment knobs) with the pins at the bottom:
- VCC (Left/Right depending on version): Power supply input. Most modules accept 5V to 12V DC.
- OUT (Center): Digital output signal. It sends 3.3V (HIGH) when motion is detected and 0V (LOW) when idle.
- GND (Right/Left depending on version): Ground connection to the power supply.
- Pro Tip: If you are unsure, you can gently pop off the white dome lens to see the labels (VCC, OUT, GND) printed directly on the circuit board.
Control Adjustments
The back of the module also contains two potentiometers and a mode jumper:
- Sensitivity Adjustment: Changes the detection range (typically between 3m and 7m).
- Time Delay Adjustment: Sets how long the output stays HIGH after detection (typically 5s to 300s).
- Trigger Jumper:
- L (Single Trigger): Output stays HIGH for the set time, then goes LOW, even if motion continues.
- H (Repeatable Trigger): Output remains HIGH as long as motion is continuous, resetting the timer with each movement.
Arduino & HC-SR501
To interface the HC-SR501 with an Arduino, connect the sensor's OUT pin to digital pin 2, VCC to 5V, and GND to GND.
The following sketch uses the Arduino IDE Serial Monitor to display motion status and turns on the built-in LED (Pin 13) when motion is detected.
/* * HC-SR501 PIR Motion Sensor Test */ const int PIR_PIN = 2; // HC-SR501 Out pin const int LED_PIN = 13; // Onboard LED void setup() { pinMode(PIR_PIN, INPUT); pinMode(LED_PIN, OUTPUT); Serial.begin(9600); // Warm-up period for the PIR sensor Serial.println("Warming up sensor... please wait 30-60s"); delay(30000); Serial.println("Sensor Active"); } void loop() { int motionState = digitalRead(PIR_PIN); if (motionState == HIGH) { digitalWrite(LED_PIN, HIGH); Serial.println("Motion Detected!"); } else { digitalWrite(LED_PIN, LOW); Serial.println("No motion."); } delay(500); // Small delay for serial stability }
Essential Setup Tips
- Warm-up Delay: The HC-SR501 requires approximately 30 to 60 seconds to calibrate to the room's infrared signature after power-on. During this time, it may trigger false positives.
- Trigger Jumper: For this code, set the yellow jumper on the back to H (Repeatable Trigger) so the LED stays lit as long as you keep moving.
- Voltage Logic: Although you power the module at 5V, the OUT pin uses 3.3V logic, which is compatible with both 5V Arduinos and 3.3V boards like the ESP32 or Raspberry Pi Pico.
Sensor topics on lamaPLC
This page has been accessed for: Today: 1, Until now: 45



