A custom ESPHome component that calculates dew point from existing temperature and humidity sensors using the Magnus formula.
- 🌡️ Accurate dew point calculation using the Magnus formula
- ⚡ Real-time updates when temperature or humidity changes
- 📊 Integrated as a native ESPHome sensor
- 🔧 Simple YAML configuration
- 🎯 Low memory footprint
- 📈 Proper logging and debugging support
- Create a
dew_pointfolder in your ESPHomecustom_componentsdirectory - Copy
dew_point.hand__init__.pyto that folder
Your structure should look like:
config/
└── esphome/
└── custom_components/
└── dew_point/
├── __init__.py
└── dew_point.h
Once published to GitHub, you can use:
external_components:
- source: github://iret33/esphome-dew-point
components: [ dew_point ]sensor:
# Your existing temperature sensor
- platform: dht
pin: GPIO5
temperature:
id: room_temperature
name: "Room Temperature"
humidity:
id: room_humidity
name: "Room Humidity"
update_interval: 60s
# Dew point calculation
- platform: dew_point
name: "Room Dew Point"
temperature: room_temperature
humidity: room_humiditysensor:
# BME280 sensor example
- platform: bme280
temperature:
id: outdoor_temp
name: "Outdoor Temperature"
humidity:
id: outdoor_humidity
name: "Outdoor Humidity"
pressure:
name: "Outdoor Pressure"
address: 0x76
update_interval: 30s
# Multiple dew point sensors
- platform: dht
pin: GPIO4
temperature:
id: indoor_temp
name: "Indoor Temperature"
humidity:
id: indoor_humidity
name: "Indoor Humidity"
# Outdoor dew point
- platform: dew_point
name: "Outdoor Dew Point"
id: outdoor_dew_point
temperature: outdoor_temp
humidity: outdoor_humidity
accuracy_decimals: 1
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 1
# Indoor dew point
- platform: dew_point
name: "Indoor Dew Point"
id: indoor_dew_point
temperature: indoor_temp
humidity: indoor_humidityesphome:
name: weather-station
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
level: DEBUG
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
sensor:
# Temperature and Humidity sensor
- platform: dht22
pin: GPIO5
temperature:
id: temp_sensor
name: "DHT22 Temperature"
filters:
- offset: -0.5 # Calibration offset
humidity:
id: humidity_sensor
name: "DHT22 Humidity"
update_interval: 60s
# Dew Point calculation
- platform: dew_point
name: "DHT22 Dew Point"
temperature: temp_sensor
humidity: humidity_sensor
icon: "mdi:water-thermometer"
# WiFi Signal Strength
- platform: wifi_signal
name: "Weather Station WiFi Signal"
update_interval: 60s- temperature (Required, ID): The ID of the temperature sensor (must be in Celsius)
- humidity (Required, ID): The ID of the humidity sensor (must be in percentage 0-100)
- name (Required, string): The name of the dew point sensor
- id (Optional, ID): Manually specify the ID for code generation
- accuracy_decimals (Optional, int): Decimal places for the sensor value. Defaults to 1
- filters (Optional): Standard ESPHome sensor filters
- icon (Optional, string): Custom icon. Defaults to temperature icon
- unit_of_measurement (Optional, string): Unit symbol. Defaults to "°C"
The component uses the Magnus formula to calculate dew point:
Td = (b × α) / (a - α)
where:
α = ln(RH/100) + (a × T) / (b + T)
a = 17.27
b = 237.7 °C
T = temperature in °C
RH = relative humidity in %
This formula provides accuracy within ±0.4°C for:
- Temperature range: -40°C to 50°C
- Humidity range: 1% to 100%
# Prevent condensation
binary_sensor:
- platform: template
name: "Condensation Risk"
lambda: |-
float dew_point = id(outdoor_dew_point).state;
float wall_temp = id(wall_temperature).state;
return (wall_temp < dew_point + 2.0);# Comfort level indicator
text_sensor:
- platform: template
name: "Comfort Level"
lambda: |-
float dew_point = id(indoor_dew_point).state;
if (dew_point < 10) return {"Dry"};
else if (dew_point < 13) return {"Comfortable"};
else if (dew_point < 16) return {"Slightly Humid"};
else if (dew_point < 18) return {"Humid"};
else if (dew_point < 21) return {"Very Humid"};
else return {"Oppressive"};# Mold risk detection
binary_sensor:
- platform: template
name: "Mold Risk"
lambda: |-
float dew_point = id(basement_dew_point).state;
return (dew_point > 15.0); # High mold risk above 15°C dew point# Turn on dehumidifier when dew point is too high
switch:
- platform: gpio
pin: GPIO12
id: dehumidifier
name: "Dehumidifier"
automation:
- platform: numeric_state
entity_id: sensor.basement_dew_point
above: 16.0
then:
- switch.turn_on: dehumidifier
- platform: numeric_state
entity_id: sensor.basement_dew_point
below: 13.0
then:
- switch.turn_off: dehumidifierCause: Temperature or humidity sensor not providing valid data
Solution:
- Check that source sensors have valid IDs
- Verify sensors are updating and providing numeric values
- Check ESPHome logs for warnings
Cause: Temperature not in Celsius or humidity not in percentage
Solution:
- Ensure temperature sensor outputs Celsius (not Fahrenheit)
- Verify humidity is 0-100% (not 0.0-1.0)
- Check for sensor calibration issues
Cause: Component not in correct location
Solution:
- Verify
custom_components/dew_point/exists - Check both
__init__.pyanddew_point.hare present - Restart ESPHome dashboard
Cause: Too frequent updates
Solution:
- Increase
update_intervalon source sensors - Add filters like
throttleordelta
Enable debug logging:
logger:
level: DEBUG
logs:
dew_point: DEBUGThis will show:
- Calculated dew point values
- Temperature and humidity inputs
- Any warnings or errors
- Memory: ~100 bytes RAM
- CPU: Minimal (only calculates on sensor updates)
- Accuracy: ±0.4°C (within valid range)
- Update latency: Instant (triggered by source sensor)
- ✅ Faster (no YAML parsing)
- ✅ More efficient (compiled C++)
- ✅ Better error handling
- ✅ Native logging
- ✅ Calculated on ESP device
- ✅ No network dependency
- ✅ Works even if HA is down
- ✅ Reduces HA load
If you prefer to calculate dew point in Home Assistant instead of on the ESP device, check out the companion project:
Dew Point Calculator for Home Assistant - A Home Assistant custom integration with UI-based configuration.
| Feature | ESPHome Component | Home Assistant Integration |
|---|---|---|
| Calculation Location | On ESP device | In Home Assistant |
| Configuration | YAML | UI-based |
| Works offline | Yes | Requires HA running |
| Network dependency | None | Requires network |
| Resource usage | ~100 bytes on ESP | Uses HA resources |
| Best for | Edge computing, standalone devices | Centralized setup, non-ESPHome sensors |
| Sensor sources | ESPHome sensors only | Any HA sensor |
Choose ESPHome Component when:
- You want calculations done locally on the device
- You need the dew point even when Home Assistant is down
- You're building a standalone weather station
- You want to reduce Home Assistant load
Choose Home Assistant Integration when:
- Your sensors aren't ESPHome devices (Zigbee, Z-Wave, etc.)
- You prefer UI-based configuration
- You want centralized management of all dew point calculations
Contributions are welcome! Please:
- Follow ESPHome coding standards
- Test thoroughly before submitting
- Update documentation for new features
- Add examples for new use cases
MIT License - See LICENSE file
- GitHub Issues: Report bugs or request features
- ESPHome Discord: Get help from the community
- Home Assistant Forum: Discuss use cases
Made with ❤️ for the ESPHome community