Go Down

### Topic: Online Thermostat (Read 9755 times)previous topic - next topic

#### draythomp

#15
##### Apr 06, 2011, 04:47 pm
I built two of them and had them working for a few months now.  It's not easy, but there is a lot of information out there to help you.  I have my source posted online; you're welcome to grab and modify as you need.
Trying to keep my house under control http://www.desert-home.com/

#### pluggy

#16
##### Apr 10, 2011, 10:23 am
From experience it can be quite an undertaking getting an arduino to satisfactorily control a heating system.  Jut having a simple set point and turning the heating on and off leads to large temperature ranges.  There is huge latency in a heating system and what happens is that 10 to 40 minutes after the heating is turned off, the inside temperature continues to rise due to the hot water in the system.  Old school thermostats have carefully designed 'forced feedback' to reduce the effects of this hysteresis/latency (basically a small heating element inside the thermostat casing that heats the bimetallic sensor and causes it to switch off earlier).  I measure the flow temperature to the radiators, the outside temperature as well as the inside room temperature and some fancy coding to get it better than an old school system.   It's controlled as much by the temperature of the water as the room temperature, and the set point for that comes from how cold it is outside.  On a good day it can keep it +/- 0.1 degrees C, +/- 0.2 generally, and old school thermostat with a decent forced feedback can manage +/- 0.5 C.  A simple single set point on an arduino can be +1.5/-0.5 which is akin to a simple thermostat without forced feedback.

This is my bit of the sketch that decides whether the heating is on or off.  The calculations are from experience monitoring my system, your number will likely be different.

Code: [Select]
`void heatingctrl(){           boolean heaton = false;        heatingloop = time + 180001;  // 3 minute check period    int tempshort = tempch - dallas[4];  //  set temp - temp in living room        int inoutdiff = tempch - dallas[1];    float wtemp = (inoutdiff * 2.75) + tempch + 48;      int watertemp = int(wtemp);    int watertemplow = watertemp - 120;  //  7.5 degrees less than nominal water temp    int watertemphigh = watertemp + 120;   // 7.5 degrees more than nominal water temp    unsigned long heatonofftime = time - heatingchange;            if (tempshort > 0){heaton = true;};  // on if below temp       if (inoutdiff > 120 && heatingtrenddown && tempshort >= 0){heaton = true;};  // on for  if temp trending down     if (!heatingtrenddown && tempshort <= 2){heaton = false;};  // off if trending up            if (dallas[3] > watertemphigh && tempshort <= 2){heaton = false; heatingloop = time + 420001;}; // turn it off for 7 mins if the water is warm        if (dallas[3] > (watertemphigh + 120) && tempshort <= 5 && tempshort > 2){heaton = false; heatingloop = time + 600001;}; // turn it off for 10 mins if the water is hot     if (tempshort >= 7){heaton = true;}; // on whatever if its well below temp    if (tempshort < 0){heaton = false;}; // off whatever its above temp    if (heatonofftime > 180000){heatingloop = time + 30000;}; // if heating has on or off for more than 3 minutes, come back here in 30 seconds.    //if (heatingon && tempshort == 0 && dallas3 < watertemplow){heaton = true;heatingloop = time + 180001;}; // keep it on if the water is cool, the room is at temp and it was on last time    //if (tempshort <= 2  && dallas3 > 1120){heaton = false; heatingloop = time + 400101;};  // absolute off if water is above 70 degree and temp is close    //if (tempshort > 8){heaton = true;};    if (heaton){       digitalWrite(chrelayPin, HIGH);             if (!heatingon){heatingchange = time;} ;      heatingon = true;           }    else    {       digitalWrite(chrelayPin, LOW);       if (heatingon){heatingchange = time;} ;      heatingon = false;       //heatingchange = 0;    }  }`
http://pluggy.is-a-geek.com/index.html

Go Up

Please enter a valid email to subscribe