Enlighten your old furnace with a Raspberry Pi, Home Assistant, an ESP8266, and some relays.

My mom has one of those on/off furnaces (EDIT: actually it’s a boiler) that heats up water and circulates it through pipes around the house that have little radiator fins. She wants it to turn on before she wakes up so it’s not so cold in the morning. In this post, I explain how to turn a normal furnace into a smart furnace for only a few bucks.

Furnace controls in Home Assistant

Starting point

I already had a Raspberry Pi 3 running Home Assistant for some basic home automation stuff around the house (a few lights, cameras, door sensors, temperature, ham radio, motion sensors.. see my earlier posts in this category). This can be set up pretty easily. I also have an OpenVPN server installed on the home router (using DD-WRT), allowing easy remote access to the LAN.

The furnace is as simple as it gets. There are like 8 zones each controlled by a two-wire (red and white) Honeywell mercury thermostat.

Honeywell Mercury Thermostat
Furnace

Physically Controlling the Furnace

When one of these thermostats gets cold, mercury flows downhill and connects the two wires, which are hooked up to a 24V transformer that actuates a water valve (for example, the silver box in upper left of above photo). The water flows and the heat turns on. Again, this system is heat only so it’s as simple as it gets. To take control of it, all I need to do is be able to control a relay that connects the two wires. I could put a relay and temperature sensor in the wall near each thermostat and run some wires to control them, but it’s easier for me to put all the relays together by the furnace and rely on wireless temperature sensors.

But how to control the relays? I don’t want to have a dedicated Pi down there for run a bunch of wires. Enter… the ESP8266.

The ESP8266 is an incredible little System-on-a-Chip (SoC) that has a WiFi radio and can be programmed just like an Arduino. It has libraries ready to go for message passing (MQTT) to tell it when to flip switches, Over-The-Air updating so I can upgrade the system without plugging it into a computer, and tons of other stuff. It also has 16 GPIO pins, many of which are available for the user in most packages. And it’s just a few bucks! (Note that the ESP32 just came out that has Bluetooth too). I got one packaged as a Wemos Mini D1 because it came with a USB interface, making it easier to deal with for a few extra dollars.

Wemos ESP8266 and Relays. USB cable is only for power because data comes over WiFi.

On the other end of these relays, we simply patch into the contacts of the red and white thermostat wires from each zone we want to control. The original thermostats stay where they are, and the system reverts to normal old behavior when the relays are off.

MQTT for communication

MQTT is perfect for this kind of application. It’s an IBM-developed simple messaging protocol originally intended to control pipelines and stuff via satellite. It offers publish and subscribe services, which is exactly what we need. The ESP8266 will subscribe to a few topics and turn relays on and off according to what it gets and Home Assistant will publish commands based on user input or automations. MQTT also has a “last will” feature where the ESP8266 can tell the broker to send an “unexpectedly offline” message if it ever gets disconnected, which I use to send myself an email if the power at home goes out or if something else breaks. The PubSub library (among others) adds MQTT capabilities to the ESP8266.

I have an external MQTT broker on a server but you can alternatively just use the built-in MQTT server on Home Assistant or install one locally on your LAN. I like the external one because it will tell me if the house goes offline.

The ESP8266 Code

My code is posted here. It has “secure” MQTT (encrypted but not verified), and allows OTA updates from the LAN.

The UI and Intelligence

Home-Assistant does all the User Interface and Intelligence. You just have to configure it.

Relevant bits of my configuration are as follows:

I don’t have all the automations with the generic_thermostat hashed out yet but am working on them.

I will need a few more temperature sensors to really be able to control things to a finer degree, but to get some basic morning pre-heating intelligence going on, this is totally sufficient. Exciting times!

 

 

5 thoughts on “Enlighten your old furnace with a Raspberry Pi, Home Assistant, an ESP8266, and some relays.”

  1. As a general tip for people like me that might be searching for this, what you are controlling is a boiler, not a furnace.

    I plan to do a very similar setup. Where are you getting the power for the board? Did you plug and just plug in an adapter, or are you converting down the 24v AC from the transformer near the boiler?

    You didn’t include what you’re doing with the original thermostats. It seems like it would be pretty easy to pick up that side of the wiring as well. Did you do, or do you plan to do this?

    1. Thanks for the feedback! I mentioned “boiler” at the top now. Yeah, the ESP8266 and relay board are just powered through the nearby wall AC outlet through a standard phone-charging microUSB wall-wart. The original thermostats stayed where they were so the system reverts to “regular old” mode when all relays are turned off (I edited the description above to clarify this).

  2. Do you have the part number of the relay module you used, and could you give additional info on how you wired the ESP8266 to it?

    Thanks!

    1. It just says “4 Relay Module” on it. It’s one of those optoisolated ones. Here’s the exact model.

      For wiring it, I applied +5V to the VCC pin, GND to the GND, GPIOs D4, D5, D6, D7 to the relay inputs (those are Wemos numbers; actual ESP8266 GPIO numbers are 2, 14, 12, 13). Importantly, I jumpered the VCC and VCC-JD pins (this powers the coils with the same +5V coming in over the USB cable from the wall outlet).

  3. hello is it possible to add 4 manual buttons to this project. I want to use this project to control my room lights.

Leave a Reply

Your email address will not be published. Required fields are marked *