EcoRenovator  

Go Back   EcoRenovator > Improvements > Appliances & Gadgets
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Display Modes
Old 10-13-11, 06:53 AM   #1
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 960
Thanks: 188
Thanked 110 Times in 86 Posts
Default Arduino based thermostat

As of today I am the proud owner of an Arduino Duemilanove Woohoo!

One of the things I'd like to do with it is to replace our thermostat. Not that the one we have is bad (it's saved us a LOT on heating bills since I installed it 3 or 4 years ago), but there are a few things I'd like to change. Some of these things are available in more expensive models, others could be worked around with a second or third t-stat, but I'd like to keep it simple and cheap, plus I like the challenge

I'm sure that I'm not the only one who would like to have a thermostat tailored to her/his house and individual heating&cooling needs, so I started this thread so that we could all pitch in our wants, ideas and expertise to get this project going. I'll start by describing what my t-stat does, then vaguely what I'd like it to do. I'd like others to do the same to give ideas about functions I may not have thought of. Any help with algorithms or even arduino code is very welcome.

My thermostat has only two programmable temperatures - night and day - with resolution 0.25°C. The programs are broken into 24 one-hour intervals, and only three programs are user-adjustable. There are also a few programs hardwired into the unit (always day temp, always night temp, always above 7°C, etc.). The program we use most is day from '0900' to '2100', night from 2100 to 0900. If I want to change the temperature, for example the house will be empty between 1700 and 2000, then I can press the 'night' button and it will hold night temperature until the next change in the program's settings, or I can set the night temp for X hours, after which the t-stat resumes whichever temperature the program now calls for.
This is better than a basic t-stat, manual or analog, but doesn't always allow me to fine tune it the way I want, so here is my wishlist:
  • Temperature changes more often than every hour. Every 15 minutes should be better.
  • More temperatures, not just two for night and day.
  • Inputs from more rooms.
  • 'Intelligent coasting'. The t-stat will do nothing if there is a temperature change within 15 minutes that would turn the boiler off. That way the boiler doesn't run for only a few minutes when the heat wouldn't make its way to the house.

Bonus question: I know that certain high-end thermostats measure outdoor temperature, but how is that information used while heating/cooling?

EDIT: This just crossed my mind for something more advanced: A sensor to monitor whether the sun is shining, then adjust the set on-time accordingly.
Also, measure humidity and adjust heating/cooling to perceived temperature (heat index).

__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.

Last edited by Piwoslaw; 10-13-11 at 08:45 AM..
Piwoslaw is offline   Reply With Quote
The Following User Says Thank You to Piwoslaw For This Useful Post:
Quest (10-13-11)
Old 10-13-11, 09:21 AM   #2
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

Woo, cool project! Congrats on being an arduino owner. They're SUCH nifty devices.

It does sound like your thermostat is a bit limited compared to the ones I've seen. The ones I've seen/used are either a 5-2, 5-1-1, or 7 day thermostats. With the 5-2 you have one program for the weekdays and one for the weekend. The 5-1-1 gives you a program for the weekdays, one for Saturday and one for Sunday. The 7 day gives you a different program for every day of the week (and usually includes some way to copy to make programming easier/faster). Each program has four time points which can be adjusted in 15 minute incriments. At these points you select what temperature you want the house to be and thats what it aims for. That is the basics of it. If you wish to override the programming you can easily just push the up/down arrow buttons to adjust the temperature. It'll stay at that temperature until the next time point. If you wish to hold that temperature indefinitely you push a 'hold' button and it keeps that temperature until you push the hold button again. Some thermostats will allow you to adjust how much sway in temperature it'll allow. Most are set I believe to 1F. So, if you have a room set to 70F, the furnace/boiler will kick on at 69F and increase the temperature to 71F. You can adjust it to increase this temperature sway to reduce short cycling of the furnace/boiler.

I think the outside sensor is more so for heat pump applications and/or hydronic floors that have a high thermal mass. Both of these heating systems take time to get heat into the house and if there is a sudden drop in outside temperature the thermostat can kick the heating system on before the house temperature actually starts to drop.

A photoresistor would be a cheap and easy way to see if the sun is shining on the house. You could allow another degree or two drop if there is a strong sun and you know it'll start heating up the house without the furnace perhaps. I know that would work nice for something like my attic heat fan.

I'll definitely have to think more about this though. Its a very cool project.
__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline   Reply With Quote
The Following 2 Users Say Thank You to Daox For This Useful Post:
Piwoslaw (10-13-11), Quest (10-13-11)
Old 10-13-11, 10:58 AM   #3
strider3700
Master EcoRenovator
 
Join Date: Dec 2008
Location: Vancouver Island BC
Posts: 745
Thanks: 23
Thanked 37 Times in 30 Posts
Default

I believe my thermostat uses the outside temperature to decide when to switch from the heat pump to the electric furnace.

I use the outside temperature measurement to decide when to light the fire.
strider3700 is offline   Reply With Quote
Old 10-13-11, 11:44 AM   #4
hamsterpower
Apprentice EcoRenovator
 
Join Date: Oct 2009
Posts: 142
Thanks: 0
Thanked 11 Times in 11 Posts
Default outdoor temp sensor

Other systems that use an outdoor temp sensor, use that sensor to adjust how hot the boiler runs. My system has a few zone thermostats and one on the boiler itself. I could replace the thermostat on the boiler with one that auto adjusts based on outside temp.

The colder it is out side, the faster the house loses heat, the hotter the boiler runs.
hamsterpower is offline   Reply With Quote
The Following User Says Thank You to hamsterpower For This Useful Post:
Piwoslaw (10-13-11)
Old 11-24-11, 07:17 AM   #5
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 960
Thanks: 188
Thanked 110 Times in 86 Posts
Default

Quote:
Originally Posted by hamsterpower View Post
Other systems that use an outdoor temp sensor, use that sensor to adjust how hot the boiler runs. My system has a few zone thermostats and one on the boiler itself. I could replace the thermostat on the boiler with one that auto adjusts based on outside temp.

The colder it is out side, the faster the house loses heat, the hotter the boiler runs.
My boiler has to be manually adjusted, but if there is a pot on the other side of the knob, then maybe the boiler's max temp could be adjusted by the Arduino. That would require some measurements and soldering, and I'm not sure if it's worth the trouble since I only adjust it 2-4 times per year.

Something that came to mind today is to adjust the set room temperature as a funtion of outdoor temperature. During the coldest days, when day/night temps would be as low as -20°C/-30°C (-4°F/-22°F), the boiler would be on almost nonstop struggling to reach the set daytime temperature of 18°C/64°F, so I'd manually set the nighttime temp (16°C/61°F) for 24h to allow the system to turn off every now and then. Since the radiators never had time to really cool off, then there was lots of radiant heat to make up for the cooler air temp, so it wasn't too uncomfortable.

The "thermoduinostat" could be programmed to automatically lower the daytime (and maybe nighttime) temperature to ease the thermal loss when it's really cold.
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline   Reply With Quote
Old 12-07-11, 09:27 AM   #6
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

Any updates on this? I think its a very interesting project.
__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline   Reply With Quote
Old 12-07-11, 12:08 PM   #7
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 960
Thanks: 188
Thanked 110 Times in 86 Posts
Default

Quote:
Originally Posted by Daox View Post
Any updates on this? I think its a very interesting project.
Nothing tangible yet, but I'm slowly piecing things together:
  • I bought two humidity sensors and found out how to use them w/ the Arduino,
  • I got an LCD screen, but haven't been able to test it (I need to solder pins to it first),
  • I've run some cables from the basement to the livingroom and outdoors,
  • I made a small cover for the outdoor sensors, I hope to install it before the weekend, time and weather permitting,
  • The algorithm for the program is swimming around in my head, maturing every day, with many of the subroutines already tested,
  • I still have a few parts to pick up, like pins and a relay.
I'll post more details as everything starts to fall into place.
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline   Reply With Quote
The Following User Says Thank You to Piwoslaw For This Useful Post:
Daox (12-07-11)
Old 12-06-12, 02:40 PM   #8
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 960
Thanks: 188
Thanked 110 Times in 86 Posts
Default

After a year of having too many more important things to do, here is an update.
- I gave up fiddling with analog and switched to digital (DS18B20) temperature sensors.
- I'm still experimenting with the humidity sensors.
- I got a shift register to be able to control it with buttons, but so far I'm still changing parameters via USB.
- The LCD has been acting up lately, at present only the top row is displayed.
- I got a relay and found out that it requires more current than should go through the Arduino, so I got another relay, this time a solid state one.
- A month ago I finally got some time to write some simple code to keep the room temperature within 0.5°C of 17°C. In short, it checks the temp every 5 seconds and if it is below 17°-0.5°C (resp. above 17°+0.5°C) for 4 consecutive readings it (resp. de-)activates the relay.
- It is hooked up in parallel with the normal room thermostat, with the latter set to a slightly lower temperature. The room t-stat is supposed to be a backup in case the Arduino t-stat fails, but also keeps a lower temp when I need it (I disconnect the Arduino t-stat then).
- I have a clock function working well, but I still haven't implemented any programmable temperature changes. Any hints on how to do it?
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline   Reply With Quote
Old 12-06-12, 03:52 PM   #9
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

Woohoo I'm happy to see some progress here.

Quote:
Originally Posted by Piwoslaw View Post
I have a clock function working well, but I still haven't implemented any programmable temperature changes. Any hints on how to do it?
Maybe you could post your code as is and we can help add to it? Unless you were thinking of talking in general.
__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline   Reply With Quote
Old 12-07-12, 01:08 AM   #10
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 960
Thanks: 188
Thanked 110 Times in 86 Posts
Default

I was thinking about some general ideas, eg which data types to use and how to implement them. Algorithms, not code letter-by-letter. Like should I make a table with 4 elements (4 times when the temp can be changed) and each table element will hold info of the time of change and the new temp. Or maybe records/structs/pointers/etc., which would allow the number of time changes to be variable? I'd also like a neat function which will tell me how long until the next temperature change, or at least if that time is < or > than 30 minutes, for example.

But I'll happily share the code I already have In pieces anyway, since the whole program is really messy at the moment: lots of unneeded stuff which hasn't been removed yet

First, the clock function. It adds 1 second for every 1000ms that have passed since the previous call. If a second has been added, then the function returns value 1, else 0. This is not my idea, I got it from here.

Code:
#define MAX_MILLIS_VALUE 34359738
unsigned long current_millis_value = 0, previous_millis_value = 0;
unsigned long m = 0;
int seconds = 0, minutes = 57, hours = 9, days = 0;

char clock(void) {  // function adds 1 second for every 1000 milliseconds since last call
  char ret_val = 0;
  current_millis_value = millis();
  if (current_millis_value < previous_millis_value) {  // if millis overflows
    m += MAX_MILLIS_VALUE - previous_millis_value + current_millis_value;
  }
    else {  // if millis has not overflown
      m += current_millis_value - previous_millis_value;
    }
  if (m>999) {
    ret_val = 1;
    seconds++;
    m = m-1000;
    if (seconds>59) {  // if seconds == 60
      minutes++;
      seconds = 0;
      if (minutes>59) {  // if minutes == 60
        hours++;
        minutes = 0;
/*    if(hours%5==0) // adjust the time with -2 seconds every 5th hour.
      seconds = seconds - 2;  // this will cause seconds to be -2,
                             // therefore seconds can't be unsigned.
*/        if (hours>23) {  // if hours == 24
            days++;
            hours = 0;
            if (days>6) days = 0;  // if days == 7
        }
      }
    }
  }
  previous_millis_value = current_millis_value;
  return ret_val;  // returns 1 if seconds was increased
}
Here's the program itself, I weeded out a bit, so it may not compile as is.

Code:
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 1  // digital pin for One Wire signal
#define TEMPERATURE_PRECISION 12

LiquidCrystal lcd(12, 11, 9, 8, 7, 6);  // Initiate digital pins for LCD
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 

#define READING_SEC 5 // seconds of delay between readings
#define TEMP_SENS_NUM 4  // number of temperature sensors
float temp[TEMP_SENS_NUM], last3temps[3];

#define RELAY_PIN 13   //  relay to boiler/furnace
#define SET_TEMP 17.1  //  set room temperature
#define DELTA 0.5      //  allowed variation from SET_TEMP

#define TEMP_OUT 0     // outdoor temp
#define TEMP_IN 1      // indoor temp
#define TEMP_SUP 2     // boiler supply temp
#define TEMP_RET 3     // boiler return temp

// ds18b20 temp sensor addresses
DeviceAddress Temp_Sens_Addr[TEMP_SENS_NUM] = {{0x28, 0xCD, 0xF9, 0xE8, 0x03, 0x00, 0x00, 0x2F}, {0x28, 0x21, 0x26, 0xE9, 0x03, 0x00, 0x00, 0xC5}, {0x28, 0x2F, 0xE6, 0xE8, 0x03, 0x00, 0x00, 0x7B}, {0x28, 0x8A, 0x17, 0xE9, 0x03, 0x00, 0x00, 0x28}/*, {0x28, 0xCC, 0x13, 0xE9, 0x03, 0x00, 0x00, 0xF0}*/};


void Boiler_State(void)
{
  if ((temp[TEMP_IN] <= (SET_TEMP - DELTA))&&(last3temps[0] <= (SET_TEMP - DELTA))&&(last3temps[1] <= (SET_TEMP - DELTA))&&(last3temps[2] <= (SET_TEMP - DELTA))) digitalWrite(RELAY_PIN, HIGH);
  if ((temp[TEMP_IN] >= (SET_TEMP + DELTA))&&(last3temps[0] >= (SET_TEMP + DELTA))&&(last3temps[1] >= (SET_TEMP + DELTA))&&(last3temps[2] >= (SET_TEMP + DELTA))) digitalWrite(RELAY_PIN, LOW);
}

void setup(void) 
{
lcd.begin(16,2);  // set up the LCD's number of columns and rows
pinMode(BUTTON_PIN, INPUT); 

sensors.begin();
for (char i=0; i<TEMP_SENS_NUM; i++) sensors.setResolution(Temp_Sens_Addr[i], TEMPERATURE_PRECISION);
}

void loop(void) 
{
if (clock()) // if clock increased seconds
{
  if (!(seconds % READING_SEC)) {
    sensors.requestTemperatures(); // Send the command to get temperatures
    for (int i=0; i < TEMP_SENS_NUM; i++) {
      temp[i] = sensors.getTempC(Temp_Sens_Addr[i]);
    }
    Boiler_State();
    last3temps[0] = last3temps[1];
    last3temps[1] = last3temps[2];
    last3temps[2] = temp[TEMP_IN];
    }
  }
};

__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.

Last edited by Piwoslaw; 12-07-12 at 01:11 AM..
Piwoslaw is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design