Always at the right time your house on temperature
This project make use of a PIC16F648(A) and a DCF77 receiver from Conrad (Orderno. 64 11 38)
With DCF77 runs the clock from the thermostat always on the right time.
Synchronizing isn't necessary anymore.
The temperaturesensor is a DS1820 or DS18B20 and on a HD44780 (or compatible) 2x16 LC-Display becomes day, date, time, temperature (with 0.1°C precision) and an indication which temperature adjustment (economy- or comfort temperature) is active.
For each day there are 4 ON/OFF times to program, ON means here switch to the comfort temperature and OFF to the economy temperature.
A handy option is for people who work at different times (shift work) because it is possible to program the clock with a 2-weeks scheme.
Virtual front as example how this clock-thermostat can be build.
Controlling the clock-thermostat is very simple, buttons and commands to synchronize the clock are left away because of DCF77.
There are set 2 temperatures, a Low economy- and a High comfort temperature.
Only 4 buttons to control everything.
Button 1 switches manual from L (economy) to H (comfort) temperature and vice versa.
Button 2 sets the comfort temperature higher per 0.5°C.
Button 3 sets the comfort temperature lower per 0.5°C.
Button 4 must pushed for 2 seconds to go to the "timer adjustmentsmenu" (see further).
The economy temperature, (when nobody is at home or at night) stays normally always at the same temperature (±16.0°C).
Set this temperature eventually higher by pushing button 1 and button 2 at the same time or lower by pushing button 1 with button 3, but normally this is never necessary.
When switching the power on, the PIC let see an intro for a few seconds, when the paper manual is lost, then you can see where to find information about this clock thermostat.
After that shows the LCD the version number from the PIC program and in what mode the week-timers are.
Then the PIC waits till it get a signal from the DCF77 module (receiver).
When searching does take more than 45 seconds, the message "No DCF signal" follows.
The PIC stays searching until it have a decent timesignal reception.
The manual control from the heating is working when there is no DCF signal, only the timers don't work.
When there is a signal found, it search to the begin from a new minute, this will take maximum 1 minute.
The timebar gives the left time.
If the whole timebar is full, then there is no startsecond found and the message "No DCF signal" appears again.
When the startsecond is found, the bits are gonna filled with time and date.
This takes exactly one minute.
If the whole timebar is full, the actual time and date is complete.
The picture above shows the display how it looks most of the time.
It shows the day with a small 1 or 2 which indicates the active week.
If there is choosen for 1-week timers, then this digit is not displayed.
Right to the day stays the actual time and at the beginning from the second line the actual date.
Direct after the date stays a bold L or H.
A L means heater system Low (= economy temperature) and a H means heating system High (= comfort temperature).
Right on the bottomline stays the actual, by the DS1820 measured temperature with 0.1°C precision.
By pushing button 4 (adjust) for two seconds the program jumps to the "timer adjust menu", starting with Monday.
Select with this same button 4 the day which must be programmed by pushing a few times on this button.
When is choosen for the 2-weeks scheme than must, to go for example to Wednesday from the second week, first stept through the first week.
The small digit after the day shows which weeknumber is adjusted.
When there is no push on button 4 for a few seconds, the program goes to normal mode again.
If the choosen day is on the display, then push button 1 (on/off) to adjust the on/off times.
For every day there are 4 blocks with each an ON and an OFF time which can be programmed, but it's not obliged to use them all four.
It's also not obliged to program always an OFF time.
When there is no push for 30 seconds on a button, then the eventually adjustments are stored in the EEPROM memory from the PIC and the program jumps back to normal mode.
Adjust the hours with button 2 (0...23) and the minutes with button 3, with steps from 5 minutes (00...55).
By pushing the button continue the time increases automatically.
When the right ON switchtime is adjusted, push again on button 1 (on/off).
The PIC program makes it impossible to adjust a lower time than the previous time.
It is not obliged an OFF time, the heater will stay ON (= at comfort temperature) till it comes to an OFF switchtime from an other day.
When the right OFF switchtime is adjusted, push again on button 1 for eventually adjustments from the blocks 2, 3 and 4.
When change an ON or OFF time from a block then all the times which comes after the anew adjusted time from that day are erased to prevent that adjustments are still changed in a wrong time later.
Push button 4 (adjust) to go to the next day.
(If there is no push on button 4 within a few seconds then the adjustments are stored in the EEPROM memory from the PIC and the program jumps back to normal mode).
For the next day there are again 4 blocks to adjust like the way above described.
When this day must be programmed exactly the same as the previous day, then the 4 blocks can be copied by pushing the buttons 1 and 2 together.
The 'C' leftunder in the display let the user know that the copy is happend.
Because it happens many times that all the days from a workweek are all the same, the workweek (Monday till Friday) can copied at once by pushing the buttons 1 and 3 minimal 1 second together.
This second waittime is done against accidentally pushing the button-combination, else the whole week would overwrite by accident.
All adjusted times from Monday are copied to Tuesday till Friday.
Attention: it's not possible to copy out of Monday.
If there is a day where nothing must be switched but there are still adjusted times on that day, then all the 4 blocks from that day can be erased by pushing buttons 2 and 3 minimal 1 second together.
What mode (economy or comfort) the thermostat will have depence on how the situation was at 00:00 from that day, because if all the timerblocks from that day are empty ( - - : - - ) then there is nothing switched.
After adjusting the timerblocks and the clock-thermostat comes in normal mode, there stays an asterisk for the timeindication (see photo).
This means that the time on the display is not the actual time anymore, because during adjusting from the timerblocks the PIC can not measure the DCF77 time at the same time, so the clock runs a few minutes slow.
But don't worry, after maximal 2 minutes the time is actual till the second again and the asterisk is disappeared.
Adjusting the timers looks intricate, but really, when this project is builded, the story from above would be clear after playing a few minutes.
Cancel timers for a while
By pushing button 1 (PORTB.0) for a longer time is it possible to cancel the timers for a couple of hours.
To set the temperature at home on comfort manually, press button 1 (on/off, H / L).
On the display changes the L (Low) into a H (High) and shows the temperature indication on the display the adjusted comfort temperature for a few seconds, after that shows the actual temperature again.
The clock-thermostat stays on comfort mode until another push on button 1 or till an adjusted OFF timer is reached.
This OFF timer switches the clock-thermostat from H (comfort) to L (economy) temperature adjusting.
If that's not the intention then press button 1 a bit longer so that the hour counter starts counting up.
As long as the 'timers cancel time' runs will the thermostat stay in the adjusted economy or comfort temperature mode, irrespective of there are timers switching within that time.
The display shows how many hours are left, the counter counts one hour back every hour.
When the time has expired then the heaters are regulated in accordance with the timeradjustments again.
A maximum from 99 cancel hours can adjusted.
This 'timer cancel time' is direct interrupted when button 1 is pushed again.
What mode (economy or comfort) the thermostat will have depence on how the situation was when button 1 was pushed, indicated with a L or a H on the display.
On the display on the photo hereabove will the thermostat stay for (yet) 14 hours in the H (comfort) mode, irrespective of there are timers switching ON or OFF within that time.
After exactly 1 hour the counter on the display stays on 13 hr and counts further every hour till the time is passed.
When the time is passed the thermostat will be stay in the choosen mode (H or L) if there are no timers programmed for that day.
When there are timers programmed then the thermostat will stay in mode H or will switch to L, depending from how the timers are programmed and what mode it must be for that moment.
When there is nobody at home for a longer period (i.e. on holiday for a couple of weeks) and there must nothing be switched,
it is not necessary to erase the timerblocks or to cancel the timers.
It is more handy to adjust the comfort temperature temporary to a lower temperature, eventually equal to the economy temperature.
If the timer switches ON or OFF doesn't matter anymore, the heater switches only to ON when the temperature is really low.
When the comfort temperature is selected, but it's still not warm enough, then it's easy, keep button 2 pressed and the comfort
temperature adjustment raises automatic with steps from 0.5°C.
Button 3 pressed decreases the comfort temperature automatic with steps from 0.5°C.
Change the temperature by pressing the button continue, the value will changes automatically.
The economy temperature is adjustable between 5°C and 18°C and the comfort temperature between 7°C and 32°C.
There is no indication on the display which indicates if the heater is actually on or off,
those who want this can connect a LED with 1k serial resistor over the relay.
The L and the H indicates only if the economy or the comfort temperature is selected.
The temperature is measured 3x per minute.
The thermostat has a hysteresis from 0.2°C, which means that if the temperature is adjusted on for example 20.0°C the heater goes on when it is cooling off till 19.9°C and goes already off when it is 20.1°C is.
This looks a little les but in practice there is an overshoot which makes that the temperature can raise till 20.5°C or more, this depence very much from where the DS1820 temperaturesensor is placed.
If for example the DS1820 is placed direct above a radiator, then it measured in no time a temperature from more than 20.1°C and it will switch the heater within a minute to off again.
After programming from the PIC itself the default economy temperature is adjusted to 16.0°C and the comfort temperature to 20.0°C.
When these temperatures are changed by the user then these adjustments are (only after a few minutes) saved in the EEPROM from the PIC so that after a power failure the user adjusted temperatures are holded.
After a power failure starts the PIC always on the adjusted economy temperature, even if comfort temperature was selected before the power failure.
As far as known, not any commercial clock-thermostat have a more-weeks timer-scheme possibility.
The actual weeknumber (1 or 2) stays behind the dayname.
Every week, when Sunday changes at midnight to Monday, changes the weeknumber automatically.
If the actual weeknumber is wrong (whatever what reason), then the weeknumber can be changed by pushing button 4 longer than 5 seconds.
When this 2-weeks option isn't used, then it's possible to change the clock-thermostat in a normal 1-weeks mode.
This happens as follows:
- Switch the power OFF from the PIC circuit.
- Keep a button pressed while the power is switched to ON again.
- The display shows for a few seconds in which weekmode the timers work.
- From now on the PIC is switched from 1 to 2-weeks mode or the other way round.
There is no weeknumber behind the dayname displayed, when the PIC stays in 1-week mode.
The display shows for a few seconds in which weekmode the timers work.
Take care for a nice stabilised 5V supply.
Pay attention for C5, it is not the usual value 100n, but this time a 1µF tantalium, if you do not then the PIC can sometimes crash when it is program his EEPROM (current peaks in the powerline where a 100n capacitor is not enough to catch this peak).
Place R1 and C2 on the side from the DCF77.
Connect the four buttons direct to PORTB.0 till PORTB.3 without pull-up resistors, because the internal pull-ups from the PIC are activated.
Any type 5V relay is allright, but if the current is greater than 100mA then take for T1 a BC337 transistor.
Scheme DCF77 clock-thermostat
|LCD||HD44780 (or compatible) 2x16 characters|
|DCF77||Module, Conrad 64 11 38|
|IC2||DS1820 temperature sensor|
|T1||BC547 NPN transistor (evt. BC337)|
|R6||0,0Ω (or just a wire) or resistor for LCD backlight|
|S1...S4||Make contact, pulser|
|Relay||Own choice, 5VDC, make|
Handy for own build extensions is the function from PORTA.5, so that the heater can set ON or OFF with for example an infrared remote control or a telephone circuit (in the future also on this website) so that this thermostat can set ON or OFF by telephone.
Without LCD it is unknown what a pulse on PORTB.0 does (ON (H) or OFF (L)?).
By making PORTA.5 low and then a pulse on PORTB.0 (from button 1) the heater will always go to the economy mode.
If it must be the comfort mode then make first PORTA.5 high again and then give an other pulse on PORTB.0 (from button 1) so that is switched from L to H.
At 23:00 will the heater go ON by timer, but a friend asked you for drinking a beer at his home.
The heater will heat the house for nobody.
It would be nice if you can ring to your house to tell the heater it don't have to go on for this time.
With the help of a telephone circuit to cancel the timers for a few hours, the telephone circuit must give on PORTB.0 a pulse from a few seconds so that the "timer cancel time" function is activated (see here).
The counter increases with 1 hour per 0.5 second, so if for example the timers must canceled for 4 hours then there must give a pulse from 2.5 seconds (4 x 0.5sec + an extra 0.5 startsecond).
This clock-thermostat works ofcourse with all types of boilers, but is not modulating (something which is possible on the newest boilers), because the manufacturers do mysterious about the data protocol from i.e. OpenTherm® or the Nefit protocol...
If it is in great demand, maybe in the future a 3 and 4 weeks timer clock-thermostat.
Also in the planning is a DCF77 clock-thermostat which can be controlled with a RC5 remote-control, so that with the TV-remote can switched between H and L and vice versa.
Only a TSOP1736 infrared receiver is needed to connect on a port.
And if it succeed, a possibility to connect the telephoneline direct to the circuit for telephone remote control.
This all should realized with a 28-pin PIC, in any case not with the PIC16F648.
Unfortunately no .bas and .hex downloads because there is a bug in the program, the PIC crashes sometimes.
|Download DCFTHERU.HEX V-1 file to program in a 16F648A|
|Download DCF77_Thermostat_V-1_uk.bas, the sourcecode for Basic|
|Download scheme as PDF file|
|The working from the DCF77 time signal|
|Datasheet DS18B20.pdf temperaturesensor|
|Datasheet HD44780.pdf LCD (Liquid Crystal Display)|