Tuesday, October 20, 2020
Home Arduino Passive Infrared Sensor HC-SR501 | PASSIVE INFRARED SENSOR


HC-SR501 is a Passive Infrared Sensor. It measures the surrounding Infrared radiation coming from bodies. It is mostly used for Arduino security projects like burglar alarms, etc. The sensor can’t get the information on who moved or what moved, so it is called Passive Infrared device.If you are looking for mini version check out the HC-SR505

USA purchase link
UK purchase link
Germany purchase link

HC-SR501 Module
HC-SR501 Module


  • Voltage: 5V – 20V
  • Power Consumption: 65mA
  • TTL output: 3.3V, 0V
  • Delay time: Adjustable (.3->5min)
  • Lock time: 0.2 sec
  • Trigger methods: L – disable repeat trigger, H enable repeat trigger
  • Sensing range: less than 120 degrees, within 7 meters
  • Temperature: – 15 ~ +70
  • Dimension: 32*24 mm, the distance between screw 28mm, M2, Lens dimension in diameter: 23mm

How does HC-SR501 work?


Every living body emits heat energy in the form of radiation. HC-SR501 is designed to detect such radiations. There is two component of the sensor. The Pyroelectric sensor and the fresnel lens. This lens focuses the infrared signals onto the pyroelectric sensor. There are two slots in the pyroelectric sensors. Behind these two slots, there are two sensor electrodes.

  • One responsible for positive output.
  • Second for negative output

When there is no movement both sides of the slot have the same outputs. This is the situation when the sensor is idle. When a warm body passes, half of the sensor causes a positive differential change. The reverse happens when the warm body leaves the sensing area. The sensor generates a negative differential change. The Corresponding pulse of signals results in the sensor setting its output pin high.

HC-SR501 Pinouts

The sensor has 3 pins

  • Vcc
  • GND
  • Output

There are two potientiometers to set the sensitivity and running time of the module.

Arduino Wiring:

First, Connect the Sensor VCC to Arduino VCC.

Then Connect Sensor GND to Arduino GND

Lastly, Connect Sensor Output to Arduino  pin 13

Arduino Code:

 * PIR sensor tester
int ledPin = 10;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;



Please enter your comment!
Please enter your name here

Most Popular


The KY-032 obstacle avoidance sensor is an infrared obstacle avoidance sensor. It comes with the 37 in 1 starter kit for Arduino. It helps...

HIH-4000 | Humidity Sensors

The HIH-4000  sensors are one of the highly efficient humidity sensors you can buy. The HIH-4000 is an analog humidity sensor. It is useful...


The KY-026 Arduino Flame Sensor is a low-cost starter sensor. It normally comes in the starter kit of Arduino like the ky-039. It can...


The KY-039 Heartbeat sensor is one of the cheapest sensors to get a start on Arduino like the Sound sensor. It cost less than...

Recent Comments