Do-it-yourself optical contactless light switch. Scheme for controlling light from a remote control Disadvantages and advantages of infrared sensors

The switch is controlled using a standard TV remote control. Using this remote control, you can turn the light on and off, as well as adjust the brightness of the lamp from zero to maximum in eight steps. The size of each stage depends on the settings of the control matrix (by adjusting three variable resistors).

At the moment of power supply, the switch is set to zero - off state. To turn on the lamp, you press any button on the remote control and hold it pressed until the required brightness is achieved. To turn off the light, you again need to press any button on the remote control and hold it pressed until the light goes out.

The circuit diagram of the switch is shown in the figure.

How light control works

The lighting lamp is controlled by a power regulator on the A1 chip - KR1183PM1. This microcircuit is widely known to radio amateurs. Let me remind you that it allows you to adjust the power (brightness) of a lamp up to 150W by changing the resistance between its pins 6 and 3.

At the moment of supplying power to the circuit, circuit C2-R3 sets the binary counter D1 to zero. At the outputs of inverters D2, the number code “7” is obtained. All three transistors VT1-VT3 are open and the resistance between pins 6 and 3 of A1 is minimal. For the KR1182PM1 microcircuit, this is a signal to turn off the lamp.

To turn on the lamp, you need to press any of the buttons on a standard TV remote control (not lower than RC-4). The system does not distinguish between remote control commands, it only counts the total number of pulses transmitted by it. When a remote control signal is received, pulses are generated at the output of the integrated photodetector F1, which are counted by counter D1.

The average frequency of these pulses is about 300 Hz (for different remote controls and different commands it may differ within certain limits). As a result of counting these pulses, the state of the three outputs of counter D1 indicated in the diagram changes in eight steps (from 000 to 111).

Accordingly, the combination of open and closed transistors VT1-VT3 changes, and the resulting resistance between pins 6 and 3 of A1 changes. By adjusting resistors R7, R8, R9, you can set any brightness control law and adjustment limits.

The logic circuit and the photodetector are powered from the mains via a transformerless source R1-VD1-C1-VD3-VD2-R11. The voltage is stabilized by a zener diode VD3 at 5V.

Details

Capacitor C6 must be designed for a voltage of at least 360V. All other capacitors must be designed for a voltage of at least 10V (this also applies to capacitors C4 and C5, although they are in contact with the mains, the voltage on them is low).

Electrolytic capacitors of types K50-35, K50-16 or similar imported. Capacitor C6 type K73-17, K73-24, or another, designed for operation in the electrical network. The remaining capacitors are of any type, for example, K10-7, KM, KS or imported.

The KS147A zener diode must be in a metal case. It can be replaced with another zener diode with a voltage of about 5V, and if the zener diode is in a glass case, you need to take two of them and connect them in parallel (to increase the reliability of the power system).

A metal case is preferable, as it acts as a kind of heat sink. Glass is more susceptible to failure from overheating. Or you can use some imported zener diode of higher power.

KD243D diodes can be replaced with KD209, KD105, KD247, or other medium or low power rectifiers capable of operating at a voltage of at least 300V.

The K561IE16 counter can be replaced with another CMOS counter with a weighting coefficient of the highest output not lower than 2048. For example, K561IE20. You can also use imported analogs - CD4020 (K561IE16) or CD4040 (K561IE20).

The K561LA7 chip can be replaced with any other CMOS chip that has at least three inverters. For example, K561LE5, K561LA9, K561LE10, K561LN2 or K176 series, or an imported analogue. Transistors KT503 - with any letter index. Instead of SFH506-38, you can use any similar integrated photodetector.

Permanent resistors of types S1-4, S2-24, BC, S2-33, MLT or imported analogues, in general, resistors - any, not wire-based, according to the power indicated on the diagram.

Tuned resistors R7-R9 types SP3-38, RP1-63, SPZ-19 or imported. However, the same goes for any non-wire ones.

Settings

Tuning consists of adjusting resistors R7-R9 so as to obtain the desired adjustment characteristic and adjustment limits.

Notes:

You can use any button on any remote control to control this universal switch. The button must be held down for about one and a half seconds (determined by the chain R3 and C2), after which the relay will operate. The circuit will remain on until a reset signal is received. The circuit is reset by briefly pressing any button on the remote control.

For example, to use this switch while watching TV, you can press and hold the button on the remote control. To prevent channels or operating modes from switching on the TV, use the button to select the same channel you are watching now. You can connect any load permissible in terms of voltage and current for a given relay to the contacts.

Circuit operation:

The modulated infrared pulses are received and buffered by the IR receiver module IC1, which can be replaced by a TSOP1738 chip. The output signals of IC1 are at standard TTL level. Resistor R1 maintains a high level at the output of the microcircuit in the absence of a signal. From the output of IC1, the signal is supplied to two CMOS inverters. One of them controls LED1, which indicates the operation of the switch. The second microcircuit acts as a buffer, to the output of which the timing chain R3, C2, R4 and D1 is connected. Capacitor C2 is charged through resistor R3 and discharged through R4. Diode D1 protects against rapid discharge through the low output resistance of the inverter. If the circuit uses TSOP1738, then the resistance of resistor R4 should be increased to 470 kOhm.

The time required to charge a capacitor is determined by the product of the resistance value and the capacitance of the capacitor, which is commonly called the circuit time constant (RC). In a time equal to one RC, the capacitor is charged only to 63% of the supply voltage. It takes 5.RC time to charge to 99%. In this circuit, the capacitor charging voltage must reach the switching threshold of the CMOS inverter. With a supply voltage of 5 V, the switching level of the CMOS chip is 3.6 V. The voltage on the capacitor reaches this level in 3.RC time, which is approximately one and a half seconds. When the inverter switches, it will start the pulse generator on the 555 timer.

The spice simulation results show the shape of the received pulses, the voltages on the integrating circuit and the output pulses in the following diagram:

Please note that the diagram shows only the result of a simulation and does not accurately reflect the shape of the voltages in the actual circuit.

As can be seen in the diagram, after the buffer the pulses have jagged spikes. To remove these emissions, caused by modulation of the IR carrier by the transmitted signal, a one-shot device is assembled on timer 555, the pulse duration of which is determined by components R5 and C4. The timer output signal, cleared of emissions, is fed to the D-trigger IC4, made on the TTL chip 7474. You can use any type of trigger, for example, from the Schottky 74LS74 series, high-speed 74HCT74, etc. The input signal is fed to the trigger's clock input, and feedback from the inverse output is fed to the data input, the reset and set pins must be grounded. Each pulse coming from the 555 timer throws the D-flip-flop into the opposite state, and accordingly turns on/off the executive relay. Please note that fast relay switching is not possible in this circuit. The output pulse of the timer lasts about 2.4 s, and the delay of the input pulse by the chain R3, C2 is about 1.5 s.

List of components:

220 kOhm or 470 kOhm
when using TSOP1738

IR receiver TSOP1838 or similar

SN74HCT74 or SN74LS74

12 V winding, changeover contacts

Brief summary.

Arduino + PSU + Relay + photodetector = control the light in the room from any remote control that is at hand with minimal labor and money.

Chapter 1. As an introduction.
What will be discussed below was conceived a year ago, done six months ago and has not yet been brought to its logical conclusion due to elementary laziness:
waiting for repairs in the room,
Every item must rest before use,
He who understands life is in no hurry.

So, after understanding the plan a year ago, the actual necessary components and a soldering iron were ordered. When everything arrived, in order to delay the start of work with a clear conscience and prepare thoroughly, I ordered more tin and flux. Having received them, I realized that I simply needed a “third hand” with a magnifying glass to comfortably implement my great idea. When I received this too, I remembered in time that I would need a pull-up resistor and ordered a set of resistors for all occasions. After receiving the resistors, my conscience firmly pushed me against the wall - it’s time, brother, to do the job, six months have already passed.

Everything is ready to start work


I needed:



Here I would like to warn. Do not buy kaku type, the circuit will not work. Due to poor quality food, codes will not be recognized, checked. Look for a recommended PSU, this one works great.

This concerns consumables. And I also bought:
(Heats up quickly, there is a regulator, a ceramic heater and does not slip in the hand and from the stands due to the rubber spacer placed on the middle part)
(Tinned, they work well. It’s a pity there is no tip with a groove inside)
(I really liked it when soldering)
(Works well and, finally, almost the same smell of rosin from childhood)
(I checked a couple of dozens selectively - the deviation from the nominal value is no more than 2%)
(Great soldering help!)
P.S. I bought all this, except for the correct power supply, from these very sellers, but a year ago and at completely different prices.


Chapter 2. Implementation.
The material I offer is based on two powerful philosophical principles: Laziness is the engine of progress and “Occam’s Razor,” which roughly translates to “do not multiply the essence beyond what is necessary” or, translated into folklore, “the simpler the better.” Having laid such a powerful scientific foundation, I will begin my story.

Looking at various crafts like “Smart Home”, I was surprised to discover that the most useful (and simply necessary!) solution for me, a true lazy follower of progress, does not exist. All proposed solutions, alas, contradict one of the above principles or both at once.

So, we will talk about turning on and off the lights in the room using the remote control. Wait a minute to raise a cry - “Like, there are as many such decisions as you want.” Now I will explain why I was not satisfied with any of them.

The solution to buying a switch with a radio channel and a special remote control is simply ridiculous. Sometimes I can’t find a normal remote control here, and this one, the miliped one, gets lost instantly. Mounting a backup switch on the wall with a radio channel for the main one did not work due to the presence of carpet on the wall and the second philosophical principle.

That's why first task for me it will sound like this - the light should be controlled from ANY existing remote control that is at hand (from a TV, receiver, air conditioner, etc.). There are always remote controls and AT LEAST ONE OF THEM is at hand.

Task two- a regular switch should remain in place and perform its functions in exactly the same way as before, since when we enter a dark room, we do not yet have a remote control in our hands. I don’t want to install capacitive and other gadgets, let the switch remain as it was, I’m used to this. In the end, it is the fulfillment of both fundamental principles and basic economy.

The tasks have been set. Let's decide.
For those who didn’t open the first spoiler, I’ll repeat it.
We will need:
1. IRDA receiver;
2. Brain (Arduino Nano);
3. Actuator (Relay);
4. Power supply for all of the above.

Due to their size, all modules will fit in the switch box (if there is not enough space, we will hollow out as many more as needed in the wall, straightening the box). There was one ambush here - in the switch box I did not have a “neutral” wire to power the power supply (this happens :)). But, since the room is still awaiting renovation, it doesn’t matter, the necessary wire will be installed in due time (a reinforced concrete argument for conscience!). I did not make a hole for the phototransistor in the switch, since I chose the right switch, which has a neon inside. Accordingly, there is a window with an orange piece of glass. Opposite this window, I glued a phototransistor from the inside. You can also output an LED from the relay there, which will completely replace the functionality of the neon light, which I threw out as unnecessary.

The operating logic will be as follows: clicking the switch will lead to an inversion of the state of the lamp in the chandelier. Those. if the lamp was turned off, it will turn on and vice versa. Pressing the programmed button on one of the available remotes will also invert the lamp state. The fact that now the position of the switch key does not depend on the lighting state does not bother me; I never remember these positions anyway. What is important is that if there is a sudden power outage, then when it resumes, the switch will be in a guaranteed off state, because The Arduino will reset and initialize when power is applied.

Let's start assembling the diagram. Now the switch will supply only one or zero to the digital input of the Arduino, and the relay will perform its own power phase switching. We will connect a card with a phototransistor to the other input of the Arduino.
We write an intermediate sketch to determine the codes of the required remote control buttons, press the selected button on each remote control, get the codes and write these codes into the final sketch.

Having assembled the circuit, we make sure that it is operational, insulate all the components (heat shrink, epoxy, blue electrical tape... (underline as appropriate)) and place it all in the switch box.

Photos, sketches, diagram, video

Let's assemble a temporary structure on a breadboard to read codes from remote controls and debug the final sketch. There is no point in drawing a diagram for connecting a computer to Arduino because of the huge variety of USB_to_COM adapters; everyone will find their own version on the Internet. And connecting the photodetector to the same legs as in the diagram below.


There is no switch in this circuit yet, but it is not needed now. We write a sketch, upload it and catch the button codes from different remote controls. I selected the RECORD button, which I do not use, everywhere. It is she who will control the light from each of the remote controls.

We catch the result in our virtual Com port.


Yes, there are codes. Now let’s write the final sketch, upload it to Arduino, remove the now unnecessary USB_to_COM adapter and add a switch to the circuit. It should be clarified here that in one of its positions the switch will supply 5V to leg No. 2 of the Arduino. But in order not to catch a false signal, you need to use a pull-up resistor. The theory tells us that this is implemented in the Arduino itself and in the sketch I give the command to turn it on, but I played it safe and added a real 10k resistor, it won’t be worse, and I’m calmer. And I also removed the phototransistor from his scarf and extended his legs with wires, since the scarf did not fit into the place of the torn neon, but one phototransistor fit perfectly. I grabbed it with superglue.


And here is the diagram of this farm, where Grd is land:

And this is the final sketch for 4 of my remote controls:


And this is what a switch with a window for a neon looks like.

As you can see, the window is built into the movable part of the switch, namely the key, and the phototransistor is fixedly fixed to the frame. However, this does not in any way affect the stability of the circuit in operation.
And finally, a video of the circuit in action:


In the video, the operation of the circuit can be determined by the LED on the relay turning on. I did not connect the lamp to the relay, because... I checked earlier that these relays handle 300 watts just fine. I've been using them for many years and they have proven themselves to be excellent.
In conclusion, I would like to note that the remote controls work reliably from any distance in the room. There is no point in tightly soldering the Arduino, because... the filling will be motionless in the wall - i.e. no vibrations. But remote controls don't last forever. Some may change, new ones may be added. Therefore, I leave the opportunity to correct the sketch code, connect the laptop to the Arduino and upload the code in a new way. And yet, in the video the LED is not desoldered from the relay, but in general it can be desoldered, the legs extended and glued together with a phototransistor to imitate a neon. But I’m not yet sure that I want another indicator to glow at night, and the remote control beam will find the switch even without backlighting.

Chapter 3. Ready!
Now, before going to bed, after turning off the TV, I don’t need to get out from under the blanket and go turn off the light, but just press the magic button on the same remote control. It’s much more pleasant to get up for work in the morning by turning on the lights from the remote control, rather than wandering in the dark to the switch, risking stepping on something.

This is how my story should have ended, but everything is still on the shelf. Because now I'm waiting for repairs. With an absolutely clear conscience.

P.S. I may have all this lying around for who knows how long, but I didn’t wait for repairs, but decided to publish the material now. In case someone gets interested...

I'm planning to buy +89 Add to favorites I liked the review +72 +162

The proposed device is designed to turn on and off (including remotely) incandescent lamps, heaters and other devices powered from a 220 V household network and representing a purely active load with a power of up to 500 W. The circuit diagram of the switch is shown in Fig. 1.

An alternating voltage of 220 V is supplied through fuse FU1 to a power unit assembled from elements VD3, VD4, SZ, C5, C7, R7 and R9. A stabilized voltage of 5 V from capacitor C5 powers the microcontroller DD1 and photodetector B1. The microcontroller, operating according to a program recorded in it, analyzes the signals coming from the photodetector to input RB5 and from the SB1 button to input RB1, as well as from the zero-phase mains voltage sensor (resistor R6, diodes VD1, VD2) to input RA1. The microcontroller controls the triac VS1 and the LED HL1 with the signals generated at the outputs RB0 and RB4, respectively. The switch changes its state to the opposite each time you press the SB1 button or the remote control button. Two program options are offered. Working according to the first of them (file irs_v110.hex), the microcontroller remembers the current state of the switch and, in the event of a temporary shutdown of the mains voltage, restores this state when its supply is restored. When using the second version of the program (file irs_v111.hex), restoration of voltage in the network always switches the switch to the off state. The HL1 LED lights up when the load circuit is open. This is convenient when controlling lighting fixtures. The diagram of the switch remote control is shown in Fig. 2.

It is powered by two AAA size galvanic cells. When you press the SB1 button, a pulse generator with a duration of about 18 ms, assembled on logic elements DD1.1 and DD1.2, starts working. These pulses control a pulse generator with a frequency of 36 kHz on elements DD1.3, DD1.4. Packs of pulses from the output of this generator are supplied to the gate of transistor VT1, in the drain circuit of which an IR emitting diode VD1 is connected. Setting up the remote control comes down to setting the generator on elements DD1.3, DD1.4 to a frequency of 36 kHz (the resonant frequency of the photodetector B1 in the switch) by selecting resistor R4. When properly configured, the maximum range of the remote control of the circuit breaker is achieved. The printed circuit board of the switch is shown in Fig. 3.

The VT137-600 triac is installed on a heat sink made of an aluminum plate with dimensions of 65x15x1 mm. A replacement for this triac can be selected from among similar devices of the VT136, VT138 series. The BZV85C5V6 zener diode is replaced by another small-sized one with a stabilization voltage of 5.6 V, for example KS156G. Instead of the TSOP1736 photodetector, another one used in remote control systems for televisions and other household electronic devices will be suitable. The central frequency of the passband of such a photodetector can lie in the range of 30...56 kHz, so the remote control will have to be adjusted to this frequency. If it is necessary to expand the sensitivity zone of the switch in the horizontal plane, instead of one photodetector, you can install two, pointing them in different directions. In this case, pins 1 and 2 of the two photodetectors are connected directly in parallel, and pin 3 is connected through resistors with a nominal value of 1 kOhm. The common point of the resistors is connected to pin 3 of block X1, and resistor R3 in the switch is replaced with a jumper. The printed circuit board of the remote control is made according to the drawing shown in Fig. 4.

Here, any IR emitting diode from the remote control of a household electrical appliance can be used as VD1. It is not advisable to replace the HEF4011 chip with a similar domestic K561LA7. When the supply voltage is low, it operates unstable. In Fig. Figure 5 shows the appearance of the switch and remote control boards.

Radio No. 5, 2009

List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
Switch diagram
DD1 MK PIC 8-bit

PIC16F628A

1 To notepad
VD1, VD2 Diode

KD522B

2 To notepad
VD3 Rectifier diode

1N4007

1 To notepad
VD4 Zener diode

BZV85-C5V6

1 KS156G To notepad
VS1 Triac

BT137-600

1 To notepad
C1 47 µF 10 V1 To notepad
C2 Capacitor0.022 µF1 To notepad
C3 Capacitor0.1 µF1 To notepad
C4, C6 Capacitor22 pF2 To notepad
C5 Electrolytic capacitor470 µF 16 V1 To notepad
C7 Capacitor0.47 µF 630 V1 To notepad
R1, R5 Resistor

10 kOhm

2 To notepad
R2 Resistor

220 Ohm

1 To notepad
R3 Resistor

1 kOhm

1 To notepad
R4, R8 Resistor

100 Ohm

2 To notepad
R6 Resistor

4.7 MOhm

1 0.5 W To notepad
R7 Resistor

47 Ohm

1 1 W To notepad
R9 Resistor

300 kOhm

1 0.5 W To notepad
IN 1 PhotodetectorTSOP17361 To notepad
HL1 Light-emitting diode

AL307BM

1 To notepad
ZQ1 Quartz4 MHz1 To notepad
FU1 Fuse5 A1 To notepad
SB1 Button 1 To notepad
X1 Connector 1 To notepad
X2 Connector 1 To notepad
Circuit breaker remote control diagram
DD1 ChipHEF40111 To notepad
VT1 Field-effect transistorKP505A1 To notepad
C1 Electrolytic capacitor100 µF 6.3 V1 To notepad
C2 Capacitor0.047 µF1 To notepad
C3 Capacitor47 pF1