Arduino Thermostat: Redux

October 28, 2011 | In: Development, Home Improvement

Well I had to bust out some modifications to the code today (again, very pleased I cut that USB hole!) to control temperature over-shoot, allow me to view the temp before rounding, and to add a larger font for the manual mode temp set screen.

The over-shoot was a problem I originally anticipated, but commented out in the code because I wasn’t sure if it was necessary. It is. When I have both the electric baseboard and the gas fireplace on, the temperature rises too fast for the [designed] 5 minute relay interval. This caused the temp to briefly surpass the set temperature for about 10 minutes until the room started cooling back down.

Here’s how I’ve controlled the over-shoot:

At the start of each cycle, I calculate the difference between the current temperature, and the last cycle’s temperature. If this number is positive (temp is rising) then I check it against the difference between the set temperature and the current temperature – to find how long until we’ll reach our target.

If that time is less than 5 minutes, I set a timer to expire exactly when that target will be reached. The timer then calls the heat off function.

Testing this revealed a shocking 100% accuracy. With the buffer set to 0 and the temp set at 21, the heat turned off at exactly 21.00 degrees. In practice I have a buffer of .35 degrees, to allow the temp to rise in this case to 21.35. I chose to do this so that the heaters would remain off for longer, but the display would still round to the desired set temperature.

I’ve also posted the code here, due to requests from members of arduino.cc 🙂