Dew Point Ventilation based on Zigbee with ESP32C6
This repository contains the source code for a dew point ventilator as initially described here by german MAKE magazin: Taupunktluefter. A short overview is also given below.
These instructions describe a dew point ventilation system. This system is used to measure the humidity of the air at two locations. If the air outside is drier in absolute terms than inside, a fan is switched on.
The following picture shows the components schematically:
The temperature is measured by an internal and external DHT22 sensor. The controll unit checks whether ventilation is useful and commands the socket via zigbee to turn on the fan for ventilation.
The individual components inside the control unit are described in more detail in the following image:
Check out the following 3d modelled parts:
- Case for dew point ventilation with seeed xiao esp32c6 and DHT22
- Grove Temperature Humidity Sensor DHT22 case
The code is intended to be compiled in vscode with platformio. The main programm logic can be found in the main.cpp and is calling six helping classes, which can be found in the lib folder:
- ProcessSensorData: Read the sensors, calculate the dewpoint and decide if ventilation is useful.
- ControlFan: Handle the mode selection by the user and the duration of the fan being on or off.
- ZigbeeSwitchHelper: Handles the zigbee communication with the mains socket, based on the Zigbee Arduino library.
- RTCHelper: Sets the RTC if necessary and supplies the date information for display and logging.
- SDhelper: Write data to the sd card in regular intervals
- DispHelper: Show status information on the display.
Here is also a short sketch of the main idea:
You can use PlatformIO to flash the board with this fast steps.
- Install PlatformIO or pioarduino.
- Clone this repo and open it in vscode.
- The project should be configured automatically.
- Click compile and upload -> Done
The outdoor sensor should be placed outside so that it can measure the air temperature and humidity of the outside air. A hanger is provided for this purpose.
The control unit should be mounted indoors and reach the outdoor sensor with the 3m long cable. The indoor sensor on the housing of the control unit should not be directly in the airflow of the future fan. It is better if it can measure the indoor temperature and humidity undisturbed.
The control unit is supplied with power using a cell phone power supply unit and a USB-C cable. When the power is connected, the device starts after 4s and shows information on the display.
The device always starts in automatic mode.
The device includes a switchable socket that works according to the Zigbee standard, as sold by Philips Hue or IKEA, for example.
- The inner and outer sensors are scanned alternately every two seconds. The air temperature and relative humidity are determined.
- Eight pairs of values are averaged so that decisions are based on approximately half a minute and not on individual values.
- The dew point temperature is calculated from the relative humidity and the temperature. The dew point temperature is a measure of the absolute amount of moisture in the air.
- If the answers to the following four questions are yes, ventilation makes sense - otherwise not!
- Is the temperature inside above 10°C?
- Is the temperature outside above -2°C?
- Is the dew point inside above 5°C?
- Is the dew point outside 5°C lower than inside? It only makes sense to ventilate If it is noticeably drier outside than inside!
- If the appliance is in automatic mode (“AUTO”) and ventilation makes sense (see 4.) then the fan is switched on for 15 minutes.
- As typical bathroom fans are not designed for continuous operation, the fan then switches off again for 10 minutes.
- After the 10 min break, the fan may be switched on again if ventilation makes sense.
The measured values of the sensors can be read on the display of the control unit. On the left for the indoor sensor and on the right for the outdoor sensor.
- Air temperature in °C
- Relative humidity in percent
- The dew point temperature in °C, which serves as a measure of the absolute humidity.
- Evaluation of the conditions. This indicates whether ventilation makes sense or why it does not.
The mode of the device can be switched using the small recessed button.
The device always starts in automatic mode and shows this as “AUTO” on the display.
When the button is pressed, the appliance switches to ON mode. Here the fan is always switched on for 15 minutes - is then switched off for 10 minutes and then starts again in any case.
If you press the button again and select the off mode (“OFF”), the fan will never start.
If you press the button a third time, you will return to automatic mode.
Regardless of the mode, the display always shows whether ventilation is theoretically useful.
The micro SD card can be clicked into place by pressing lightly on the right-hand side of the housing. This causes it to come out a few millimeters and can be removed.
The data on the SD card can be converted into a nice graphic using the Jupyter notebook Dewpoint-Visualization.ipynb.
The visualization shows:
- The temperature inside and outside. The limits are shown as a dotted line. (At the moment the limits are not read from the sd card, but are hard coded into the visualization.)
- The measured relative humidity.
- The calculated dew point. If the outer dew point is below the inner dewpoint, the air contains less humidity, the are between the curves is colored in light green. If the differences is above the necessary 3 K difference, the area is colored in dark green.
- The summed time how long the fan was turned on is shown in between the plot.
A new zigbee device can be coupled for 180s after a reset of the controller. To delete old couplings a zigbee factory reset can be done with a long press on the boot button on the esp32c6.
component | Approx. price |
---|---|
ESP32-C6 by Seeed Studio | 6 € |
XIAO Expansion Board | 15 € |
2x DHT22 Sensors | 20 € |
XLR socket and cable | 5 € |
SD card | 6 € |
3D print | 15 € |
Zigbee socket | 8 € |
Cell phone power supply + USB-C cable | 5 € |
CR1220 battery for RTC | <1€ |
M2 and M3 screws ... | <1€ |
total | 80 € |
Obviously, additionally required:
- Bathroom fan