HC-SR501 - Arduino Compatible IR Motion Sensor

HC-SR501

If you want to provide your DIY Arduino projects with the ability to detect proximity or movement and based on that do some kind of action, such as registering an event, turning on a light, setting off an alarm, activate a DC motoretc, then you should get to know the HC-SR501 sensor.

This sensor uses IR, like other types of similar sensors, and in this guide I will try to explain everything you need to know to start using it from scratch. From its features, to how to integrate HC-SR501 with your badge Arduino UNO. Everything in a more practical way to make it as simple as possible.

What is HC-SR501 and working principle

fresnel lens

El HC-SR501 is a kind of motion sensor, a PIR sensor consisting of two separate elements. On the one hand, it has a device that emits the differential signal between it and other sensors that will actually activate the alarm signal.

This is achieved by a integrated circuit BISS0001, which contains operational amplifiers and additional electronic interfaces. In addition to that, the module allows two adjustments of its functions, one is for the sensitivity of the PIR detection distance with some potentiometers. The other feature is the automatic light detection capability, although it is not enabled at the factory.

That last function is often used to some systems so that they turn on the light of a system when movement is detected, but the ambient lighting is not high, that is, when it is night.

In the case of the HC-SR501, it has a motion detection range with a range of 3 to 7 meters away, and PIR openings of up to 90 and 110º. That's a good range, allowing it to be installed where you need it, such as a wall, ceiling, floor, etc.

As you can see, the PIR sensor is covered by a kind of white dome, that's what is known as Fresnel lens. It is named for the French inventor and physicist Augustin-Jean Fresnel. Thanks to it, it is possible to build large aperture and short focal length lenses without the weight and bulk of the material that should be used with a conventional lens.

And that's thanks to the design of this lens invented in 1822, and that follows is a surface pattern that you can see in the image, similar to a golf ball. And thanks to this design, a multitude of devices have been implemented, including the HC-SR501.

HC-SR501 Features

HC-SR501 controls

El HC-SR501 IR module is a low cost sensor, small and with one of the most advanced technology of all current motion sensors. With its two potentiometers and the integrated jumper, its parameters can be easily modified, adapting them for all sensitivity and distance needs, and even activation and response time.

HR Technical specifications of this HC-SR501 are:

  • It consists of the PIR LH1778 and the controller BISS0001
  • Supply voltage: 5 to 12v
  • Power consumption: <1 mA
  • Distance range: 3 to 7 m adjustable
  • Detection angle: 110º
  • Settings: by means of 2 potentiometers for the detection range and active alarm time. The jumper adds the ability to configure the alarm output in single-shot or repetitive or rettigerable trigger mode. The alarm output can be configured for times between 3 seconds and 5 min.
    • 1 (in the image): turn to the right as it is in the image to set from 3 seconds to 5 minutes.
    • 2 (in the image): turn left as it is in the image to configure the distance from 3 meters to the maximum 7 meters.
    • 3 (in the image): jumper to configure the trigger. When the jumper is inserted in the two outermost pins seen in this image, then it will be configured as 1 single shot. And if it is in the two innermost, the repetitive mode is activated. That is, there are 3 pins, if it is on the outside and the middle one is the mono function, and if it is on the central pin and the one on the inside of the PCB it will be the repetitive one.
  • Initialization time: after starting to power the HC-SR501 module, at least 1 min must pass before it is operational.
  • Operational working temperature: -15ºC and + 70ºC
  • Further information: see pinout and datasheet

Keep in mind that these passive sensors They are ideal for your projects, they will only start up if they detect a proximity, meanwhile they will remain in passive ear. And you can get it very easily, since the HC-SR501 has a simple pinout:

  • Vcc to give power.
  • GND to connect to ground.
  • Output for the sensor output.

As for two trimmers which I have quoted before, they can be adjusted as I said. What I have not explained are the firing modes by the jumper:

  • H (re-activation): The output remains high when the sensor is triggered, that is, it keeps the voltage high when it detects movement or proximity, and it does so repeatedly. It will go down when the sensor is inactive.
  • L (normal): the output increases from low-high when activated. Continuous movement results in a repeated high-low pulse.

Applications

PIR is based on low-level infrared radiation. The hotter an object is, the more IR it emits. That is what this type of sensor is based on, since people, objects and animals give off heat and with it it can be measured to know if they are close or not.

With this simple system can be implemented from doors that open automatically, escalators that start when detecting proximity, alarms that are activated when they detect presence, lights that illuminate when they detect your presence, etc. The number of applications is very high ...

This combined with Arduino and many other devices such as the connectivity module, can be shipped Internet alerts, and further extend capabilities by making presence detection trigger activity remotely. I am referring to ESP8266-01 module or similar ...

Another recommendation es use a relay to activate higher voltage elements, such as a door motor, a light bulb, etc.

Integration of the HC-SR501 with Arduino

hc-sr501 connection with Arduino

For, integrate it with your Arduino IDE board, You can see our programming course for more information. However, I show you a simple sketch code with which you can start to see how it is used in a basic way, and little by little you can modify the initial code and add elements to your project to make it work completely.

El example source code it would be like this:

//Ejemplo básico con el HC-SR501

byte sensorpir 8; //Pin del salida del sensor que está como salida.
byte led=13; //Puedes conectar un LED en el 13 para ver el efecto visual cuando se activa al detectar presencia

void setup()
{
 pinMode(sensorpir, INPUT); //Declaramos pines E/S
 pinMode(led, OUTPUT); 
 Serial.begin(9600); //Configuramos la velocidad del monitor serial
}

void loop)
 {
 if(digitalRead(sensorpir)== HIGH)
  { 
   Serial.println("Movimiento detectado");
   digitalWrite(led, HIGH);
   delay(1000);
   digitalWrite(led , LOW);
  }
}


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.