Building a Smart Heater from scratch

The winter is starting to get tougher here in Portugal, bringing up challenges regarding climatization of our homes. If you don’t live in here, you probably thought that it is a warm country due to our sunny summers. Traditionally older houses are inferior in terms of climatization, lacking things seen in other western and central Europe countries.

Designing a solution

I’m using a simple space heater to do climatization of my living room, which includes an analogue thermostat. Toggling it too high or too low results in an inefficient outcome, so I’ve decided to turn this appliance into a Smart Heater.

Picture 1 — Overview of the setup

By using an ESP8266, running Arduino, plugged with a DHT11 sensor, I’m able to measure in real-time the temperature and humidity of my living room. This device collects the data and sends it to an MQTT server running in a Raspberry Pi. I’ve developed a small microservice that analyzes this data, toggling a smart plug when necessary, according to a preset target temperature. This setup allows me to save money since the heater is only turned on when needed, without any manual interaction.


You can find the source code for the following components here:

Monitoring the solution

Picture 2 — Monitor the device through New Relic.

All the data is queryable through NRQL, here is an example of a query for the temperature readings widget (Picture 3):

SELECT latest(minimum) as 'ºC Min', latest(maximum) as 'ºC Max', latest(average) as 'ºC Avg', latest(target) as 'ºC Target' From HeaterEvent WHERE appName = 'Smart Heater' TIMESERIES
Picture 3 — We can expand graphs in the dashboard for better view.

Scale-up possibility

Another improvement to consider is swapping the DHT11 sensor to a DHT22, which provides a lower margin of error, in terms of readings.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pedro Freitas

Full-time DevOps Engineer | CKA | CKAD — Helping organizations to grow a DevOps culture.