Hc sr501 photoresistor connection diagram. Infrared motion sensor HC-SR501(PIR Motion sensor). Key Features of HC-SR501

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 a motion sensor has proven itself in work both indoors and on open areas. 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%)
  • Working 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.

After selecting the sensor operation mode, adjusting the sensitivity and response time, let's move on to one more important point installation of a photoresistor, since in addition to 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 yellow, (see pictures below).


12v led strip

More recently, a number LED lamps replenished with lamps, which are thin flexible ribbons 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 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.

Flexible LED strip device plastic tape up to 5 m long there are 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 protective film and attach 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

For the installation of radio components and radio components, assemblies and blocks of radio-electronic equipment, installation electrical apparatus and devices, mounting wires are used. 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 from 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 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 from it we will make contact pads and printed circuit board transistor key.

12V power supply or battery

The power supply converts the AC voltage of the home electrical network voltage 220V to the specified constant voltage.

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

A photo assembled version LED lamp

List of radio elements

Designation Type of Denomination Quantity NoteScoreMy notepad
P1 SensorHC-SR5011

In this article I will tell you how to work with the HC-SR501 sensor (PIR sensor). The sensor is inexpensive and versatile, and can be used alone or with a microcomputer to create various projects(systems burglar alarm 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 thermal 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 adjusts 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 electricity 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 by using 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 in fact 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 movement 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 not a large number of current. HC-SR501 has a 3-pin connector, the purpose is as follows:

Pin assignment
VCC- positive voltage direct current 4.5 to 20 VDC.
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 setting potentiometer TIME.

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 to some extent improves the accuracy of the detector.
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 is not covered from natural light room, and was also 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 and independent device, it can be connected to the output of the microcontroller. 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 Testing 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


PIR sensor translated from English as Pyroelectric (Passive) InfraRed sensor— pyroelectric (passive) infrared sensor. Pyro-electricity 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 with the old motherboard computer.


You can play around with the sensitivity setting and setting the module to 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 appearance 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.

Infrared motion sensor HC-SR501

This article provides a description of the main characteristics and principles of operation of the finished IR sensor HC-SR501, which can be used both with arduino and separately.

The most important advantage of this sensor, in my opinion, is the price for aliexpress, I bought it for 42 rubles with free shipping in 2016
Its second advantage is the ease of connection and use, since it does not contain any interfaces and has only three contacts (power, common and output).

In the "H" mode, a logical unit (+3.3 volts) appears at the output, which allows even a novice radio amateur to connect the sensor.

Main characteristics

  • Dimensions: 3.2 cm x 2.4 cm x 1.8 cm (approx.)
  • Sensitivity and delay time can be adjusted
  • Working voltage: DC 4.5V - 20V
  • Current:< 60 мA
  • Output signal: high / low level (0 or 1), signal: 3.3V TTL level
  • Detection range: 3 - 7 meters (adjustable by potentiometer)
  • Detection angle: 120-140° (Depends on installed Fresnel lens)
  • Trip delay time: 5-300 seconds (adjustable by potentiometer, default 5s -3%)
  • Blocking until the next measurement: 2.5 seconds (smd resolder can be changed)
  • 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.
    • L mode - in this mode, a separate pulse appears at the output each time the sensor is triggered.

The appearance of the motion sensor


In the photo above, the sensor is on both sides and with the Fresnel lens removed.
To set the operating modes, the module has two potentiometers and a jumper, I think their purpose is clear from the photo below:

HC SR501 upgrade

- About adjustment b locking until the next measurement (2.5 sec.)
As mentioned above in the main characteristics, the blocking time can be changed by replacing smd ,
its default resistance is 1 MΩ, in the diagram below it is designated R14 (between 5 and 6 legs of the microcircuit)
The resistance can be slightly reduced to increase performance, for example
replacing this resistor with 220 kΩ reduces the delay by a factor of 5, but be careful, excessive speed can cause the sensor to turn on immediately after trying to turn it off, such an effect observed already at 100 - 180 kOhm

- Photoresistor in HC-SR501
In addition to the standard sense organs of the pyroelectric sensor on the hc board SR501 you can also 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. When the photoresistor is illuminated, its resistance is low, and the voltage at input A3 of the DA1 chip will be insufficient to turn on the device.
You can adjust the switching threshold by connecting in parallel
resistor R9 tuning resistor. it is desirable to connect through a resistance of 100 - 200 ohms in order to prevent a short circuit at low resistances of the photoresistor.
Everything seems to be clear, if you don't understand, ask in the comments.

- Noise sensor in HC SR501
Perhaps a little superfluous, but there is such a possibility - connecting a noise sensor from the same arduino.
The signal wire through a 10 kΩ resistor connected in series with a 10 microfarad capacitor is connected to the 13th leg of the DA1 microcircuit (see diagram)

The noise sensor itself is best powered from a stable source of 3.3 -5 volts, you can take power from the stabilizer
in
HC-SR501 (7133) - DA2 chip.

- (thermistor) in HC-SR501
According to some reports, a thermistor is connected to the RT contacts of the IR sensor in parallel to R8,
I couldn't find any information about it on the Internet. Since this is a circuit between the first and second stages of amplification and the resistance R8 directly affects the sensitivity of the sensor, it can be assumed that the thermistor should ensure the sensor is triggered in case of fire or is simply an element of thermal stabilization, which in my opinion is unlikely.
In general, a new sensor has been ordered (the old one already controls the light), they will come and try it and describe what for what and why.
If you have an answer, you can write in the comments.

HC-SR501

The diagram may differ from the one shown, but not by much.
The supply voltage through the protective diode VD1 is supplied to the microcircuit voltage regulator
HT 7133-1.
C1 - filtering. The pyroelectric sensor is powered by voltage stabilizer through additional RC filter consisting of resistors R3, R4 and capacitor C4. From the output of the pyroelectric sensor through the resistor R2, the signal is fed to the non-inverting input of the operational amplifier A1, pin 14 of the DA1 chip. Resistor R2 is part of the U - shaped filter - C2, R2 and C5. The DA1 microcircuit is a specialized microcircuit and, in all likelihood, a Chinese brainchild, because the documentation for it is on Chinese. The DA1 circuit from the documentation is shown in Figure 2, and typical scheme turn on in Figure 3. Other than the op amps and some of the logic cells, it's hard to understand anything. But we don't need much.

And so, the amplified op-amp A1 sensor signal, pin 16 DA1, through a decoupling capacitor C6 and resistor R8 is fed to the inverting input of the second amplifier A2, pin 13 DA1. Capacitors C7 and C9 are apparently corrective, and resistor R10 is a resistor feedback, on the value of which the transmission coefficient of this amplifier depends. The gain A1 is equal to R10/R5. The gain of the OU A2 is equal to the ratio of the sum of the resistances R6, R7 and the resistance of the resistor R8. Kus = (R6 + R7)/R8. Resistor R7 is trimmer, which gives us the opportunity to adjust the sensitivity of the circuit. In other words, you can adjust the distance from the sensor to the object at which the signal will appear at the output of the device. Conclusion 9 DA1 pulled up to the supply voltage. It can be used to turn the circuit on and off. If this pin is connected to a common wire, then the output signal at pin 2 will not appear. A photoresistor can be connected to the RL connector, then the device will only work in the dark. When the photoresistor is illuminated, when its resistance is low, then the voltage at input A3 of the DA1 chip will be insufficient to turn on the device. You can adjust the turn-on threshold with a trimming resistor connected in parallel with resistor R9.

Chip DA1 has an internal timer. Using this timer, you can set the duration of the output signal at pin 2. The timing circuit of this timer is resistors R13, R15 and capacitor C10. Time adjustment is made by resistor R15. The logical one level corresponds to a voltage of two volts, so in some cases a matching stage may be required to work with other blocks. The current consumption of the circuit is very small and is only 0.06 mA.

Sensor test

Checking the operation of the sensor is very simple by assembling on a breadboard a simple circuit. The indicator here is a conventional LED, with a current-limiting resistor of 180 ohms, as shown in the figure below.

You can buy a sensor HC-SR501here.

I take sound modules

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 with 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. ( Full description I don’t see the point here, since this information is more than enough). Externally, the sensor looks like this:

Just what you need for lighting 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 detects movement and outputs a signal high level. 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 options using Arduino as overly costly and sketched out the following diagram.

Functionally, the device consists of three nodes:

  1. the HC-SR501 sensor itself;
  2. executive device, 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 needed 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.