Stufin
Home Quick Cart Profile

HC-SR505 Mini PIR (Passive Infrared) Motion Sensor

Buy Now

The sensor has three pins

VCC (Power Supply)Connect to a 3.3V to 5V power source
OUT (Output)Connect to a microcontroller or other logic circuits
GND (Ground)Connect to a common ground

Note

The HC-SR505 PIR Motion Sensor is a sensitive device and may require additional shielding or filtering to minimize electromagnetic interference (EMI) in certain applications.

Always follow proper safety precautions when working with electrical components.

Pin Configuration

  • HC-SR505 Mini PIR (Passive Infrared) Motion Sensor Pinout Explanation
  • The HC-SR505 Mini PIR Motion Sensor is a popular and compact sensor used to detect motion and occupancy. It has 3 pins, which are explained below:
  • Pin 1: VCC (Power Positive)
  • Function: Provides power to the sensor
  • Voltage: Typically 5V, but can operate from 4.5V to 20V
  • Connection: Connect to the positive terminal of the power source (e.g., Arduino's 5V pin or a breadboard power rail)
  • Pin 2: OUT (Output)
  • Function: Outputs a digital signal indicating motion detection (HIGH) or no motion (LOW)
  • Logic Level: TTL (Transistor-Transistor Logic) compatible
  • Connection:
  • + Connect to a digital input pin on a microcontroller (e.g., Arduino's digital pins)
  • + Can be connected to a relay module or other devices that require a digital input signal
  • Pin 3: GND (Ground)
  • Function: Provides a reference point for the sensor's circuitry and grounds the device
  • Connection: Connect to the negative terminal of the power source (e.g., Arduino's GND pin or a breadboard ground rail)
  • Connection Structure:
  • 1. Connect the VCC (Pin 1) to the positive terminal of the power source (e.g., Arduino's 5V pin or a breadboard power rail).
  • 2. Connect the OUT (Pin 2) to a digital input pin on a microcontroller (e.g., Arduino's digital pins) or to a relay module.
  • 3. Connect the GND (Pin 3) to the negative terminal of the power source (e.g., Arduino's GND pin or a breadboard ground rail).
  • Additional Notes:
  • The HC-SR505 has a built-in voltage regulator, so it can handle a wide range of input voltages.
  • The sensor has a built-in delay time of around 2-3 seconds, which means that the output will stay HIGH for 2-3 seconds after the last motion detection.
  • The sensor is sensitive to temperature and humidity changes, so it may require adjustments or calibration in certain environments.
  • It's recommended to add a pull-down resistor (e.g., 10k) to the OUT pin to ensure the output signal is stable when no motion is detected.
  • By following these pinout explanations and connection guidelines, you can successfully integrate the HC-SR505 Mini PIR Motion Sensor into your IoT projects.

Code Examples

HC-SR505 Mini PIR (Passive Infrared) Motion Sensor Documentation
Overview
The HC-SR505 is a popular, low-power, and high-sensitivity motion sensor module based on the Passive Infrared (PIR) technology. It is commonly used in various IoT applications, such as home automation, security systems, and robotics. This module is compact, easy to use, and provides a digital output signal when motion is detected.
Pinout
VCC: 5V power supply
 GND: Ground
 OUT: Digital output signal (TTL level)
Technical Specifications
Operating voltage: 5V
 Operating current: 10mA (typical)
 Sensitivity: 7m (typical)
 Detection angle: 120
 Response time: 2.5s (typical)
 Output signal: High (3.3V) when motion is detected, Low (0V) when no motion is detected
Code Examples
### Example 1: Basic Motion Detection with Arduino
This example demonstrates how to use the HC-SR505 motion sensor with an Arduino board to detect motion and trigger an LED.
```c
const int pirPin = 2;  // Pin for PIR sensor output
const int ledPin = 13;  // Pin for LED
void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  int pirState = digitalRead(pirPin);
  if (pirState == HIGH) {
    digitalWrite(ledPin, HIGH);  // Turn on LED when motion is detected
  } else {
    digitalWrite(ledPin, LOW);  // Turn off LED when no motion is detected
  }
  delay(50);  // Wait 50ms before checking again
}
```
### Example 2: Motion Detection with Raspberry Pi (Python)
This example demonstrates how to use the HC-SR505 motion sensor with a Raspberry Pi board to detect motion and print a message to the console.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pir_pin = 17  # Pin for PIR sensor output
GPIO.setup(pir_pin, GPIO.IN)
while True:
    pir_state = GPIO.input(pir_pin)
    if pir_state:
        print("Motion detected!")
    else:
        print("No motion detected.")
    time.sleep(0.5)  # Wait 0.5s before checking again
```
### Example 3: Motion Detection with ESP32 (MicroPython)
This example demonstrates how to use the HC-SR505 motion sensor with an ESP32 board to detect motion and send a notification over Wi-Fi using MicroPython.
```python
import machine
import time
import network
import urequests
pir_pin = machine.Pin(0, machine.Pin.IN)
wifi_sta = network.WLAN(network.STA_IF)
wifi_sta.active(True)
wifi_sta.connect("your_wifi_ssid", "your_wifi_password")
while True:
    pir_state = pir_pin.value()
    if pir_state:
        urequests.get("http://your_notification_service.com/motion_detected")
        print("Motion detected!")
    else:
        print("No motion detected.")
    time.sleep_ms(500)  # Wait 0.5s before checking again
```
Note: Make sure to adjust the pin numbers and Wi-Fi credentials according to your specific setup.