Open hardware thermostat with remote control based on ATmega128

DIY hobby construction, open source firmware available

Why to build such a trivial device as thermostat, when there is a huge amount of such devices on the market, recently also WiFi thermostat e.g. from Honeywell? Well most of them are dumb and not flexible at all. I wanted a device which will
1) be reliable - no under-dimensioned low-cost Chinese components or planned lifetime design. I have been using a homebrew thermostat of this design, in a prototype version connected on a universal PCB, since 2006 and no problems occured so far
2) support any number of wireless thermometers in different rooms and control the heating based on average, minimum or maximum of the measured temperatures, or a time-dependent combination thereof (e.g. sleeping room in the night, living room + children room average over the day) - as far as I know the Wifi thermostats on market do not offer that
3) be comfortably programmable - by entries in a Unix crontab on a home server ;-) - the hacker's way, android apps are for BFU's
4) be accessible via internet - although indirectly through a home server to keep its cost low - to e.g. switch on heating in advance when returning from a holiday. Recently commercial devices with this ability appeared on the market, but I do not trust the security of proprietary systems :-)
5) be safe from malicious neighbors - all wireless communication is encrypted
6) be universal concerning the connected heating/air conditioning device - depending on its type, either optotriac or optocoupler can be connected to switch it, up to four such devices can be controlled. Again commercial devices are not flexible enough.

I thus designed a device myself, slightly adapting a PCB used previously for a meteostation and rewriting a firmware of an older thermostat which was wired on an universal PCB. Both hardware and software is open (GPLv3 licensed) and I used the open source KiCad program for the PCB design to be completely free. The KiCad design files as well as Gerber and Excellon files for production are in the file, the firmware source is in file For convenience, PDF export of the schematics is here. The wireless communication is very simple using the amplitude modulated 433.92MHz modules from Aurel, all modulation is handled in software, sending 128-bit long datagrams. Authentication is achieved using the rolling code method and as a cipher I used for historic reasons double Keeloq, although today I would switch to AES128, if I had time to rewrite the code. The name "generic" can be changed by changing #define LOCATION in termostat3.c and appropriate renaming of the header files, which allows compilation of firmware for thermostats placed in different locations with different encryption keys. (Of course, you need to replace the dummies 0xffffffff by your own keys (obtained e.g. from /dev/random) in the header file. Note that the file generic_keys.h contains shared keys for all sorts of home automation, only one sensor and actor key corresponding to the serial number #defined in termostat3.c should be set.)

For the user the device is very simple - turning the knob of the rotational coder left/right the set temperature is modified, display shows current temperature and set temperature, RGB-LED indicates whether heating/air conditioning is active. Pressing the knob shortly toggles backlight of the display, longer press switches to menu, which is controlled by the rotation again. Very long press resets the device. All functions can also be controlled wirelessly and the thermostat also sends messages about the temperature and status of controlled devices - see the code for details :-).

UPDATE 2019:
As the SMT160 is not in production any more and I had troubles with SMT172 (easily damaged by heat when soldering or heatshrinking, and more jitter requiring long averaging), I have implemented support for the popular DS18B20 temperature sensor chip. The code autodetects whether SMT160/172 or DS18B20 is connected. Pullup for DS18B20 is implemented using internal GPIO pullup in software; it worked for me, but maybe external 4k7 pullup resistor is better for increased reliability. Notice however the different pinout of the SMT160/172 vs. DS18B20 in TO92. The board layout keeps the SMT160 pinout.

Front side of the board:

Notice that the RF amplifier and some meteostation-specific footprints are left unoccupied. The relay is NOT for the heater, the optotriac connected to AUX connector is installed in a separate box, together with the power supply - the thermostat is powered by 13.8V backed up by a lead acid battery.

Back side of the board:

Notice the ugly placed transil due to badly dimensioned footprints for SMBJ5V - this bug has already been fixed in the pcb version downloadable on this page.

Programming finished device:

Auxiliary high-volatge box:

Upper part: solid state relay (SSR) with a snubber, Lower part - 13.8V switched mode power supply from a modified DC adapter, on the top a backup battery

Thermostat installed on the wall:

I have published another thermostat construction which uses the ARM LPC1114 chip to control a stepper motor turning a valve.

My Electronics page

My hobby page

My main page with e-mail contact

TOP of my family pages