~~NOCACHE~~ ====== LamaPLC: PIR sensors ====== {{ :sensor:hc_sr505.png?140|HC-SR505}} 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. ^Feature^HC-SR501^HC-SR505^AM-312^Panasonic EKMB/EKMC Series| | |{{ :sensor:hc_sr501.png?80 |HC-SR501 PIR sensor}}|{{ :sensor:hc_sr505.png?80 |HC-SR505}}|{{ :sensor:am_312.png?80 |AM-312}}|{{ :sensor:ekmb_1.png?80 |Panasonic EKMB/EKMC Series}}| ^Operating Voltage|4.5V - 20V DC|4.5V - 20V DC|2.7V - 12V DC|2.3V - 6V (EKMB), 3V - 6V (EKMC)| ^Quiescent Current|~50µA - 65µA|~60µA|<0.1mA (~100µA)|Extremely Low (e.g., 1µA, 2µA, 6µA for EKMB; 170µA for EKMC)| ^Detection Range|3m - 7m (up to 7m, adjustable)|Up to 3m|3m - 5m|Varies greatly by model/lens (e.g., 5m, 12m, 17m options available)| ^Detection Angle|<140° cone angle|~100° cone angle|≤100° cone angle|Varies by lens (e.g., 94°x82°, 150° in one axis)| ^Adjustable Delay|Yes (via potentiometer, ~5s - 300s)|No (fixed ~6-12s)|No (fixed ~2s)|Varies by specific model, some are highly configurable| ^Adjustable Sensitivity|Yes (via potentiometer)|No|No|Varies by specific model| ^Trigger Mode|Configurable (Repeatable 'H' / Non-repeatable 'L')|Repeatable only (by default)|Repeatable only (by default)|Varies by specific model| ^Physical Size|Standard (32x24mm module)|Mini/Small|Mini/Small (10x8mm module)|Very small, integrated components, often lensless options available| ^Reliability/Noise|Prone to false triggers, low quality processing|Can be triggered by temperature changes/power noise|Small, but has reports of false alarms|Superior reliability, high signal-to-noise ratio, highly shielded| ^Cost|Very Low|Very Low|Very Low|Higher cost (professional grade)| 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. {{page>:tarhal}} ====== HC-SR501 PIR sensor ====== {{ :sensor:hc_sr501.png?140|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 ===== {{topic>sensor}} \\ {{tag>HC-SR501 HC-SR505 AM-312 EKMB/EKMC PIR motion sensor arduino code}} This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}