Programmable House Thermostat

By Alex Bezroutchko,
December 2005

Contents

 Overview
 User interface
 Hardware description and schematics
 Software description and source code
 Downloads


Overview

This webpage describes a microcontroller-based house thermostat which I have built to replace the old one in my house. This is an ongoing project, the documentation is not complete. Feel free to contact me over the email (see at the top of the webpage).

DISLAIMER: The device operates with high voltages, so there is a risk of electric shock. Please use all necessary precautions.

The device is capable of maintaining convenient temperature when I am home and keep the house from freezing while I am away. A temperature mode is chosen according to the predefined time schedule or manually from the console. The thermostat switches the pump (230V AC) on and off to maintain house temperature within desired limits.

The device features a transformer-based power supply and optoinsulated triac driver. Therefore the microcontroller and user interface is galvanically insolated from mains. The device based on Microchip 18F1320 microcontroller and DS1820 digital thermometer.

My goal was to build a flexible device which I could eventually improve and add more functionality. So it is most probably not really cost-effective. However, it seems to keep my house warm and it was a lot of fun to build.


User interface

The user interface is pretty handicapped at the moment:

  • Menus accessible via RS232 serial link
  • Two LEDs
  • Buzzer
I plan to add 16x4 LCD panel (HD44780-compatiple) and 4x4 keypad as soon as I find a suitable LCD panel.

Yes, to reach the menu I need a laptop and a cable. Green LED indicates power supply working ok. Yellow LED lits when the heater is on. The buzzer makes an annoying sound in case of repeatable failures of the temperature sensor or after power blackout.

Main menu looks like this:

   SCHED  19 08:53:15
   1. ON/SCHED/AWAY/OFF
   2. Set schedule
   3. Set HOME temp
   4. Set AWAY temp
   5. Set clock
   6. Clear alarm

The top line indicates mode, current temperature (in degrees C), and a wall time. Digits 1-6 gives access to the corresponding functions.

1. ON/SCHED/AWAY/OFF Toggle between the four operation modes
2. Set schedule Current schedule (3 entries) is displayed. User can choose which entry to modify,
and enter new start and end time.
3. Set HOME temp
4. Set AWAY temp
Set temperature range for HOME and AWAY modes.
5. Set clock Set wall time, hours and minutes.
6. Clear alarm Shut the alarm. Alarms are triggered after multiple temperature sensor errors or
after power blackout.


Hardware description and schematics

Power module

The power supply is a standard regulated one. It consists of:
  • Transformer: primary 230V, secondary: 9V, 1.8VA
  • Varistor and fuse at the input of the transformer
  • Diode bride followed by 7805 regulator at the output
  • Green LED to indicate power is ok.
AC load driver is based on 2N6075A triac controlled by MOC3063. The schematics is based on one suggested at the datasheet of MOC3063.

Microcontroller

The device is based on Microchip PIC18F1320 microcontroller. Internal 8MHz internal oscillator is used as a system clock and an external 32 kHz watch quartz crystal for precise timekeeping.

For microcontroller programming (upload software into the microcontroller) I use tinybld bootloader.

The microcontroller connections:

  • Watch quarts crystal => Pins B6, B7
  • MAX233 RS232 level converter => Pins B1, B4
  • Buzzer => Pin B2
  • MOC3063 driver module via a resistor and yellow LED => Pin B5
  • DS1820 DQ => Pin B3
See Downloads section for draft Eagle schematics and board layout.

Software description and source code

The software is written in C, compiled with CCS C compiler. See Downloads section for the source code, the main program is tempcontroller.c


Downloads

The source code is available here. Draft Eagle schematics and board layout is available here.

(C) Alex Bezroutchko, 2005