Jul 192011
 

I’ve completed the first pass of what seems to be a popular electronics self-education project: a home thermostat. I’ve already written about some of the software, and now I’d like to share some of the hardware details.

Arduino Thermostat

Detecting the Temperature
The brains of the project is an arduino nano (a digital microcontroller). It has an input connected to a temperature sensor from Adafruit, and it does a little math to convert the analog reading from the sensor into the ambient temperature.

Controlled the HVAC
As the acronym suggests, my HVAC unit has three functions: heating, fan (“ventilation”), and A/C. Each of these is controlled by closing a circuit from a common 24VAC line. If you take the faceplate off my old thermostat, you can see which terminals are used for these functions:
RH: The common 24VAC source
W: Heat
Y: A/C
G: Fan

Connecting RH to W/Y/G will tell the HVAC to kick that function on, so putting a relay between those lines allows me to programmatically flip the switch. I only have two relays (heat and A/C) because I never actually use the fan, but adding that would be trivial. The relays I use can switch 12-240VAC, and require 4-10VDC as digital input, which means 1) it can handle 24VAC on the HVAC side, and 2) it can be toggled directly by the output of my arduino (5VDC).

Setting the Temperature
The arduino is connected via USB to a computer, which sends data to set the desired temperature. The computer runs a program (written in nodeJS) which periodically polls a public Google calendar to fetch the scheduled temperature.

Fun With Logs
The arduino sends logging info back over the cable to the computer, which logs and graphs the data.

Not Pretty, But It Works!
Here is the completed setup. You can see the thermostat sitting on the shelf, and the wires going up to connect to the terminals on the old thermostat. The old unit is still there only for the handiness of the terminals (as opposed to just having wires coming out of the wall). You can also see an unrelated XBee hanging on the wall to the right. That is part of Power Hungry.

TODO
I’d love to make the project more permanent, either with a real PCB (if I can get over the pain-threshold of learning and using Eagle to design the circuit board), or at least with a soldered breadboard. I’d also like to come up with a cool case, probably using my 3D printer and some laser-cut acrylic from ponoko. I’d also like to go over the arduino code and clean it up, because I kinda hacked my way through it to get it to work.

The Code
You can get the code (for the arduino, and the graph server) on github.

  21 Responses to “Building A Thermostat Using Arduino”

  1. Very impressive. Thanks for posting! Would you be interested in writing a guest blog post for us at http://www.acdi.com/?

    • Hi Elizabeth — Feel free to ping me at patrick – at – plainlystated.com and let me know what you have in mind :)

  2. Thanks for this writeup. I’m going to experiment with it, because the thermostat in our house is going bad!
    I’m having some trouble with it, because once it goes to cooling mode, if you change the set temperature to where should heat, it is never detected. It goes to off, but never switches to heat.
    And the other way around, if it starts in heating mode, and you switch the desired temp, so that it should cool, it never goes to cooling mode.

  3. I have a side project for u & willing to pay . Small tape recorders ( loop recording ) work off remote control. Is this something u can do ?

    • Hi greg. Feel free to contact me at patrick at plainlystated dotcom to discuss the details of your project.

  4. Do you have a schematic or circuit diagram for the circuit connecting the HVAC system? I’m pretty sure I know what I need to do, but I just want to be sure when I’m working with higher voltage components.

  5. [...] while back I built my own thermostat using an Arduino, nodejs, and Google Calendar. It worked really well, but when I moved to a new [...]

  6. [...] Building A Thermostat Using Arduino [...]

  7. Can you give us an update on your project ?

    • Hi Dwight,

      I have since moved, and my new apartment doesn’t have central HVAC, so unfortunately this project is moth-balled.

  8. Seems like you got to the point where you can control the system, and then just emulated the original functionality of the thermostat. With the added calendar system.

    I have to wonder if you had given though to possible energy saving methods.

    What if one were to, for instance, leave the ac running for a while, and if the temp is close to the target then switch to just using the fan. Turn the ac off, let it blow cool-ish air to reach the target temp. Same for heat. Maybe there are other things possible. It just seems like you spent very little time on it.

    Not trying to criticize, just wanted to see more. I get the electronics of it, but there seems to be little are in the saving power. There has to be some software tricks to be done.

    • Years ago, I wrote a program for a Johnson Control thermostat that measured the thermodynamic response of the area under control to predict the time it would take to get the area to a specific temperature at a a specified time so that when you programmed 74 degrees at 7 AM it was at 74 degrees at 7 AM. Not exactly power savings, but makes it warm when you get out of bed in the middle of the winter after being cool all night. A lot of analysis was done of how an area responds to changes in temperature It turns out that all you have to do is monitor the response of the system as an RC circuit, determine the values of R and C and use them to predict the time needed from the starting point to the end point. that is good enough for a first order of approximation.

  9. Effectively worded post will probably be sharing this kind of with my readers this week

  10. Patrick, I’m extremely interested in this because I’m currently building a cooling unit for my computer out of an old electric water cooler. Basically I’m going to use the cooler’s tank to chill the non-conductive fluid instead of radiators. The problem is I know that I cannot run it full cycle even with the thermostat that it comes with fully adjusted without condensation. My question is, is it possible to build and program this type of device to lock the fluid 10-15 degrees below ambient to avoid condensation?

  11. […] I’ve completed the first pass of what seems to be a popular electronics self-education project: a home thermostat. I’ve already written about some of the software, and now I’d like to share some of the hardware details.  […]

  12. Hi there, just became alert to your blog through Google, and found that it’s really informative.
    I’m gonna watch out for brussels. I’ll
    be grateful if you continue this in future. Many people will be
    benefited from your writing. Cheers!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>