Space Heater Thermostat

This project implements a space heater thermostat. It uses an ATtiny84P microcontroller, a DS1775 I2C temperature sensor, and a SAA1064 I2C LED display controller. And a pushbutton rotary encoder.

This is the second version of this project; the first used a KTM-S1201 LCD display and a solid-state relay. It suffered from two problems: The LCD had no backlight, and in operation it could barely be seen; and the solid-state relay kept burning up. The SSR was rated at 30 amps and the heater ran about 7 amps, and was well heatsunk, but the problem seemed to be in the screw connections. They somehow worked loose over time causing resistance, heat, and burning. I destroyed two relays the same way before retiring the design. This project uses regular heavy-duty relay which will hopefully never fail (nice try, see below).

schematic

(Click to enlarge the schematic.)

The interesting part of the project is the use of two I2C devices. The temperature sensor is a DS1775, which not only is I2C driven, but contains a thermostat built-in. When programmed, the DS1775 signals the microcontroller to turn the load on and off. This simplifies the microcontroller programming somewhat.

Two 2-digit LED displays are used, one showing the set temperature (degrees C) and the other showing the measured temperature. Twisting the rotary encoder increments or decrements the set temperature (and reprograms the DS1775). Pressing the button turns the thermostat on or off. When off, the set temperature goes blank but the unit continues to display measured temperature (and the load is off).

The LED displays are ordinary common-anode two-digit seven-segment displays p/n LTD-4608JF. I found these in my parts bin along with a driver chip p/n SAA1064, which controls both displays and uses an I2C interface. It is hard to wire up but a pleasure to program compared to my other LED projects.

front viewinside view


bottom viewsensor

The green module in the top left corner of the inside view is the 5V power supply. It came from a USB-type 5V 1A wall-wart switching supply with the case removed. Below the DS1775 is mounted on a surface-mount board, the only way to manage such a tiny part with almost no pins. The relay is 110 VAC 10 amp contacts, with a 5 VDC coil (see below). My relay draws about 200 mA and closes easily at 4V. Any NPN driver transistor can be used as long as it can handle the relay's current.

Programming notes:

1. The DS1775 is a celsius device, and my project displays celsius. Converting to fahrenheit is not difficult but some programming effort would be required.

2. The on/off hysteresis is specified in a define in main.c, 1.6 degrees C in my code. Depending on the environment and location of the sensor, a larger or smaller value might be appropriate. It is easy to change and re-compile the code. As with all my AVR projects, Atmel Studio is used with WinAVR GCC compiler, all free to download. Create a project, select the ATtiny84A device, add the source code modules and build the code.

2021-05 Please be careful selecting the relay. It needs a 5VDC coil and switching contacts that can handle the load, 10 to 20 amps. The relay I was using (fleamarket special, open frame relay) lasted a few years but finally burned up. The problem was resistance in the switching contacts. My heater runs 6.5 amps, and if the contacts have 0.1 ohm resistance, there will be 4.2 watts of heat produced! The new relay tests 0.04 ohms, better but still not great. According to T. J. Byers, "As the relay ages, the contacts become pitted and the resistance increases."

2022-03 Occasional malfunction was tracked down to noisy power supply. (Many of those 5V switchers are crap.) I added a capacitor to the output, hopefully this will fix it.

Download WinAVR C source code for the thermostat

Back to VE3LNY's AVR Projects Page