- ESPHome installed (version 2023.1.0 or higher)
- Existing temperature and humidity sensors configured
- Basic understanding of ESPHome YAML configuration
This method is best for local development and testing.
In your ESPHome configuration directory, create the custom components folder:
# Navigate to your ESPHome config directory
cd /config/esphome/
# Create the custom components directory structure
mkdir -p custom_components/dew_pointYour directory structure should look like:
/config/esphome/
├── custom_components/
│ └── dew_point/
│ ├── __init__.py
│ └── dew_point.h
├── secrets.yaml
└── your-device.yaml
Copy the two required files to the custom_components/dew_point/ directory:
__init__.py- Python configuration filedew_point.h- C++ header with calculation logic
Edit your device YAML file (e.g., weather-station.yaml):
esphome:
name: weather-station
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
level: DEBUG # Enable debug for testing
api:
ota:
sensor:
# Your existing temperature sensor
- platform: dht22
pin: GPIO5
temperature:
id: my_temperature
name: "Temperature"
humidity:
id: my_humidity
name: "Humidity"
update_interval: 60s
# Add dew point sensor
- platform: dew_point
name: "Dew Point"
temperature: my_temperature
humidity: my_humidity# Validate configuration
esphome config weather-station.yaml
# Compile and upload
esphome run weather-station.yamlOnce the component is published to GitHub, this is the easiest method.
Add to your device YAML:
external_components:
- source: github://iret33/esphome-dew-point
components: [ dew_point ]
refresh: 1h # Check for updates every hoursensor:
- platform: dht22
pin: GPIO5
temperature:
id: temp
name: "Temperature"
humidity:
id: hum
name: "Humidity"
- platform: dew_point
name: "Dew Point"
temperature: temp
humidity: humESPHome will automatically download the component from GitHub:
esphome run weather-station.yamlFor development or when you want version control without GitHub.
# Create a local repository
mkdir ~/esphome-dew-point
cd ~/esphome-dew-point
git init
# Create component structure
mkdir -p components/dew_point
cp __init__.py components/dew_point/
cp dew_point.h components/dew_point/
# Commit
git add .
git commit -m "Initial commit"external_components:
- source:
type: local
path: /path/to/esphome-dew-point
components: [ dew_point ]After uploading, monitor the logs:
esphome logs weather-station.yamlYou should see:
[C][dew_point:XXX]: Dew Point Sensor:
[C][dew_point:XXX]: Dew Point 'Dew Point'
[C][dew_point:XXX]: Temperature Source: 'Temperature'
[C][dew_point:XXX]: Humidity Source: 'Humidity'
If connected to Home Assistant, check:
- Go to Developer Tools → States
- Look for
sensor.weather_station_dew_point - Verify it shows a numeric value
Change temperature or humidity and watch the dew point update in real-time.
Error: Component dew_point not found
Solutions:
-
Verify directory structure:
ls -la custom_components/dew_point/ # Should show: __init__.py and dew_point.h -
Check file permissions:
chmod 644 custom_components/dew_point/* -
Restart ESPHome dashboard
Error: 'log' is not a member of 'std'
Solution: The component uses <cmath>. This is included in dew_point.h. If you still get errors, check your ESPHome version:
esphome versionUpdate if needed:
pip install -U esphomeIssue: Dew point sensor shows NaN or no value
Causes and Solutions:
-
Source sensors not ready
- Wait 1-2 minutes after boot
- Check source sensors are updating
-
Invalid sensor IDs
# Incorrect - platform: dew_point temperature: temperature # Wrong! # Correct - platform: dew_point temperature: my_temperature # Use the sensor ID
-
Temperature not in Celsius
- Component expects Celsius
- Add conversion filter if needed:
temperature: id: my_temp filters: - multiply: 0.5556 # If Fahrenheit, convert - offset: -32
Issue: Dew point doesn't update when temperature/humidity changes
Solutions:
-
Check update intervals match
sensor: - platform: dht22 update_interval: 60s # Same as dew_point
-
Enable debug logging
logger: level: DEBUG logs: dew_point: VERBOSE
-
Verify sensor state changes
[D][dew_point:XXX]: Calculated dew point: 12.3°C (T: 20.5°C, RH: 65.0%)
Issue: ESP8266 running out of memory
Solutions:
-
Reduce logging
logger: level: WARN
-
Disable unnecessary components
-
Use ESP32 instead
- More RAM available
- Better for complex setups
Issue: Dew point seems wrong
Verification:
- Check temperature is in Celsius
- Verify humidity is 0-100%
- Compare with online calculator
- Check sensor calibration
Common Issues:
- Humidity sensor returning 0.65 instead of 65% → multiply by 100
- Temperature in Fahrenheit → convert to Celsius
- Sensor placement → ensure sensors are in same location
sensor:
# Room 1
- platform: dht22
pin: GPIO5
temperature:
id: room1_temp
name: "Room 1 Temp"
humidity:
id: room1_hum
name: "Room 1 Humidity"
- platform: dew_point
name: "Room 1 Dew Point"
temperature: room1_temp
humidity: room1_hum
# Room 2
- platform: dht22
pin: GPIO4
temperature:
id: room2_temp
name: "Room 2 Temp"
humidity:
id: room2_hum
name: "Room 2 Humidity"
- platform: dew_point
name: "Room 2 Dew Point"
temperature: room2_temp
humidity: room2_humsensor:
- platform: dew_point
name: "Dew Point"
temperature: my_temp
humidity: my_hum
filters:
# Smooth out readings
- sliding_window_moving_average:
window_size: 5
send_every: 1
# Only send significant changes
- delta: 0.5
# Limit update rate
- throttle: 30ssensor:
- platform: dew_point
name: "Dew Point"
temperature: my_temp
humidity: my_hum
icon: "mdi:water-thermometer"
accuracy_decimals: 2
internal: false # Make visible to Home AssistantIf using the ESPHome API, sensors are automatically discovered in Home Assistant.
If needed, add to Home Assistant's configuration.yaml:
sensor:
- platform: esphome
host: weather-station.local
sensors:
- name: "Weather Station Dew Point"
id: dew_pointtype: entities
title: Weather Data
entities:
- entity: sensor.weather_station_temperature
- entity: sensor.weather_station_humidity
- entity: sensor.weather_station_dew_point
icon: mdi:water-thermometer- Download new files
- Replace in
custom_components/dew_point/ - Recompile and upload
Automatic updates based on refresh setting:
external_components:
- source: github://iret33/esphome-dew-point@main
components: [ dew_point ]
refresh: 1hTo force update:
esphome clean weather-station.yaml
esphome run weather-station.yaml- Remove dew_point sensor from YAML
- Recompile and upload
- Component code remains but unused
rm -rf custom_components/dew_point/The sensor entity will be marked unavailable and can be removed from the UI.
- See EXAMPLES.md for complete configuration examples
- Check README.md for usage guides
- Review logs for any warnings or errors
- Calibrate your sensors for best accuracy
If you encounter issues:
- Check logs with
esphome logs device.yaml - Enable debug logging
- Verify sensor IDs and configuration
- Check GitHub issues
- Ask on ESPHome Discord or forums
Q: Can I use Fahrenheit? A: Component expects Celsius. Add a conversion filter if your sensor outputs Fahrenheit.
Q: How accurate is the calculation? A: ±0.4°C within -40°C to 50°C temperature range.
Q: Does it work with ESP32? A: Yes, works with both ESP8266 and ESP32.
Q: Can I use multiple instances? A: Yes, create multiple sensors with different IDs.
Q: Will this work offline? A: Yes, calculation happens on the ESP device, no network needed.
Good luck with your installation! 🎉