ThermOS

Joseph Truncale
7 min readJan 8, 2021

A multi-zone “smart” thermostat solution for your home

  1. The Story
  2. Buy vs. Build
  3. Designing the ThermOS Hardware
  4. Writing the ThermOS Software
  5. ThermOS in a Lunchbox

The Story

My wife and I moved into a new home in October of 2020. As soon as it started getting cold, we started to realize some shortcomings of the home’s older heating system (including one heating zone that was always on 😓). We were used to having Nest thermostats in our previous home and the current setup was not nearly as convenient. Some thermostats had heating schedules programmed, other ones had different schedules, some had none at all. It was time for a change…

Previous owner left us some Post-It notes explaining a few of the thermostats (4 of the 7)

Lets define some of the home’s constraints

  • It was built late 60s with a renovation during the 90s
  • My heat is hydronic (hot water baseboard)
  • I have 6 thermostats for the 6-zones of heat
  • There are only two wires that go to each thermostat for heat (red & white)
Taco (Pronounced: TAY-KO) Zone Valves at the Furnace

Buy vs. Build

What I wanted:

“Smart” thermostat control for all heat zones (schedules, automations, home/away)

Option 1: Replace with Nest/Ecobee

  • Expensive: no smart thermostat can handle multiple zones, so I need 1 for each zone (~$200*6 = $1200)
  • Difficult: I would need to re-run thermostat wire in order to get the infamous C-wire. The wires are 20–100ft each in-wall and might be stapled to the studs

Option 2: Replace with battery-powered (Sensi Wifi Thermostat)

  • Batteries last a month or two
  • Not HomeKit compatible in battery only mode

Option 3: Replace with a COTS version (only one kind-of exists..Honeywell TrueZONE)

  • Old and poorly supported… released in 2008
  • Expensive: $330 for just the controller, but you need a RedLink(?) gateway for a shoddy app to work

…and the winner is…

Option X: Build my own!

  • Centralized at the furnace (only need 1 device instead of 6)
  • Re-use the existing in-wall thermostat wires
  • HomeKit compatible (complete with automation, scheduling, home/away)
  • anddddd.. fun? Yeah, fun.. I think

Designing the ThermOS Hardware

I knew that I wanted to use a Raspberry Pi and since they’ve gotten so inexpensive, I decided to use a Raspberry Pi 4 Model B 2GB. I’m sure we could get by with a Raspberry Pi Zero W, but that will be for future revision.

Before we get into the individual components, here’s a full list of parts used:

I began drawing out the diagram on draw.io and began realizing that I lacked some crucial knowledge about the furnace. I opened up the side panel and found the step down transformer that takes the 120V line and makes it 24V for the heating system. If your heating system is anything like mine, you’ll see a lot of jumper wires between the Taco zone valves. Terminal 3 on the Taco is jumped across all of my zone valves. This is due to the fact that it doesn’t matter how many valves are on/open, as it just controls the circulator pump. If any combination of 1 to 5 valves are open it should be on, if no valves are open it should be off.. simple!

ThermOS Architecture as explained using 1-zone

At its core, a thermostat is just a type of switch. Once the thermistor (temp sensor) inside the thermostat detects a lower temperature, the switch closes and completes the 24V circuit. Instead of having a thermostat in every room, this project will keep them all right next to the furnace so that all 6 zone valves can be controlled by a relay module using 6 of the 8 relays. The Raspberry Pi will act as the brain of our thermostat and control each of the relays independently.

Manually setting the relays using the RPi and Python

The next problem to solve was how to get temperature readings from each room? I could have a wireless temperature sensor in each room running on an Arduino/Pi, but that can get expensive and complicated. Instead I decided I was on a quest to re-use the existing thermostat wire in the walls, but purely for a temperature sensor.

The “1-wire” DS18B20 temperature sensor appeared to fit the bill:

  • Accuracy of +/- 0.5°C or 0.9°F
  • Uses the “1-wire” protocol for data
  • Most importantly.. DS18B20’s can use “parasitic power” mode where it only needs 2-wires for both power and data. Just a heads up.. almost all of the DS18B20’s out there are counterfeit. I purchased a few hoping they were genuine, but when I tried to use parasitic power, they wouldn’t work. Purchased real ones from Mouser.com instead and they worked a charm!
3 DS18B20s connected using parasitic power on the same GPIO Bus

Starting with a breadboard and all the components locally, I started writing code to interact with all of it. Once I proved out the concept I added the existing in-wall thermostat wire into the mix. I was able to get consistent readings with that setup, so I set out to make them a bit more polished. With the help of my Dad, the self-proclaimed “just good enough” solderer, we soldered leads to the 3-pin screw terminals (to avoid overheating the sensor) and then attached the sensor into the terminals. Now the sensors can be attached with wire nuts to the existing in-wall wiring.

DS18B20’s are then attached to the old thermostat location using the existing wires

I’m still in the process of “prettifying” my temperature sensor wall mounts, but I’ve gone through a few 3D printing revisions and I think we’re almost there.

Started at “Nest” style and made my way to flush-mount

Writing the ThermOS Software

https://github.com/truncj/thermos

As usual, writing the logic wasn’t the hard part. However, deciding on an application architecture and framework was a confusing multi-day process. I started out evaluating some open source projects like PiHome, but they relied on specific hardware and it was written in PHP. I’m a fan of Python and decided I would start from scratch and write my own REST API. Since HomeKit integration was so important, I figured I would eventually write a HomeBridge plugin to integrate it. What I didn’t realize was that there was an entire Python HomeKit framework called HAP-Python that implements the accessory protocol. This let me get a POC running within 30min that was controlled through my iPhone’s Home app.

Initial version of Apple HomeKit integration. Shoutout to the HAP-Python Framework
ThermOS Software Architecture

The rest of the “temp” logic is relatively straight forward, but I wanted to highlight a piece that I initially missed. I had my code running for a few days and was working on the hardware when I noticed that my relays were turning on and off every few seconds. This “short-cycling” isn’t necessarily harmful, but it certainly isn’t efficient. In order to avoid that, I added some thresholding to make sure that we only toggle heat when we’re +/- 0.5C °.

Threshold logic (you can see the rubber duck debugging in the comments)
Thresholding allows us to have longer stretches of time where the heat is off

And the ultimate goal — to be able to control them all from my phone

ThermOS as a HomeKit Hub

ThermOS in a Lunchbox

..let’s package this thing up

ThermOS controlling a single zone (before)

With the software and general hardware design in place, I could start figuring out how to package all of the components in a more permanent and polished form. One of my main concerns for a permanent installation was the use of a breadboard with dupont wires. I ordered some solderable breadboards and a screw terminal breakout board (thanks @arduima) for the Raspberry Pi GPIO pins.

Solderable breadboard with mounts and enclosure (in-progress)
Mounted in the boiler room (after!)

Now I just need to spend some time organizing/labeling the wires and then I can start swapping the remainder of the thermostats over to ThermOS.

Next up..

ThermOS for my Central AC 😅

--

--