Online Thermostat

This is my first big project with the Arduino. I'm trying to make a thermostat that I can set from the internet. I've gotten to the point that I can sense the temperature using a thermistor. I also have the official Arduino Ethernet board. I tried using Pachube, but was having problems with it. I would rather not use pachube if I could avoid it. I am planning on using a relay to control the heater or AC.

What I would like to be able to do is to have a page of some sort that I can access from a browser using any computer. On the page I would like it to display the current temperature in my house, the current temperature setting, and whether the system is on or off. I would also like to be able to turn the system on or off and set the temperature for the thermostat.

My first question would be what ethernet library(ies) would best help me with this. I've looked around and have noticed that there are a few libraries out there. If I can get some suggestions on the libraries to use, it would be a good starting point for me. Thanks!

I'd start with the regular library and use it until it doesn't do something you want it to do.

I did this with two thermostats in my house as part of an energy saving project I've been working of for a couple of years now. I don't allow the thermostats to be seen outside the house, but I control them over my house network. Thermostats on the internet didn't seem like too good an idea to me.

This is an ongoing project (meaning I'll probably never completely finish it), and what I have gotten done is available on the site above.

Think it would be easy to control your heating over the internet but you should apply some security measures, at least a password.

Did some experiments with - http://www.no-ip.com/ - to get an webaddress that can be tunneled (most routers support this) to my Arduino behind my firewall etc. worked quite well.

I have a system set up to do this, but I use a hacked NAS box as a small server that does the web interface and the arduino is connected to it via USB. I use lighttpd (sort of a poor mans apache) on Debian Linux and use a password protected folder for the heating controls. I don't think an arduino would have enough grunt to do all its doing now and run a web interface with security as well. The server draws pretty graphs from the data the arduino collects which is obviously way beyond an arduino. It does other duties not connected with the arduino (print server and local file server) on top of that. It runs it's own firewall (another no-no for an arduino) to keep the bad guys out. It doesn't show anything but a standard web interface (port 80) to the world but shows more to a few select IP addresses that I control. As it is, on the heating front, the arduino just knows how to maintain a temperature and the server alters that to suit different times of day (standard cron jobs) or it can be overriden from the web. There isn't an 'off' position as such but turn it down far enough and it doesn't come on.

http://pluggy.is-a-geek.com/

Peek behind the password protected 'Heating Controls' :

I decided to go with the Tiny Web Server library found here: http://www.webweavertech.com/ovidiu/weblog/archives/000484.html

I got the BlinkLED example working and it seems to have the functionality I'm looking for. I just need to figure out the code to work it for my needs. If anyone has any ideas, I could probably use some help. I'm not a great coder... I'm trying to decipher the code in the program and matching it with the html in the files. I'm not exactly sure what points to where at this point.

Back to the "security" issue...

Perhaps needing a password to alter the thermostat is overkill for your needs...

But if you live in an area where pipes can freeze if the heat is turned off, maybe the following would be wise, not just to thwart malevolent people, but also mis-behaving circuits and programming?

Equip your system with a SIMPLE, old-fashioned, hard wired ALTERNATIVE "turn the heat on" system which will over-ride your fancy web-etc based system any time the fancy system is failing to say "turn heat on" if temperature is below, say, 48 F?

The alternative would probably just be a traditional thermostat wired in parallel with whatever turns the heat on when your fancy system thinks there's a need.

If your house is often unattended, perhaps another traditional thermostat should be wired in series with your fancy circuits to over-ride the "turn heat on" signal any time the house temperature is above, say, 75 F?

An ounce of prevention....?

===
While it doesn't address your "control the thermostat" wants, a system for watching the temperatures in a home from anywhere on the internet is explained at.....

@tkbyd
You are definitely right, and keep in mind that a good heating system has at least two temp sensors (inside, outside) but probably more that can trigger the system as you described. But it would be neat if only the part that is in danger of freezing would be heated => intelligent valves (per room?)

Much depend on how the building is located, what is it coldest point, windcatch etc.

2 cnts :slight_smile:

@tkbyd - Thanks for your suggestions. The site that you posted about displaying the temperature looks like it requires a computer running. I'm trying to avoid having a computer running while I'm away. It just sucks up too much power. I would rather it all be controlled with the Arduino which consumes much less electricity. I think the Tiny Web Server that I mentioned earlier should do the trick for me.

I did think about the too cold issue to prevent freezing. I actually have a space heater that works nicely and it has an anti-freeze setting. It keeps the place warm enough to prevent the pipes from freezing.

I do like the idea of having a simple thermostat that won't allow the temp to go too high though. Just in case. I will have to do some testing when I get things set up

That's the reason I use a hacked NAS box and not a computer, it uses around 5w - less than a unit a week. All the advantages of a computer without the computers appetite for power.

It doesn't run Windows though.....

http://consumer.media.seagate.com/2010/01/the-digital-den/seagate-freeagent-dockstar-–-what-is-it/

http://www.jeff.doozan.com/debian/

Below is a simple way I controlled a t-stat just for fun a long time ago. Now days most t-stats are digital, so operating them will probably be more involved, or a special t-stat may be required.

Zoomcat, that is so COOL. My problem with that would be that I would be constantly playing with it to watch the servo move the lever. I'd mess with the temperature constantly just because I could. I may have to use your idea to build a finger that can press my remote control for the TV.

Very clever and fun.

I may have to use your idea to build a finger that can press my remote control for the TV.

Using a pair of 4051 multiplex chips, you probably have total control of a tv remote. Below is a hack I did so I could change tv channels from work so I could watch the news of the first gulf war via a webcam program I had.

http://web.comporium.net/~shb/irmods.htm

Just an update with what I've been doing with this project.

I've started to really work on programming. I've been learning some programming languages. I kind of dipped into C++ and I've really been working on Java lately. I'm thinking about learning some objective-c next and maybe go back and go more in depth with C++. This all kind of random in how I'm choosing the languages because I knew practically nothing except for very basic things about programming before this. I'm hoping that as I go through these languages, it will start to shed some light on the Tiny Web Server programming that I want to use. If there are any coders out there who want to help me out by looking through the code a little bit, it might help to know what language I should be going into. Here's the link again for the Tiny Web Server: http://www.webweavertech.com/ovidiu/weblog/archives/000484.html

I am really starting to enjoy programming though.

Hi all,

I've almost finished this project from Practical Arduino Online Thermometer | Freetronics - it's basically an online thermometer which displays temps from Dallas DS18B20s on a web server.

How easy would it be to extend this project into an online-controllable thermostat? I was thinking of just having a box on the web page where you can input a set point, and then the arduino switches the boiler on and off via a relay.

My programming skills are rank beginner at best, so I'm sure this isn't as simple as I think it is!

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.

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.

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;
    }
  
}