This thermostat is built around an ATMega164 and a TC1047A temperature sensor. It controls your furnace and air conditioner. It is not programmable, although it has a clock and is capable if some additional code were written (any volunteers?). The unique feature is that instead of a bunch of buttons and switches, I used a single pushbutton rotary encoder, for a very simple user interface.
The ATmega164P has plenty of I/O and memory. The LCD is the usual 16×2 parallel I/O. The TC1047A temperature sensor is easy to program to, if you don’t mind its tiny size. The real time clock is a NJU6355. Note the use of a DS32khz instead of the usual 32 kHz crystal; I was fed up with RTCs running a bit fast or slow, and I wanted to try this as a possible solution.* Finally there’s the rotary encoder; I used a Grayhill Inc p/n 62P22-L4. The Digikey part number is GH7295-ND, and the price was C$4.69. (More information on this part can be found on my rotary encoder page.) The encoder outputs a 2 bit code which allows you to tell if it is being turned clockwise or counter-clockwise. In addition it has a pushbutton built in to the shaft.
The most interesting part of this project is the use of the rotary encoder. In run mode, turning the knob raises or lowers the temperature setting. Press the button and you enter the customization menu. The first menu lets you select heat, cool, or off. The next menu lets you turn the fan on or off. After a few more menus you can set the clock if you like, then the unit returns to the run mode again.
The nice thing about this thermostat is that it is powered by the furnace. There are no batteries to replace. The last set temperature is remembered in EEPROM so it always returns to the correct state after a power off. What I really like is keeping the LCD backlight on all the time, since there is no need to conserve power.
To make this possible you need access to the “C” wire in the furnace, which is not normally run to the thermostat. My thermostat had “RH” and “RC” wires which were both connected to the “R” terminal in the furnace. All I had to do was move one wire to the “C” terminal (the unused one!).
You may find the terminology of the thermostat/furnace connections confusing, I certainly did. I am not in the heating/AC business so my knowledge is based on study of the furnace schematic and my own speculation. The furnace contains a 24V transformer which powers the control system. One lead of the 24V secondary is common/ground and called “C”. The hot side of the transformer secondary is called “R”. “R” is delivered to the thermostat which contains one to three switches to activate the functions of the furnace and A/C. Each switch requires one wire back to the furnace controller. The one switch all thermostats have is heat, which is returned to the “W” terminal in the furnace. If you have A/C, the cool switch returns to the “Y” terminal. Finally if you have a Fan On switch, it is returned to the “G” terminal.
There may be other kinds of furnace control systems in use. Please make sure your furnace corresponds to my description before you try it. You could damage your furnace controller. I cannot be responsible.
In order to get power from the furnace I accessed the 24 VAC across the “C” and “R” terminals, rectified by D2, filtered by C11 and regulated by U3**. My switches are relays, RY1 RY2 and RY3. I happened to have a few SPST reed relays that operate at 5V and 10 mA, so they can be driven direcly from the AVR I/O port. These relays are labelled “Hamlin HE321A0400 8006”. I rescued them from an old PCB many years ago. (The Fan On relay has been energized in my project for years now and still works!)
J1 (in-circuit programming connector) was used during development but you can leave it out if you like.
Thanks to Peter Fleury for the AVR LCD routines.
Download C source code for AVR Thermostat
* Update on the DS32khz: it really works, although I can’t quantify it precisely. The clock appears to keep good time (within a second or two) after a few months in operation.
Read more: AVR Thermostat