Contents

Interfacing HC-SR505 Infrared PIR Motion Sensor with Arduino

HC-SR505 Motion Sensor Features

The HC-SR505 motion sensor is a PIR module based on infrared technology. PIR modules consist of two parts: PIR sensor and lens. This sensor can detect infrared waves. This range includes all objects with a temperature above absolute zero. You can see this sensor by removing the module lens.
This module has regulator, so it can be connected to 4.5 to 20 volts. The viewing angle is 100 degrees. This sensor is widely used in a variety of electrical equipments because of its ultra-small size, ultra-low-voltage operation mode, high sensitivity and high reliability.

Note

The HC-SR505 sensor detects motion up to 3 meters distance. If it detects motion, output will be HIGH and LOW again with some delay. This delay is 8 seconds based on the datasheet.

You can download the datasheet of this module here.

HC-SR505 Motion Sensor Pinout

This Module has 3 pins:

  • VCC: Module power supply – 5 to 20 V
  • GND: Ground
  • OUT: Digital output

You can see the pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
HC-SR505 Motion Sensor × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing HC-SR505 Motion Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to HC-SR505 sensor. Connect wires accordingly.

Step 2: Code

Upload the following code to Arduino.

    /*
  HC-SR505-PIR-Motion-Sensor
  made on 24 oct 2020
  by Amir Mohammad Shojaee @ Electropeak
  
Home
*/ const int Pin=2; void setup() { pinMode(Pin, INPUT); Serial.begin(9600); } void loop() { int sensorValue = digitalRead(Pin); if(sensorValue==HIGH){ Serial.println("detect Motion"); delay(1000); } else{ Serial.println("no Motion"); delay(1000); } }

In this code, the digital input is read, if HIGH, motion is detected and if LOW, no motion.

The result appears on the Serial Monitor. As you see, the delay time after each detection is approximately 13 seconds.

Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

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