Programmable AVR 1-Wire Thermostat

Introduction

To support experiments for the Meter Gateway Architecture, Michael LeMay developed a programmable thermostat based on a single-board computer with an Atmel AVR ATmega128 microcontroller. The board is an Olimex AVR-MT-128, described here. His design of this embedded system is given below with all the details you need to build one of your own!

Hardware Components

Besides the Olimex development board, I used a Dallas DS18S20 1-wire thermostat to actually measure the temperature, a standard PC floppy drive cable to connect the DS18S20 to the development board, and one of the 12V power supplies offered by MC Pros (where I bought the development board). I used an Atmel AVR JTAG ICE mkII programming and debugging tool, which I connected to the development board using the "squid cable" included with the programmer. Finally, I used a standard serial cable to connect the thermostat to my PC. This board can be operated in a standalone mode as well. The fully-assembled system is depicted below:

To assemble this system, simply plug the floppy cable onto the EXT1 and EXT2 headers, with the key on the cable pointing away from the center of the board. The floppy cable should fit perfectly on the headers, with no room to spare. Then, plug the DS18S20 into the other end of the cable, as shown below. Make sure you pay attention to the direction the key on the cable is pointing. It is critical that you plug the thermostat chip into the exact socket holes shown below.

Finally, you must wire up the JTAG cable to the back of the board, as shown in the following diagram. Then, you're ready to program the device.

I have released the firmware I developed for this project available as a convenience for the community, and have included a link at the end of this page. It requires the AVR-GCC cross compiler and must be compiled and installed under Linux. It is heavily based on the excellent sample code made available by Olimex for this board, as well as the AVR318 Atmel application note which provides code for interfacing with 1-wire devices. To install the firmware, simply enter the "build" subdirectory and type "make upload". You may have to run that command as root, to allow access to the USB port connected to the JTAG programmer.

When it powers up, the thermostat should display low (L:) and high (H:) temperature setpoints, and the current ambient temperature. When the temperature exceeds the high setpoint, the relay will close, and will not reopen until the temperature falls below the low setpoint. This relay can be used to control an actual air conditioner, as described here. Simply replace the recommended temperature sensor with this programmable thermostat.

The thermostat has three distinct controls. You can adjust the high and low setpoints of the device, and control whether it beeps when the relay changes its state. To adjust the low setpoint, hold down the "southern" button on the thermostat and either the western or eastern button to adjust the setpoint down or up, resp. Hold down the northern button to adjust the high setpoint. Currently, the thermostat does not perform any sanity checks on the setpoints, so you are responsible for ensuring the low setpoint is actually lower than the high setpoint, etc. Press the center button to toggle the beeping mode.

Finally, you may wish to monitor and control the thermostat from your PC. To do so, you must first connect a serial cable between ttyS0 on your PC and the thermostat. Then, download the AMDR software distribution, as described here. One of the applications included in that distribution is a simple thermostat controller. It is named edu.uiuc.seclab.thermo.DrThermoCtrl and is an executable class. It dynamically updates to display the current temperature and setpoints on the thermostat, and allows you to adjust the setpoints by using simple spinner controls.

Thank you for reading this project description; I hope you find it to be useful! Feel free to send me any feedback you may have.

Software Releases

Maintained by: Michael LeMay

 

JoomlaGATor!