Approximating Dew Points in ESPHome

A dew point is a practical measure of moisture in the air that is a good proxy for occupant comfort. It is better to determine if a space feels “muggy” than relative humidity. The dew point is the air temperature, assuming the amount of water vapor in the air remains constant, in which the relative humidity of the air would be 100%. If the temperature decreases to be less than the dew point, water will condense on surfaces [1]. Another way to quantify the absolute quantity of moisture in the air is to use absolute humidity, but it is arguably easier to interpret a dew point has the same units as a regular temperature measurement.

Unfortunately, cheap, readily available electronic sensors that measure dew point directly are unavailable. However, we can approximate the dew point temperature relatively quickly and accurately by knowing the relative humidity and air temperature, which many sensors make available! As a note, there are many ways to approximate the dew point. However, we will base our approximation on a calculation that uses the Magnus formula described in [2].

The dew point temperature \( T_{dp} \) (in \( ^\circ \text{C} \)) is approximated by

\[T_{dp} \left( T, RH \right) = \frac{\lambda\left( \ln\left(\frac{RH}{100}\right) + \frac{\beta T}{\lambda+T} \right)}{\beta-\left( \ln\left(\frac{RH}{100}\right) + \frac{\beta T}{\lambda+T} \right)},\]

where \( T \) is the ambient temperature in \( ^\circ \text{C} \), \( RH \) is the relative humidity (as a number between 0 and 100), \( \alpha = 6.112 \text{hPa} \), \( \beta = 17.62 \), and \( \lambda = 243.12 ^\circ \text{C} \). In our equivalent C++ implementation, we use a temporary variable of

\[H(T,RH) = \ln\left(\frac{RH}{100}\right) + \frac{\beta T}{\lambda+T},\]

and return the dew point in \(^\circ \text{C}\) with

\[T_{dp}(H) = \frac{\lambda H}{\beta - H}.\]

Since I use ESPHome to control my sensors, the ESP32 will calculate the dew point directly on the device using a template sensor. The following template sensor assumes there are separate humidity and temperature sensors with an ESPHome id of “humidity” and “temperature” respectively.

  - platform: template
    name: "${upper_device_name} Dew Point"
    id: dewPoint
    update_interval: 30s
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0                                # formula is uncertain up to 0.35 degrees C = 0.63 degrees F for usual indoor temperatures
    lambda: |- 
        const float alpha = 6.112;                      // (hPa)
        const float beta = 17.62;
        const float lambda = 243.12;                    // (degrees C)

        float RH = id(humidity).raw_state;              // Relative Humidity
        float T = id(temperature).raw_state;            // Temperature in (degrees C)

        float H = log( RH/100 ) + beta*T/(lambda+T);
        return (lambda)*H/(beta - H);


  1. 1. Service USNW Dew point vs. Humidity. Available at:
  2. 2. Application Note: Dew-Point Calculation Sensirion AG.