Infra-Red Panel Thermostat
by RobBest in Circuits > Microcontrollers
159 Views, 0 Favorites, 0 Comments
Infra-Red Panel Thermostat
This project is a combination of two projects I created earlier:
I have an Infra Red panel, which is mounted below my desk. I wanted a device that did the following:
- Function as a programmable thermostat and switch off the Infra-Red panel when the temperature below my desk reaches a certain temperature so that I do not get it too warm.
- Function as a programmable timer so that my Infra-Red panel is always switched off after a certain time so that I am certain that it is off in case I forget to switch it off myself.
This Infra-Red Panel Thermostat does all that.
As always I used a PIC microcontroller and created all software without using any specific libraries. For the temperature measurement I used the DS18B20 and I reused most of the software of the projects mentioned earlier.
Supplies
You need to have the following components for this project:
- A piece of breadboard
- PIC microcontroller 16F1823
- 74HC595 Shift Register
- DS18B20 temperature sensor
- 3 * 7-segment display, common anode
- 2 * 100nF ceramic capacitors
- 9 * 330 Ohm, 4 * 1k, 3 * 10k resistors
- 1 * BC547, 3 * BC557 transistors
- 1 * 1N4148 diode
- 1 * Amber LED or any other color
- 2 * push-button switches
- 2 connectors for connecting to the mains and to the Infra-Red Panel
- Fuse holder with fuse, at least 4 Ampere/250 Volt, slow switching
- 5 Volt Relay, capable of switching 230 V, 4 Ampere
- 5 Volt power supply
See the schematic diagram on how to connect the components.
Building the Electronics
You can build the circuit on a breadboard. In the picture you can see the circuit as I build it on the breadboard. The whole circuit was built in a plastic housing. You must make sufficient holes in the top and the bottom of housing for the air flow and for the temperature sensor to be able to measure the correct room temperature.
For the power supply I used a small switching power supply which is also connected after the fuse for safety. Note that this device connects to the main power supply so make sure the mains power is switched off when the housing is open.
The Software
As already mentioned, the software is written for a PIC16F1823. It was written in JAL. Since I did not use any specific libraries the total code size is 1500 bytes which fits nicely in the 2k program flash memory this specific controller has.
The software performs the following main tasks:
- Measuring the room temperature using the DS18B20. For this I implemented the one-wire protocol in JAL. The temperature is measured once every 30 seconds.
- Show the temperature on the 7-segment LED displays. These displays are multiplexed in software and are controlled via the 74HC595 shift register since there were insufficient pins available on the controller to control the 7-segments directly.
- Store a preset temperature. For this an up switch and a down switch are used. During this so-called program mode the 7-segment LED display will blink. The temperature program mode is started by pressing the up switch when the device is on and is stopped when no button is pressed for 10 seconds. The minimum programmable temperature is 15 degrees Celsius, the maximum is 25 degrees Celsius and can be changed in steps of 0.5 degrees Celsius. The preset timer is stored as long in non-volatile memory (EEPROM).
- Store a preset timer value. For this an up switch and a down switch are used. During this so-called program mode the 7-segment LED display will blink. The timer program mode is started by pressing the down switch when the device is on and is stopped when no button is pressed for 10 seconds. The minimum programmable timer value is 30 minutes, the maximum is 240 minutes and can be changed in steps of 15 minutes. The preset temperature is stored as long in non-volatile memory (EEPROM).
- Sending the RF message to control the RF Panel Relay if the Thermostat is switched on. This message is repeated every two minutes as to keep the link with the RF Panel Relay alive. The transmission of the RF message is completely interrupt based
- The Thermostat can be switched on and off using the up switch and down switch. The Amber LED will be on when the Thermostat is switched on. When the device is switched on, the preset temperature will be compared with the room temperature and based on the values it will switch the relay – and so the Infra-Red panel - on or off.
The PIC controller runs on an internal clock with a frequency of 32 MHz. The Intel Hex file is attached.
The video demonstrates the operation of the device by turning the device on and switching the relay on – and so the Amber LED and the Infra-Red panel, which is located on the right - by increasing the programmed temperature on the device. The right-most decimal point of the display will light-up shortly when a new measurement was done. After the relay is switched on, the programming of the timer function is demonstrated after which the programmed temperature is lowered, switching off the relay again. After that the device is switched off.
Have fun building your own project and looking forward to your reactions.