Making a Fan Smart or How to Improve the Microclimate in the Bathroom with Home Automation
A fan was chosen as the test subject.
AURAMAX OPTIMA 5
from ERA Group.
Technical characteristics of this fan:
The image below shows the appearance of the fan:
![Вентилятор Optima 5](https://habrastorage.org/webt/fx/1b/h8/fx1bh8n_4cg2p4-51odrwcgyoc0.png)
As you can see, the fan housing has a slotted area on the front side, which is ideal for installing a temperature and humidity sensor. However, the internal space is quite limited for placing the control electronics, which will need to be taken into account when designing the circuit diagram and printed circuit boards. Well, in the best DIY traditions, we will develop the control electronics ourselves.
❯ Electronics development
The core of our management system will be
ESP8266
— a budget microcontroller from the company
Espressif Systems
with a Wi-Fi interface, which allows for integration into smart home systems or autonomous operation. And since we are limited in space for placing electronics inside the fan housing, I decided to use a transformerless solution based on a high-voltage pulse voltage stabilizer as a power source
LNK306GN
and for switching the fan power circuit we will use a triac. Below is the basic diagram of our control system.
![Принципиальная схема системы управления](https://habrastorage.org/webt/at/xc/ym/atxcymokv3gp1chntyphbazadsm.png)
In this circuit, a DHT22 is used as a temperature sensor, and a piezoelectric buzzer with a built-in generator is used for sound notification of turning the fan on or off. Also in the circuit, you can see the Zero Cross sensor, which is implemented on the U2 optocoupler. This sensor was supposed to be used in the implementation of a pulse-phase control system for adjusting the fan speed, but as practice has shown, the ESP8266 did not “carry out” the developer’s “wants”. It is more expedient to implement this system on a separate low-power microcontroller such as Attiny 2313 and the like. Currently, this sensor is used in the hardware interrupt function to turn the fan on/off at the moment of crossing zero.
Oscillogram of the zero cross sensor operation
![Осциллограмма работы zero cross датчика](https://habrastorage.org/webt/wv/jg/eh/wvjgehyvmetulhjpsjh86fwapu4.png)
As I wrote earlier, the power supply is implemented on a PWM controller
LNK306GN
where the output voltage of 3.3 V is set by feedback, which is formed using resistors
R1
And
R5
. We increase the denomination
R5
respectively, the output voltage of the power supply increases. For power control of the fan, a “classic” circuit based on an optocoupler with a triac output (U3) and a power triac (Q1) is used. Below are screenshots of the layout and rendering of printed circuit boards.
Wiring:
![Разводка плат](https://habrastorage.org/webt/ff/vz/us/ffvzuswly_nnzqhg28scseba8lg.png)
Render of 3D model:
![Рендер печатных плат](https://habrastorage.org/webt/vs/at/o3/vsato31c6swqnkhz1gq4e97onrs.png)
❯ Manufacturing of printed circuit boards
It's time to make printed circuit boards. I usually make prototypes at home using my compact laser machine, using the method I wrote about
.
The photo below shows the process of photoresist activation using a 445nm laser:
![Активация фоторезиста лазером](https://habrastorage.org/webt/s7/bv/kr/s7bvkrkdoxmerkcbn2g_nmqvs10.png)
After exposing the photoresist, it is necessary to develop it in a solution of sodium hydroxide (10%) or sodium carbonate, whichever you prefer.
Payments after the development process:
![Платы после проявки](https://habrastorage.org/webt/ew/kp/ni/ewkpnixdexzohsoid-causxnoqo.png)
Next, after etching the boards, we install the radio components in accordance with the circuit diagram and then perform a test connection and debugging. To improve the dielectric characteristics of the power module, since the board operates with high voltage and to avoid breakdown, a solder mask was applied. To prevent premature annihilation of the power supply board, I recommend performing tests with a series-connected load (in my case, a 60 W incandescent lamp) in the 220 V power supply circuit. Also, do not neglect the basic rules of electrical safety when performing these works, since the power module does not have galvanic isolation from the network.
❯ Installing printed circuit boards into the fan housing
After all tests have been completed, we install the printed circuit boards of our control system into the fan housing, not forgetting to place the sensor above the special slots. The placement option is shown below
Placement of printed circuit boards on the fan housing:
![Размещение плат в корпусе вентилятора](https://habrastorage.org/webt/ai/02/q0/ai02q0lciqi7trmforvzrjanwzg.png)
❯ Firmware and interface
The device works on the basis of my firmware, which can already be called the standard for my smart devices. The development was carried out in the environment
Arduino IDE
. The firmware source code will be available at the end of the article.
The device configuration is classic – via the web interface. When initially connected, the device creates an access point CYBEREX-SmartFAN with password-free access. After connecting to the access point, the user will automatically open an authorization page where they will need to enter the default password “admin“. After logging in, you need to make all the necessary settings for the device. The interface is simple and intuitive. Below are screenshots of the interface.
Login and main page:
![Страница входа и основная](https://habrastorage.org/webt/oo/pz/wh/oopzwhzqut46b6snrn2r18x-mxe.png)
Data transfer and automatic mode configuration pages:
![Страницы конфигурации](https://habrastorage.org/webt/sj/mz/k6/sjmzk6gcge3znb_ih_ghxalevsu.png)
Wi-Fi connection configuration:
![Конфигурация Wi-Fi подключения](https://habrastorage.org/webt/v8/g1/ng/v8g1ngkqdpbxwqrsu-xr8obmaow.png)
As I wrote earlier, the device can operate both as part of the Smart Home system and in standalone mode. For integration into smart home systems, the MQTT protocol is used, where data exchange is performed in JSON format. Below is an example of the output (topic “your root name”/jsondata):
{
"c": "Off",
"temp": "29.00",
"hum": "49.70",
"a": "1",
"h_on": "65.00",
"h_off": "52.00",
"fan_level": "0.00"
}
The fan is controlled using a topic
“your root name”/control
where the passed value is:
0 - включает или отключает вентилятор в зависимости от текущего состояния;
возвращаемый статус: On или Off
1 - включает автоматический режим работы;
2 - выключает автоматический режим работы;
возвращаемый статус: 0 или 1
Below is an example of an “object card” for this fan in a smart home system.
Home Assistant
:
![Пример карточки объектов вентилятора в системеHome Assistant](https://habrastorage.org/webt/jk/g7/hx/jkg7hxbw-48av-desg8onqof-28.png)
Relative humidity chart for the bathroom:
![График относительной влажности](https://habrastorage.org/webt/wd/o5/nk/wdo5nkurg-cidxilssoapgpxz5c.png)
I would like to add that this device has a mechanism MQTT Auto Discovery allowing you to automatically add its sensors and switches to Home AssistantBelow is an example of the object card code that allows you to implement the display of sensors and controls on the Home Assistant panel:
type: entities
entities:
- entity: switch.f_onoff
name: Управление вентилятором
- entity: sensor.smart_fan_temp
name: Температура
- entity: sensor.smart_fan_hum
name: Влажность
- entity: switch.smart_fan_auto_switch
name: Автоматический режим
- entity: sensor.smart_fan_hum_on
name: Порог включения
- entity: sensor.smart_fan_hum_off
name: Порог выключения
title: Вентилятор в ванной
❯ Results & Conclusions
Let's sum it up. As you can see, we have implemented a very useful and necessary system that allows you to automate exhaust fans with a minimal budget to achieve high-quality microclimate indicators in the bathroom. As I said earlier, this system can work both autonomously and as part of a smart home, which simplifies the automation process without using IoT infrastructure. And if you compare the financial costs of implementing my DIY project described in this article with ready-made solutions, for example, with a regular fan with a built-in humidity sensor, then DIY clearly wins not only from a financial point of view, but also in terms of functionality. Below are the approximate costs of implementing this solution:
- Microcontroller ESP8266 — 1 piece: 94 rubles or $ 1.07
- Power controller LNK306GN-TL — 1 piece: 95 RUB or $ 1.09
- Temperature and humidity sensor DHT22(AM2320) — 1 piece: 98 rubles or $ 1.12
- Optocoupler with triac output MOC3052 — 1 piece: 141 RUB or $ 1.61
- Power thyristor BT136-600(TO-252) — 1 pc: 9 rub or $ 0.10
- Fan AURAMAX OPTIMA 5 — 1 piece: 890 RUB or $ 10.17
- Other components and materials: ~ 200 rubles or $ 2.29
- TOTAL : ~ 1327 RUB or $ 15.17
If we compare it with a ready-made solution, the price for a regular fan with automatic control from a built-in sensor, where there is no hint of integration with smart home systems, starts from 2939 rubles or $ 33.59. The conclusion about the economic efficiency of our DIY project is obvious.
If you liked the article, support it with the up arrow. And if you have something to add, then welcome to the comments. I wish you all creativity, kindness and thank you for your attention.
Links to the article:
Read also:
News, product reviews and contests from the Timeweb.Cloud team — in our Telegram channel ↩
News, product reviews and contests from the Timeweb.Cloud team — in our Telegram channel ↩