When it first came out, I was really enamoured with the nest thermostat. The idea of a remotely-accessible, app-controlled thermostat appealed to the gadgeteer in me, but the price and lack of flexibility (it really wanted to be left alone to learn and do its own thing, as opposed to being controlled by a fixed schedule), plus my propensity to tinker, led me to build my own.

For a long while I had an Arduino-based thermostat running in my house, but I wasn’t very happy with it. Writing code for the Arduino isn’t always very fun (for me), especially when you want it to be web-accessible.

Then came the Raspberry Pi.

This is what I had always wanted: a little full-blown computer with a bunch of GPIO pins. It runs Linux, which means you can leverage all the great software you’re already using elsewhere, and you’re free to use your programming language and web technologies of choice when building the software.


The basic idea of the PiThermostat is this: The Raspberry Pi reads the current temperature from a Dallas 18B20 temperature sensor, and then turns on/off the relevant relays on a linked Relay Board. That relay board can either control the direct wires from your existing thermostat, or can control the A/C power to an outlet, etc. This gives you full flexibility to replace an existing central HVAC thermostat, or just control a window A/C unit. I have two thermostats running, one in each of those configurations.

Parts List

This is the current parts list:

Setting Up the Raspberry Pi

  1. Download the latest version of Raspbian from raspberrypi.org.
  2. Install the image to your SD card.
  3. Connect your Raspberry Pi to the network, wait for it to boot, then SSH to it.
  4. Run raspi-config and configure your Pi as desired, changing passwords, etc.
  5. Turn your Pi off.
  6. Wire up your temperature sensor. I used GPIO pin GPIO04 (hardware pin #7). See the pinout here
  7. Wire up your relay board. I used GPIO_GEN0 - GPIO_GEN3 to control relays 1-4, respectively.
  8. Install the software to run the PiThermostat code as explained under ‘Setting up the Pi’ over on the project Github site

Controlling the Thermostat From the Web

By default, the rails app powering the thermostat runs on the web. Just point your browser to that IP Address / URL and you can set the temperature, set schedules, override schedules, etc. Just make sure you setup the thermostat on the rails console first.

Controlling the Thermostat From An App

The rails server has a full REST API for handling a native app. I’ve hacked together a few UIs to manage my thermostats, but none are polished enough to be worth releasing. If you write one I’d love to know.

Controlling the Thermostat From Siri

This is where things get even cooler. First, go install Homebridge, which basically involves installing node.js and editing a single config file.

Once Homebridge is installed, go get the accessory file for the PiThermostat, and install it into your accessories folder. Then edit your config, restart Homebridge, and boom, you should be able to tell Siri to “Make the thermostat colder.” If you have an Apple Watch, you can even do it from your wrist, Dick Tracy style.