Archive | February 2016

Red River Thermostat

This is a project that I’ve been slow to post about because it’s been hard to decide when to call it complete enough, I may not be there yet but something’s gotta be posted.

Our house is heated and cooled with forced air, it’s either on or it’s off, and the thermostat was mounted in the living room that we’re not always in. This means that during the night, when we have our bedroom door closed and are evidently acting like food fueled space heaters, the temperature climbs to uncomfortable levels and the thermostat at the other side of the house is unaware of that. During the day, when the sun warmed up the living room through our large window, the thermostat thought all was perfectly fine while the kids in my wife’s daycare downstairs are getting very chilly.

So what I needed was a way to control the thermostat based on the temperature in different locations at different times of the day. Since I have raspberry pi’s scattered around the house for various other purposes it made sense to make them do dual duty as temperature sensors. The diagram below gives a rough idea of the system layout.


The temperature sensors are a mix but all I2C. HTU21D, BMP085, and TMP102s are all compatible. Here’s a picture of the Main Thermostat Pi. The I2C connections tie into the terminal strip on the top left. The two sensors on this one are at the ends of about 10′ of cable. I’m likely breaking some rules when it comes to I2C there, but I don’t seem to have any communication errors so I’m not gonna think to hard about it. One thing to note is that these 5v relays can’t get their power from the RPi header, they pull enough current that it’s a problem (sd corruption and brownout issues), so they need to be fed from the power supply directly.


The thermostat status and settings are accessible via a web interface hosted on the same pi. It’s so nice to be able to call this up on my phone and bump up the heat without getting out of bed 🙂


As it is now, the program is built around the Webiopi package, which takes care of the IO management as well as the web interface. As things progress, I’m moving away from webiopi http hosting and gradually building up a standalone html/javascript interface that can do some fancier graphs and visualizations. All of the temperature data that’s being monitored is also being logged in a mysql database. As of today it’s been running for just about 10 months. The only big hiccups I’ve had are with some unique exceptions not being dealt with properly, and the SD card filling up at one point because I was logging about 4000 times more data then was really necessary.

The code is up at if anyone’s interested, but at the moment (Feb 15, 2016) what’s checked in doesn’t actually match what’s running, and likely doesn’t even work. It’s in the middle of a large rewrite that changes the way the UI interfaces with the controller. So stay tuned for an update when version 0.2.0 appears.