About this project
TaupunktLueftung is an ESP32-based system for intelligent ventilation control based on dew point difference. It is ideal for targeted drying of humid rooms such as basements, laundry rooms, or storage areas – efficient and fully automatic.
The system measures temperature and humidity indoors and outdoors (via sensors like SHT31 or DHT22 – or via MQTT), calculates the dew points, and activates ventilation only when drying conditions exist – that is, when the outside air is capable of absorbing moisture rather than introducing it. In humidity control mode, it attempts to maintain a desired humidity level by dehumidifying or humidifying.
Ventilation is switched via a relay – optimally in a setup with two fans: one pulls dry air in, the other exhausts humid air. This creates an effective airflow for targeted dehumidification.
## Features
- Dew point controlled ventilation for targeted dehumidification – a dew point analysis algorithm controls ventilation based on the difference.
- WiFi credentials are configured via the access point (`TaupunktLueftung-Setup`) in the browser and stored permanently. No manual editing in `secrets.h` needed.
- Web interface with live data display, real-time charts (hourly, daily, and monthly views), and configuration area.
- **Light/Dark design (Light/Dark/System)**, switchable via dropdown – the choice is saved in the browser.
- **Login protection (HTTP Basic Auth)** for the entire web interface, username and password changeable during operation.
- Optional temperature protection against overcooling.
- Optional dryness protection against too low humidity.
- Optional humidity control mode to maintain a desired humidity level.
- **Fail-safe on sensor failure**: If a sensor error persists, ventilation automatically switches off as a safety measure instead of running indefinitely in the last state.
- Adjustable delay times for fan/relay protection in boundary areas.
- MQTT interface (publish & subscribe) + Home Assistant auto-discovery.
- Modular: selectable sensor source (hardware or MQTT data), switchable directly in the "Sensor source" area.
- Firmware backup: current running firmware can be saved as a `.bin` before an update.
- WiFi credentials can be reset via a button in the web interface without losing other settings.
- Supports over-the-air (OTA) firmware updates. After initial flashing via USB from the Arduino IDE, customized firmware variants can be updated via OTA from the Arduino IDE, or uploaded from a firmware file via the web interface.
- Performance optimizations (since v4.2): CSS/JavaScript are cached by the browser instead of being reloaded from the ESP32 on every page visit; a WiFi fix keeps modem sleep mode permanently disabled (prevents noticeable delays after WiFi reconnections); MQTT reconnect attempts are throttled so an unreachable broker does not block the web interface.
## Required Components and Setup
### Hardware Components
| Component | Description | Approx. Price (EUR) |
| --- | --- | --- |
| **ESP32 Dev Board** (e.g., DOIT) | Microcontroller with WiFi | 6–10 EUR |
| **SHT31 Sensor (indoor, optionally outdoor)** | Temperature & humidity, I2C, high accuracy | 5–8 EUR each |
| **DHT22 Sensor (outdoor, alternative)** | Temperature & humidity, digital single-wire, cheaper | 3–5 EUR |
| **LEDs (3x)** + resistors (220–470 ohm) | Status indicators: green, yellow, red | 1–2 EUR |
| **Relay module (1 channel)** | For controlling ventilation | 2–4 EUR |
| **Jumper wires / breadboard** | For setup and testing | 2–5 EUR |
| **Enclosure (optional)** | Protection for ESP32 and wiring | 3–8 EUR |
**Total cost:** approx. **20–30 EUR**, depending on configuration and source.
### Setup and Wiring
**ESP32 pinout:**
| ESP32 Pin | Function | Connected to |
| --- | --- | --- |
| GPIO17 | DHT22 data line | DHT22 (with 10 kohm pull-up) to GND – only for DHT22 variant |
| GPIO16 | Relay | Relay IN |
| GPIO2 | Green LED | Resistor + LED |
| GPIO18 | Red LED | Resistor + LED |
| GPIO19 | Yellow LED | Resistor + LED |
| GPIO21 | SDA (I2C data) | SHT31 indoor **and** SHT31 outdoor (shared bus) |
| GPIO22 | SCL (I2C clock) | SHT31 indoor **and** SHT31 outdoor (shared bus) |
| 3.3V/GND | Power supply | All components |
### Simplified ASCII Schematic
```
+----------------------------+
| ESP32 Dev |
| |
| GPIO17 --> DHT22 data | (only DHT22 variant)
| GPIO16 --> Relay IN |
| GPIO2 --> Green LED |
| GPIO18 --> Red LED |
| GPIO19 --> Yellow LED |
| GPIO21 --> SDA (SHT31) |
| GPIO22 --> SCL (SHT31) |
+-------------+--------------+
| 3.3V / GND
```
LEDs: Anode (long pin) → resistor → GPIO / Cathode (short pin) → GND
### Outdoor Sensor Selection
This project supports two sensor types for the outdoor sensor:
- **SHT31 (recommended)** – digital I2C sensor, significantly more accurate and stable than the DHT22 (typically ±2% RH vs ±2–5% RH for DHT22), responds faster to changes, provides reliable values even at low temperatures, and uses I2C which is a more robust, less interference-prone transmission protocol than the proprietary single-wire timing of the DHT22. For control based on small dew point differences, higher sensor accuracy directly impacts the quality of ventilation decisions.
- **DHT22** – cheaper, less accurate, but simpler 3-wire wiring without I2C addressing.
**Special note for two SHT31 sensors:** Since both indoor and optional outdoor SHT31 use I2C, both sensors can operate on the **shared bus** (SDA = GPIO21, SCL = GPIO22) – no additional data lines needed. To allow the ESP32 to distinguish between the two sensors, the SHT31 has an `AD`/`ADR` pin for address selection:
| Sensor | ADDR/AD pin | Resulting I2C address |
| --- | --- | --- |
| SHT31 indoor | open or to GND | `0x44` (default) |
| SHT31 outdoor | tied to **3.3V** | `0x45` |
*(Some SHT31 modules have an additional `AL`/`ALR` pin – this is an alarm/interrupt output and has nothing to do with address selection; leave it unconnected.)*
**Setting the outdoor sensor type:** Unlike the indoor/outdoor mode (hardware or MQTT), which can be set in the web interface, the choice between SHT31 and DHT22 for the outdoor sensor is intentionally a **compile-time decision** directly in the source code – this way only the actually needed sensor library is included during compilation, saving flash memory and avoiding unnecessary I2C communication with a possibly non-existent second sensor.
To change the sensor type:
1. Open `TaupunktLueftung.ino`.
2. Find the line `//#define SENSOR_TYP_AUSSEN_SHT31`.
3. For **SHT31 outdoor** (default in repository): keep the line active (not commented out).
4. For **DHT22 outdoor**: add the comment marker `//` back at the beginning and ensure the DHT22 is connected to pin 17.
**Pre-built firmware variants without compiling yourself:** Each [release](https://github.com/mallewski/TaupunktLueftung/releases) on GitHub automatically contains **two ready-made `.bin` files** – `TaupunktLueftung_dht22.bin` and `TaupunktLueftung_sht31.bin`. Simply choose the file matching your hardware during OTA update in the web interface, no Arduino IDE installation needed.
### Notes
- **Relay module:** Can be used to switch a 230V ventilation fan. **Caution:** Mains voltage should only be connected by qualified personnel.
- **MQTT:** To receive external sensor data, an MQTT broker is required (e.g., Mosquitto or Home Assistant). Auto-discovery is supported (Home Assistant compatible).
- **Web interface:** All settings such as MQTT, sensor sources, and thresholds are directly configurable via the browser interface, protected by a login (username/password).
- **Default credentials after first flash:** Username `admin`, password from `secrets.h` (`CONFIG_PASSWORD`) for self-compiled firmware, or [...] Both can be changed later in the web interface under Settings → Access (Login).
### Fan Recommendation
100–150 m³/h for small basement rooms. A WiFi smart plug integrated via a smart home system (like Home Assistant) can also be used.
### Power Supply and Decoupling
Place 3.3V to GND as close as possible to the power pins, most effectively as a combination of two capacitors in parallel: an **electrolytic capacitor (470–1000 µF)** for short voltage dips, plus a **ceramic capacitor (100 nF)** for short, high-frequency noise spikes – the electrolytic alone does not adequately handle high-frequency components.
### Home Assistant Integration (MQTT)
Existing Home Assistant sensors can be fed as a sensor source via automation (see [Guide: HA sensors via MQTT](https://github.com/mallewski/TaupunktLueftung/blob/main/docs/Anleitung_HA_Sensoren_via_MQTT.md)).
If you like this project or find it useful, you can buy me a coffee.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.