Fan automation in a smart home
Today I checked the operation of the fan in the bathroom. I have it set up so that it turns on when the light is on and if the humidity rises more than 70 percent and works as long as the light is on or the humidity is not less than 70 percent. When the door is closed and the humidity is more than 70 percent, the fan runs for five minutes and then, if the humidity drops, it turns off.
Today I conducted an experiment, checked the fan operation when the door is closed, and the humidity dropped from 86 percent to 68 in 22 minutes, if the bathroom door is open, the fan is always forcibly turned off. Of course, the best way to reduce the humidity in the bathroom is to open the door, which first increases the humidity in other rooms and very quickly lowers the humidity in the bathroom. I also observed the rate of humidity drop in the bathroom, it turned out that 68 to 35 percent humidity fell in 24 minutes. I use a homemade temperature humidity sensor in the bathroom, also on this sensor is installed a light sensor that shows the illumination in the bathroom and is used in the light control scenario, and a motion sensor. Why did I make my own sensor, and do not use a ready-made one, for example, I also have a Xiaomi temperature humidity sensor installed there, I tried to put a motion sensor from Xiaomi there, but in general it turns out that it is not very convenient to control the motion sensor from Xiaomi, because the delay was more than 1 minute to trigger again and for example, if the light turns off, it doesn't see it and can't work. My sensor is made so that if there is no light and there is movement, it immediately sends a signal to the smart home and I process the event and turn on the light. When comparing two home-made and Xiaomi sensors, the difference in humidity is quite large, the Xiaomi sensor shows about 65 percent while my sensor shows 85. In the lower part, the sensors show about the same, but again Xiaomi shows a little more than my homemade sensor.
The light in my bathroom is set up to open the door, I installed a door opening sensor on the door and the light turns on when the door is opened, and turns off when the door is opened again. There are several other modes, when I have an open door, I go in and close the door behind me, and if it was turned off, it also turns on. There is also a temporary bathroom visit mode when I open the door, go in, without closing the door, take a break in the bathroom and after a while go out, at this moment when the doors are closed, the light also turns off. If the door remains open, then I process the motion sensor and if there was no movement in the bathroom for more than a minute, then the light also turns off. And of course, when the bathroom is open and there is movement in the bathroom, the light also turns on, but there is a nuance here: if you leave the bathroom and quickly check the motion sensor and respond to it, the light may turn on again, because while you leave the sensor also works. My motion sensor uses a delay of 2 seconds, which is enough time to read the value from it. but it resets the value quickly enough if there is no movement. The sensor itself is built on attiny85 and works from batteries, but while three large AA batteries are temporarily connected, and of course it works very stably, even though the batteries are no longer new, but strongly hooked up, about one battery somewhere around 1.3 volts gives out everything. If attiny is powered by CR2032 and CR2450 batteries, then when triggered, there is a strong voltage drop, I use a capacitor to smooth it out, but this is still not enough and the stability can sometimes be disturbed. To transmit the value from attiny 85, I use the 433 megahertz radio channel, a 5-volt transmitter is installed, which can work up to 3 volts quite reliably and it transmits information about temperature and humidity, traffic and light, respectively, the battery charge value is also read once a day and also transmitted to the smart home system.
A homemade receiver based on ESP 8266 is installed on the receiving side. I didn't use any libraries to transmit it.I transmit it as a 32-bit signal, and it contains information about the sensor and its value. Temperatures and humidity are transmitted by one signal, while traffic and light are transmitted by two different signals. The signal encoding itself is made simply as an integer, respectively, I encode two zanaks - this is the sensor number and the remaining seven digits to transmit the value, if you need to transmit 2 values, then I group, the first three or four digits are temperature, the second three digits are humidity, the temperature is transmitted with fractional values, with tenths, humidity is transmitted with integers by numbers. Sending is performed once every half hour, but for example, on my other sensors, I do about 50 minutes of sending so that every hour I have a value in the database or with sudden changes in values, this is if the temperature changes by half a degree or humidity by 5 percent. Also based on the attiny 85, I made a water flow meter, I used to use it on the basis of Arduino Nano, but it requires power from an outlet and in case of power loss, the meter was reset, which is not very convenient, so after a while I decided that I needed to make the sensor work on a battery, and for this I usually use attiny However, the circuit itself is of course very simple, it is a microcontroller and wires from meters are connected to it. Counters either break the signal or close the contacts with a reed switch and send a signal about once every 5 liters. In fact, this is not exactly done. One signal passes through 3 liters, the second signal passes through 7 liters, but in general I consider it 5 and write it down in the database exactly like this. The meter itself also counts locally the number of liters consumed and each time transmits to the smart home system how much water was consumed, and even if there were packet misses during transmission, then the next transmission will simply update this information and the value will be relevant. I also send a signal every 5 liters, which can be used to check for leaks or if someone forgot to turn off the water. Sometimes it happens that, for example, a button jams in the toilet tank and thus I can also determine that there is a water flow. Of course, you can transmit once a day and the battery will be saved, but in fact, calculations show that the number of transmitted packets is not so critical. For example, I have one attiny powered by a CR2450 battery, this battery has an estimated amount of energy of 650 milliamps per hour, with the current mode of operation, this sensor can work for about 4 years. The mandrel is produced on average six times an hour with a consumption of 15 cubic meters per month, this is for both hot and cold at the same time. In general, attiny is quite economical and the consumption in standby mode is quite small, it is about 4 microamperes, the consumption in transmission mode depends first of all on the transmitter itself and a total of about 15 milliamps is obtained, but since the transmission is quite fast, usually 6 packets are transmitted for the frequency of 433 MHz, which in total takes about 300 milliseconds, but when running on CR 2032 or 2450 batteries, they have limits on the maximum current and it is advisable to use no more than 6 milliamps on CR 2032, and a single current on CR 2450 no more than 9 milliamps. But I have a capacitor in parallel and it allows you to transmit the signal quite efficiently. Packets are lost this can be seen from the statistics of writing to the database, i.e. I take the number of liters transmitted, for example, 100 liters were transmitted, if I know what should be transmitted every 5 liters, that is, these are 20 transmission packets, if I do not receive them, then accordingly I can calculate the reliability of communication between the sensor and the smart home system.
Automation in a smart home should be useful and create additional comfort, but sometimes everything goes wrong… The reasons for this, and how to configure everything, see on my channel.