Hc sr501 wiring diagram. Homemade LED lamp based on the HC-SR501 IR sensor. Active Motion Sensors

In this article I will tell you how to work with the HC-SR501 sensor (PIR sensor). The sensor is inexpensive and versatile, it can be used alone or with a microcomputer to create various projects (burglar alarm systems or automated lighting systems)

Specifications

Supply voltage: 4.8V ... 20V
Static current: 50mA
Output level: 3.3V / low 0V
Delay time: 0.5 - 200s (adjustable)
Blocking time: 2.5s
Work Angle:< 100
Working temperature: -15C … + 70C
Object detection: 23mm
Dimensions: 33mm x 25mm x 24mm

General information

Any person or animal with a temperature above zero emits heat energy in the form of radiation. This radiation is not visible to the human eye because it is emitted at infrared wavelengths, below the spectrum that humans can see. Measuring this energy is not the same as measuring temperature. Since the temperature depends on the thermal conductivity, therefore, when a person enters the room, he cannot instantly change the temperature in the room. However, there is a unique infrared emission due to body temperature that the PIR sensor is looking for.
The principle of operation of the infrared motion sensor HC-SR501 is simple, when turned on, the sensor is set to "Normal" infrared radiation within its detection zone. It then looks for changes, such as a person walking or moving within a controlled area. The detector uses a pyroelectric sensor to determine the infrared cure. This is a device that generates an electrical current in response to receiving infrared radiation. Because the transducer does not emit a signal (such as the previously mentioned ultrasonic transducer), it is penalized "passive". When a change is detected, the HC-SR501 changes the output signal.

To improve the sensitivity and efficiency of the HC-SR501 sensor, the method of focusing infrared radiation on the device is achieved, this is achieved with the help of the "Fresnel Lens". The lens is made of plastic and is made in the form of a dome and actually consists of several small Fresnel lenses. Although plastic is translucent to humans, it is actually completely transparent to infrared light, so it also serves as a filter.

The HC-SR501 is a low cost PIR sensor that is completely self-contained, capable of operating on its own or in conjunction with a microcontroller. The sensor has a sensitivity adjustment that detects motion from 3 to 7 meters and its output can be set to remain high for 3 seconds to 5 minutes. Also, the sensor has a built-in voltage regulator, so it can be powered by a constant voltage of 4.5 to 20 volts and consumes a small amount of current. HC-SR501 has a 3-pin connector, the purpose is as follows:

Pin assignment
VCC— positive DC voltage from 4.5 to 20 V DC.
OUTPUT- 3.3 volt logic output. LOW does not indicate discovery, HIGH means someone has been discovered.
GND- grounding.

The board also has two potentiometers for setting several parameters:
SENSITIVITY— sets the maximum and minimum distance (from 3 meters to 7 meters).
TIME- the time during which the output will remain HIGH after detection. At least 3 seconds, maximum 300 seconds or 5 minutes.

Jumper assignment:
H is the Hold or Repeat setting. In this position, the HC-SR501 will continue to output a HIGH signal as long as it continues to detect motion.
L— This is an interrupt or no retry option. In this position, the output will remain HIGH for the period set by the TIME potentiometer setting.

The HC-SR501 board has additional holes for two components, there is a marking nearby, you can look at it by removing the Fresnel lens.

Purpose of additional holes:
RT- This is for a thermistor or temperature sensitive resistor. Adding this allows the HC-SR501 to be used in extreme temperatures and also improves the accuracy of the detector to some extent.
RL is a connection for a light-dependent resistor or photoresistor. By adding a component, the HC-SR501 will only work in the dark, which is a common application for motion-sensitive lighting systems.

Example #1: HC-SR501 as a standalone device.

Required details:


Transistor 2SC1213 x 1


Connection:
When you turn on the HC-SR501, calibration is required, it takes from 30 to 60 seconds, the sensor also has a “reboot” period of about 6 seconds (after triggering), during which time it does not respond to movements. In this example, we use HC-SR501 and a relay module (1-channel), as well as an NPN transistor (2SC1213 is used in the example). The HC-SR501 sensor is powered by 5 V, since the relay also requires the same power, and a 220V lamp is used as a load. Since the output signal of the HC-SR501 is weak (in practice, it is only enough to light the LED), one option is to use any NPN bipolar transistor.

Attention! Follow safety precautions and be careful!

The operation of this circuit is very simple, after switching on and calibrating, the sensor starts reading. When motion is detected, the sensor changes the value at the “OUT” pin.

Example #2: HC-SR501 adding photoresistor

Required details:
Motion sensor HC-SR501 x 1 pc.
Relay module (1-channel) x 1 pc.
Transistor 2SC1213 x 1
Lamp for 220V (75W) with socket x 1 pc.
Power supply for 5V x 1 pc.
Photoresistor x 1pc
DuPont wire, 2.54 mm, 20 cm, F-M (Female - Male) x 1 pc.

Connection:
In the following example, we use the same circuit as in example No. 1, only a photoresistor has been added. The place for installing the photoresistor is located next to the output connector, the designation on the board is "RL". You can solder directly to the board or use the pin header to easily connect the Dupont wire. The main thing is that the photoresistor should not be closed from the natural light of the room, but also be protected from the light of the lamp, which we use as a load. The figure below shows where to install the photoresistor.

Once the photoresistor is installed, turn on the circuit and wait for a while while the HC-SR501 sensor calibrates. If everything is connected correctly (and the room lights are on), nothing will happen, the photoresistor prevents the HC-SR501 from starting when the room is lit. Now turn off the light and the HC-SR501 will start up whenever it detects activity.

Example #3: HC-SR501 and Arduino

Required details:
Arduino UNO R3 x 1pc
Motion sensor HC-SR501 x 1 pc.
LEDs 5 mm x 3 pcs.
Resistor 0.125W, 320Om x 3 pcs.
DuPont wire, 2.54 mm, 20 cm, F-M (Female - Male) x 1 pc.

Connection:
Although the HC-SR501 sensor is a stand-alone device, it can be connected to a microcontroller pin. In the example, we use the Arduino UNO R3 controller, in which we can take into account the turn-on time and the reset period. This way the device can be more accurate as you won't be trying to sense forward motion when the sensor is not ready. Also, you can connect several HC-SR501 sensors to the Arduino, which will allow you to track movement in different places.
In the following example, we will connect one HC-SR501 to the Arduino as an indication using three LEDs, each of which indicates the status of the sensor:

  • Red LED- This LED indicates that the sensor is not ready.
  • Yellow LED- This LED indicates that the sensor is ready to detect motion.
  • Green LED- This LED lights up for 3 seconds when the sensor is triggered. Instead of an LED, you can control an external output (like the relay module we used earlier).

Wiring diagram:

The jumper on the HC-SR501 must be set to the “L” position, and it is also necessary to set the time to a minimum (5 seconds), to do this, turn the potentiometer to the left until it stops. Now that you're all connected, you need to upload the sketch.

/* Tested on Arduino IDE 1.8.0 Test date 08/12/2016. */int detectedLED = 13; // Specify the pin int readyLED = 12; // Specify the pin int waitLED = 11; // Specify the pin int pirPin = 7; // Specify the pin of the sensor int motionDetected = 0; // Variable for motion detection int pirValue; // Variable to save value from PIR void setup() ( pinMode(detectedLED, OUTPUT); // Set pin as output pinMode(readyLED, OUTPUT); // Set pin as output pinMode(waitLED, OUTPUT); // Set pin as output pinMode(pirPin, INPUT); // Set pin as input // Initial delay of 1 minute to stabilize the sensor// digitalWrite(detectedLED, LOW); digitalWrite(readyLED, LOW); digitalWrite(waitLED, HIGH); delay( 60000); digitalWrite(readyLED, HIGH); digitalWrite(waitLED, LOW); ) void loop() ( pirValue = digitalRead(pirPin); // Read the value from the motion sensor if (pirValue == 1) // If there is movement, make a delay of 3s ( digitalWrite(detectedLED, HIGH); motionDetected = 1; delay(3000); ) else ( digitalWrite(detectedLED, LOW); ) // Delay after triggering // if (motionDetected == 1) ( digitalWrite (detectedLED, LOW); digitalWrite(readyLED, LOW); digitalWrite(waitLED, HIGH); delay(6000); digitalWrite(readyLED, HIGH); digitalWrite(wai tLED, LOW); motionDetected = 0; ) )

Download sketch

Upload this sketch to the Arduino controller. When turned on, the red LED will light up, which indicates the preparation of the sensor (on for 1 minute). After a minute, the yellow LED will turn on and the red LED will turn off, which means that the sensor is ready to detect motion. As soon as the sensor detects motion, the green LED will turn on and remain lit for three seconds.

Buy on Aliexpress
Buy Infrared Motion Sensor HC-SR501
Buy a set of DuPont wires, 2.54 mm, 20 cm

In the face of ever-increasing electricity tariffs, it's time to think about saving it. And when it comes to lighting, this can be achieved by using LED light sources, which save energy to a large extent. Also, in addition to them, motion and light sensors are installed, which allow you to automate the lighting process and thereby increase the life of the LED light source, which has a rather high price, and also reduces power consumption. These LED light sources respond to both room illumination and movement, while working in conditions when it is needed. Turning off such LED light sources occurs independently after a while. LED lamp with motion sensor has proven itself to work both indoors and outdoors. It is worth noting that the installation of LED lamps with a motion sensor is possible even in hard-to-reach places where there is no way to supply electricity. The advantage of such LED lamps with a motion sensor is that it will not consume electricity unnecessarily and thus save it. At the same time, there is no need to install a switch under it, which then will have to be looked for in the dark. Moreover, if a photo sensor is installed in the device, then this LED lamp will respond not only to movement, but also to the level of illumination. If the lamp is installed on the street, then at dusk it will turn on automatically, and turn off when there is sufficient lighting.

Well, let's start in order and make such an LED lamp ourselves. For this we need the following:

  • frame
  • mounting wires
  • foil fiberglass
  • 12v power supply or battery.

Sensor HC-SR501

To set modes on the sensor HC-SR501 there are two potentiometers (time and sensitivity) and a jumper (see picture below):

Key Features of HC-SR501:

  • Working voltage: DC 4.5V - 20V
  • Output signal: high / low level (0 or 1), signal: 3.3V TTL level
  • Detection range: 3 - 7 Meters (adjustable by "sensitivity" potentiometer)
  • Detection angle: 120-140° (Depends on installed Fresnel lens)
  • Trip delay time: 5-300 seconds (adjustable by "time" potentiometer, default 5s -3%)
  • Operating Temperature: -20 - 80°C
  • Working mode:
    - Mode H - in this mode, when the sensor is triggered several times in a row, its output (at OUT) remains at a high logic level.
    - Mode L - in this mode, a separate pulse appears at the output each time the sensor is triggered.

Having chosen the sensor operating mode, setting the sensitivity and response time, let's move on to another important point - installing a photoresistor, since in addition to the standard sense organs, a pyroelectric sensor has the ability to install a photoresistor. Often there are free contacts on the connection board. In the diagram below, its contacts are designated as RL.

When a photoresistor is connected, the device will only work in the dark. Since if you illuminate the photoresistor, its resistance will decrease and the voltage on leg 9 of the DA1 microcircuit will be insufficient to turn on. You can adjust the turn-on threshold by connecting a tuning resistor in parallel with resistor R9. It must be connected through a resistance of 1 ... 4.7 kOhm in order to prevent a short circuit at low resistances of the photoresistor. The photoresistor is installed on the sensor board in the place circled in yellow (see the pictures below).


12v led strip

More recently, a number of LED lamps has been replenished with lamps, which are thin flexible tapes up to 5 meters long with the possibility of increasing their length. The tape can also be cut into small pieces, a few centimeters long. When choosing an LED strip, the main lighting characteristic is the intensity of the luminous flux, which is expressed in lumens per meter (lm / m). The amount of luminous flux is determined by the type and number of LEDs installed on one meter of tape. Knowing the type of LEDs and their number, it is easy to independently determine the luminous flux.

For example, a meter of white light LED strip has 30 type 3528 LEDs with a luminous flux of 5 lumens per LED. We multiply 5 lm by 30 LEDs, we get 150 lm. Approximately such a luminous flux emits a 10-watt incandescent light bulb.

The device of the LED strip on a flexible plastic tape up to 5 m long contains thin copper conductive tracks of the required configuration. LEDs and current-limiting ones are soldered to the tracks. With a supply voltage of 12V, three LEDs connected in series and one or more current-limiting resistors are installed. The number of resistors is determined depending on the amount of power dissipated on them (see the figure below).

To mount the LED strip, a sticky layer protected by a film is applied on one side. In order to fix the tape on the surface, it is necessary to remove the protective film and apply the sticky side to the installation site. If necessary, the LED strip can be cut. The cutting step is determined by the number of LEDs connected in series and is separated on both sides by pads that allow you to solder wires to them (see the figure above). For the LED lamp, 4 pieces of LED strip with 5630 LEDs were used.

frame

Since LEDs are afraid of overheating, good heat dissipation is necessary for their long service life. In this regard, the frame was made of an aluminum plate 2 mm thick. Holes for fasteners and wire laying are also drilled in the frame (see pictures below).

Mounting wire

Mounting wires are used for the installation of radio components and radio components, assemblies and blocks of radio-electronic equipment, the installation of electrical apparatus and devices. Conductive cores of mounting wires are tinned copper wires that allow connections by soldering with low-temperature solders. Stranded flexible wires provide installation flexibility and reliable protection against external influences. The insulation material is glass and nylon threads, triacetate film tapes used in the temperature range of -60 ... +105 ° C, polyvinyl chloride and polyethylene insulation with an additional protective sheath made of nylon, resistant to moisture, oils and fungal mold.

Foil fiberglass

Foiled glass-textile sheet material is made from fiberglass, which is impregnated with epoxy resin. A layer of galvanic copper foil with a thickness of 35 µm or 50 µm is applied to the surface of the product. So we will make contact pads and a printed circuit board of a transistor key from it.

12V power supply or battery

The power supply unit converts the alternating voltage of the 220V home electrical network into a given constant voltage.

It's time to consider the scheme of this lamp.

Photo of the assembled version of the LED lamp

List of radio elements

Designation Type of Denomination Quantity NoteScoreMy notepad
P1 SensorHC-SR5011


PIR sensor translated from English as Pyroelectric (Passive) InfraRed sensor— pyroelectric (passive) infrared sensor. Pyro-electricity- this is the property to generate a certain electric field when the material is irradiated with infrared (thermal) rays. That's why PIR sensors allow to detect the movement of people in the controlled area, as the human body radiates heat.

HC-SR501 can be powered from 4.5 to 20 volts,
its dimensions are approximately 3.2cm x 2.4cm x 1.8cm,
Detection distance 3 - 7m, regulated by a variable resistor " Sensitivity Adjust"
Pulse Width at Detection 5 - 200sec is regulated by a variable resistor " Time Delay Adjust"
Working temperature-20 — +80°C

Operating modes
L and H
H mode- in this mode, when the sensor is triggered several times in a row, its output (at OUT) remains at a high logic level.
L mode- in this mode, a separate pulse appears at the output each time the sensor is triggered.

For example : set the light to turn on for 5 seconds.
mode L : there is movement - the light turned on, after 5 seconds. turned off. If you walk in front of the sensor all the time, the light is on-off-on-off, etc.
H mode : there is movement - the light turned on, after 5 seconds. turned off. If you walk in front of the sensor all the time, the light is on all the time.

After connecting power to the sensor, you must wait about 1 minute, the sensor is calibrated after switching on. Do not perform any actions with him at this time.

As soon as the sensor detects movement, the output out voltage will appear and will remain there for a certain time set by a tuning resistor Delay. With this output voltage, we turn on the required device. It can be a lighting lamp, a fan, a sound annunciator. Of course, it will not be possible to power these devices directly from the sensor, the output is low-current, so we need something else to switch a powerful load.
The easiest option is to use FETs from an old computer motherboard.


You can play around with setting the sensitivity and installing the module in different places at home
So that the module does not slow down, you can replace R12 (which goes to the 6th output of the microcircuit) with 100 Ohms, it sets the frequency of the common generator.
If the sensor is used to turn on the lighting, you can install a photoresistor on the board, then during the daytime the sensor will not give a signal to turn on. For the photoresistor, the board has mounting holes above the input pins. There are also holes for installing a thermistor. Its installation will increase the sensitivity of the sensor and the accuracy of its operation.




Do not place the PIR sensor in places where the temperature changes rapidly. This will lead to the fact that the sensor will not be able to detect the presence of a person in the controlled area, and there will be many false positives, but with the thermistor installed, there will be no such problem.

You can make your home a little smarter and more economical by installing such sensors in places where you need to turn on the lights only while a person or a warm-blooded animal is there.

Currently, pyro sensors, or infrared motion sensors, are commercially available. The principle of operation of the pyroelectric sensor will not be described here. I will only say that the pyro-sensor is designed to record the movement of a person. This particular device uses the HC-SR501 pyro sensor.

Module with sensor HC-SR501

It is a small printed circuit board on which the lens is located. This board has three points for connecting to an external circuit - point Vpp (power supply from 5 to 20V), current Out (output, when it is triggered, the voltage is 3.3V), and GND (common minus).

There are two tuning resistors on the board, one of which regulates the sensitivity of the sensor (the range of motion detection is from 3 to 7 meters), the other is the time during which the voltage of 3.3V is maintained at the output when triggered (from 5 seconds to 200 seconds). Another jumper for two positions "H" and "L".

In order for the sensor to work in this design, you need to put the jumper on its board in the “H” position, the time adjustment resistor in the minimum time position. Well, the sensitivity adjustment resistor to a position in which there will be the necessary sensitivity. Figure 1 schematically shows the pyroelectric sensor board with the location of the connection and control elements on it.

Rice. 1. Organs for setting and connecting the HC-SR501 sensor.

Schematic diagram of the security device

The alarm works on the B1 electronic siren, which is a standard car alarm siren. This is due to the supply voltage of the circuit. The circuit is based on a D1 logic chip of the K561LE10 type (or a foreign analogue 4025). This chip consists of three logic elements "ZIL-NOT" CMOS logic. When powered from a 12V source, the voltage at the output of the pyroelectric sensor F1 (3.3V) will not be enough, so after it the cascade on the transistor VT1 is turned on, it increases the level of a logical unit but inverts the voltage. To correct the inversion introduced by the transistor VT1, element D1.1, included by the inverter, is used.

Rice. 2. Schematic diagram of a security device based on the HC-SR501 pyro-sensor.

Now, when the pyroelectric sensor is triggered, the output of element D1.1 will be a logical unit. On the other two elements of the microcircuit, an RS flip-flop is assembled with a reverse reset circuit on C2 and R4.

As soon as the trigger is set to a state with a logic unit at the output D1.3, the capacitor C2 begins to slowly charge through R4, and after about 20 seconds the voltage across it reaches the logic unit threshold. And the trigger returns to its original position.

The trigger is blocked by the C1-R3 circuit. While C1 is discharged or the blocking switch S10 is closed, the voltage at terminal 12 D1.3 is a logical unit. While there is such a state, the voltage at the output of element D1.3 does not depend on the voltage at the terminals 1 and 2 of element D1.2 connected together. Therefore, the circuit does not respond to the state of the pyroelectric sensor.

After turning off S10, the capacitor C1 through the resistor R3 begins to slowly charge and after about 20 seconds the voltage across it reaches the logic zero threshold. Now the trigger will respond to the pyroelectric sensor, and when it is triggered, a logical unit will be set at the output of D1.3. The key on VT2 and VTZ will open and power will be supplied to the siren.

Disabling the alarm occurs in two stages. First you need to press the code buttons on the keyboard from the S0-S1 buttons. The keyboard is made according to the scheme of a simple combination lock. All buttons are toggle.

All are connected in series in the circuit, but the buttons that form the code are connected by normally open contacts, and all the rest are normally closed. As a result, the circuit is closed if only the buttons that form the code are pressed at the same time. In all other cases, the circuit is not closed. The code is set by mounting the buttons.

The figure shows the option for the code "045", - while pressing the buttons SO, S4 and S5, the circuit closes and discharges the capacitor C1. Now, for about 20 seconds, the circuit will not respond to the pyroelectric sensor, you can enter the room and finally block the alarm with switch S10 (turn it on).

The time during which the circuit is not sensitive to the pyroelectric sensor (time to enter and block or to unblock and exit) depends on the parameters of the circuit C1-R3. The minimum time during which the alarm sounds - by the R4-C2 circuit.

Details and installation

B1 - any electronic siren for car alarms. Buttons S0-S9 - toggle switches, non-latching. The logic part is mounted on the printed circuit board shown in Figure 3.

Rice. 3. Printed circuit board for a security device based on the pyro-sensor HC-SR501.

Keyboard buttons S0-S9 are installed on a separate panel and wired with mounting wires, according to the given code.

Karavkin V. RK-2015-11.

In the struggle for the life of incandescent lamps on the landing, I tried a fairly large number of schemes for their protection. These were both simple diodes and soft start circuits, and acoustic sensors. Not all have proven themselves on the positive side. Going to the Aliexpress website, I came across a pyroelectric sensor HC-SR501. At a price of less than one dollar, the sensor has a number of positive qualities, namely: power supply from 5 to 20 volts, motion detection zone from 3 to 7 meters, turn-off delay from 5 to 300 seconds. (I don’t see the point in giving a full description here, since this information is more than enough). Externally, the sensor looks like this:

Just what you need to illuminate the landing, where people do not walk so often and the constant glow of the lamp is useless.

The photo below shows the connection points for the common wire (GND), the trigger signal output (Output) and the power bus (+ Power). The board has two variable resistances: one regulates the response zone (Sensitivity Adjust), the other the turn-off delay (Time Delay Adjust).

In addition, there is a jumper for switching modes. H and L. In mode L the sensor, having fixed the movement, outputs a high-level signal. Regardless of whether there is further movement in the detection area or not, after a set delay time (for example, 30 seconds), the output signal will be turned off.

In mode H the output signal will disappear only after the delay time has elapsed from the moment of the last motion detection in the detection zone. That is, they passed through the movement zone - it will turn off after 30 seconds, stay and move in the detection zone for 10 minutes and leave it - it will turn off after 30 seconds. While you are in the detection zone, the sensor will not turn off.

Just what you need to illuminate the landing, where people do not walk so often and the constant glow of the lamp is useless. Having studied the datasheet and materials on the network, I discarded the Arduino use cases as excessively costly and sketched the following circuit.

Functionally, the device consists of three nodes:

  1. the HC-SR501 sensor itself;
  2. an actuator consisting of a resistor R3, a transistor VT1, a diode D1 and a relay P1, where R3 and VT1 serve as a link between the sensor and the relay. Without them, the load capacity of the sensor is so low that only an LED can be connected directly;
  3. transformerless power supply, where R1 is necessary to reduce the inrush current (often it can be neglected), capacitor C1 with a rating of 0.47 - 0.68 uF with an operating voltage of at least 250 volts provides an output current of up to 0.05 A, R2 is necessary for discharging capacitor C1 after disconnecting the device from the network.

Why a diode bridge is known to everyone. The filter capacitor should be selected with an operating voltage of at least 25 volts. Well, finally, the zener diode sets the voltage at the output of the power supply at 12 volts. The choice of a zener diode specifically for 12 volts is due, on the one hand, to the supply range of the sensor from 3 to 20 volts, on the other hand, the operating voltage of the relay is 12 volts.

Separately, it is worth mentioning the transistor. This is practically any NPN transistor structure - 2N3094, BC547, KT3102, KT815, KT817, etc. etc.

A relay with almost any coil resistance, a switching voltage of 250 volts and a current of 3 amperes, which will make it possible to safely switch a load of several hundred watts.