⬆️ ⬇️

Detector presence of a person in the toilet

I love it when the lights turn on automatically, so I try to automate it wherever possible. In the corridor, this is done elementarily - with a motion sensor. In the pantry, you can simply turn on the light when the door is open.



How to do it in the toilet? When a person is sitting on the toilet, there is no particular movement, the light will go out, and the door is usually closed behind itself. I was faced with the task of creating a device that would determine that a person was sitting on the toilet, or that someone else was in the toilet.



The decision was quite obvious - optocouplers. You can hang infrared LEDs on one side of the toilet, and a photodiode (s) on the other. True, the last ones I did not have in stock, but a whole bunch of TSOP 1736 DU receivers were lying around, which I don’t use anywhere else. It is quite simple to use these receivers, they have only three outputs: ground, power and output. If you apply power to it, the output will be 5 volts, but if at the same time somewhere near the infrared LED flashes at a frequency of 36 kHz, then the output will be zero.



The task has been reduced to the following: to blink LEDs in turn, to check whether the remote control receiver sees the signal, and if it does not see (something blocked it), then turn on the light through the relay. It remained to assemble a device that will do all this. I quickly sketched a fee:

')

image



Everything is quite simple. Used ATMEGA8 microcontroller. On the right is the connector for connecting the programmer (the network and the ability to remotely update the firmware are not needed here, perhaps). Top contacts for connecting the remote control receiver and IR LEDs. On the left, the clamps are 220 volt in and out on the lamp. Just to the right of the relay, which is turned on through the transistor, do not forget to plug a diode into the return line. Just to the right of the center are three LEDs for easy debugging. I decided to use the power supply ready, broke for the charge of Nokia.



The result was such a device:



image



However, the hardest was ahead. Firstly, the LEDs had to be correctly positioned so that the lines between them and the remote control receiver passed exactly where the person is usually located. There were no questions with a sitting position, but I never had to think before - at what point am I standing when I wrote? It's like a joke about a professor and a beard - until you think about it, it's simple. I had to carry out several experiments, writing without moving the LEDs without thinking , as a result the perfect combination was found:



image



In this situation, no matter how I get up, one of the rays always intersects, and in the sitting position all three intersect.



The second problem was that the LEDs are very bright, if you can say so about infrared light, and the tile on the walls reflects the rays well. As a result, the DU-receiver saw the signal, even if you close the LEDs with your palm. It was necessary to lower their brightness, with what is individual and desirable without changing the scheme, i.e. programmatically. Alas, it is problematic to reduce the current in this way, but it turned out that the blinking ratio has a strong effect on the range.



image



Above - a normal signal when the LED flashes 36,000 times per second, and from below a signal that the remote control will register only from a closer distance. In this case, the frequency remains the same - 36 kHz, but the time during which the LED is lit becomes less.



Experimentally, the ideal values ​​for each of the LEDs were selected. I felt in a very stupid situation, sitting with a laptop and programmer in the toilet. As a result, everything works in such a way that the smallest object is enough to completely block each of the rays, but there are no false positives. The light turns off after only 15 seconds. In case something suddenly goes wrong, the light will not burn for more than 15 minutes. Reason not to stay there.



All wires neatly hid in the box:



image



image



So there was another little convenience in the house. Buy another Japanese toilet, and there will be complete harmony :)



upd: Comments show that the choice of technology strongly depends on individual requirements: some have cats, others do not, some open the door to the outside, others inside. Someone has children. Someone is sitting in the toilet without moving for 15 minutes. Well, someone pees while sitting, in the end :) I chose a method that I was most interested in implementing.

The post was perceived much more seriously than I expected. I wrote it with a considerable amount of humor - with a serious look to talk about some kind of nonsense.

Source: https://habr.com/ru/post/191092/



All Articles