Fighting Condensation in the Smart Home

Monitoring humidity, checking weather forecasts and predicting when condensation might occur. An alerting system for the Smart Home.

Danny Boland
Oct 17, 2018 · 4 min read

Living in Scotland, I’m no stranger to condensation. As a student, I once lived in a tenement flat where even my phone screen would be wet on a morning. Armed with data from my smart heating system, I was finally ready to fight back. I set up an alerting system that texts my phone on evenings where there’s a risk of waking up to wet windows.

Where’s the data?

I previously wrote about hacking my smart heating system and logging its data to Amazon Web Services. I have a setup that pushes temperature, humidity and heating data to S3 — Amazon’s ‘simple storage service’.

I also needed weather forecast data to work out how cold my windows might get at night. There are plenty of options for free APIs to use, being British I opted for the Met Office’s DataPoint service.

Humidity readings throughout the day. No prizes for guessing when lunch and dinner were cooked!

Weather API

The Met Office’s DataPoint API offers free, 3 hourly forecasts for 5,000 sites in the UK. You just need to register a personal account to get an API key. There’s an endpoint to retrieve the list of locations and their corresponding IDs:<key>

I looked up the ID for my nearest forecast site and queried the forecast endpoint with it:<key>

The response is fairly comprehensive, with forecasts for the next week covering weather type, temperature, ‘feels like’ temperature, wind, rain, visibility, UV and humidity.

I wrote some Golang code to parse the JSON response and calculate the coldest temperature forecast over the coming evening. The plan was to create an AWS Lambda function that queries the weather each hour, checks the readings in the house, and alerts if condensation is likely.

The Maths Bit

Calculating the Dew Point

The temperature below which moisture in air starts to condense is called the dew point. It can be approximated using the Magnus formula:

I took the b=17.62 and c=243.12℃ constants from an application note I found, which cites a journal article from the 80s. The note shows that these values give a very good approximation for any temperature we’re likely to see in the home.

I implemented the Magnus formula within my AWS Lambda function:

func dewpoint(T float64, RH float64) float64 {
b := 17.62
c := 243.12
H := math.Log(RH/100) + (b*T)/(c+T)
DP := c * H / (b - H)
return DP

How cold are my windows?

One complicating factor in this project is that my windows are going to be much colder than the ambient room temperature. Without a sensor attached to the window, I’d need to approximate the window temperature as a function of ambient and external readings. Fortunately, the University of Liverpool hosts a fantastic video showing how to derive the surface temperature of a window.

Windows are typically marketed with a U value in units of W/m²K, being the heat transfer rate per square metre per degree temperature difference. I was happy enough to use a typical value for that to capture the heat loss through the window. I could also assume that the heat transfer out of the window was equal to the heat transfer to the window from the room via convection. Taking a typical heat transfer coefficient h for air in a room gives a heat transfer of:

I didn’t pay enough attention in first-year thermodynamics lectures but the above seems to work well enough. I implemented the simplified window interior surface temperature calculations as below:

func windowSurfaceTemperature(Texterior float64, Tinterior float64, Uvalue float64, Hinterior float64) float64 {
return (Hinterior*Tinterior + Uvalue*Texterior) / (Hinterior+Uvalue)

Codensation Alerts

I could now work out when condensation might occur. I could compare the dew point for the moisture in each room against how cold my windows might get through the night. I set the Lambda function to query the current temperature and humidity via Athena every hour in the evening. If condensation is likely, it sends an alert (via a Simple Notification Service topic) with a warning and the related measurements. All that’s left is to open a window or bump up the heating when an alert arrives!

The code for this has been added to the git repo for my Wiser system hacking. I’m quite pleased with this setup but one thing bugs me. Only the room thermostat measures humidity and the Wiser kit comes with just one of those. They’re also much more expensive than the smart radiator valves I have around the house. For this alerting system to really work, I need to measure humidity in every room. Stay tuned for a future blog post on adding DIY humidistats to the system!

Leader image cropped from a photo by Patrick Hendry, via Unsplash.


Data Science, day-to-day.

Danny Boland

Written by

Writing about Data Science applied to day-to-day life.



Data Science, day-to-day.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade