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!
Press enter or click to view image in full size
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.
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!
Press enter or click to view image in full size
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.
Press enter or click to view image in full size
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.
Press enter or click to view image in full size
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.
Press enter or click to view image in full size
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 °.
Press enter or click to view image in full size
And the ultimate goal — to be able to control them all from my phone
Press enter or click to view image in full size