Showing posts with label Thermostat. Show all posts
Showing posts with label Thermostat. Show all posts

Tuesday, May 21, 2013

Thermostat Prototype Stage

This is a continuation of work started in part one

I've finished a usable version of the firmware and have gone ahead and installed the prototype thermostat. It's ugly as sin with all it's interconnects and it's enormous makerbotted case, but it's working. It has a much longer cycle time than the old thermostat which was really short cycling. I'm not sure if I like it better like this or the old way. I think that to be completely accurate it's going to need to anticipate the temperature drop or rise and actually cut out before it reaches the goal temperature. I think the array that I use to average several temp readings over time will need to be adjustable in size too.



There you can see the various parts, the LCD display in back with it's IC2 backpack both from adafruit.com, the diavolino board from evilmadscience.com is my favorite arduino platform for such things, and you can't beat the price either if you're willing to do a little soldering. To the right are the xBee for comm and below that the temp/humidity sensor. That one is the parallax board purchased from adafruit and I'm not wedded to that form factor though I suppose the pins on it would make it easier to include it on a custom board. the analog board below is working great.

I need to add some fail safe logic in the arduino code that make sure that multiple relays aren't on at the same time, it shouldn't happen, but it will be easy to verify.

All the wiring is such a mess, it needs to be all on one board and this will be my excuse to really learn to use some of the open source schematic and board layout tools. I'm not looking forward to that actually as they all look like a nightmare, though some folks seem to do very good work with them. The diavolino was designed with them so I should be able to learn to use them too. 



There it is installed, looking like a total hack on the wall, but it's a prototype and I've done far worse to the house in the name of science ;) The oregon sensor is for temperature verification. I graph the 2 of them together in the computer to make sure that I'm actually measuring the temperature.

The connection software so that it can get it's info from and send data to XTension is all done. It's a very simple human readable protocol. The thermostat doesn't try to do any scheduling or setback by itself, that will all be handled by scripts in the computer so it's own software isn't concerned with such things as what time it is. The clock display is updated from the computer with a regular update that is only for display. If you dont send a clock update for 2 minutes that display changes to tell you there has been a loss of communications to let you know something is up. So far that hasn't happened, the xBee is working perfectly.

The bottom line in the display there showing the outside temp is just a text line message that can display anything. The computer can send any kind of alert to display there. At the moment I'm only sending the outside temp, but it could show anything useful there. 



The web interface through XTension is working great too. I now have 5 thermostats connected to the computer in 2 separate physical locations. The "Beach" one is at Nana's place near the beach and is connected over the internet. I have 2 wifi thermostats from radiothermostat.com, an omnistat, an aprilair communicating thermostat and until the last lightening storm an RCS RS485 model that I loved sadly it died and is now replaced with a home made one. XTension supports all these kinds now and if anyone wants to use another kind let me know, as long as it has a documented protocol. The latest honeywell wifi thermostats that home depot is carrying now are locked down and they seem to have no interest in interacting with any other systems at all, so dont buy those.


The backlight level is not automatic yet, I just control it from a unit in XTension. So when I go to bed it dims it down and when we get up in the morning it turns it up for easier viewing. I'm also tracking free memory in the arduino and sending that as a unit update. In the above example it's 0 because it's never actually sent a change since the first few minutes. There are a lot of variables and the array of floats to average for temperature so I was concerned that it would stop working after time if I had bugs in the code. With each loop through the main code it checks it's available memory and if it changes it will report it up to XTension. So far doing it's thing for several days now the available memory hasn't changed at all which is a good thing.

So whats next? I dont really like the display, I think that version 2 might have a graphical display for fancier display. I used an expensive temp/humidity module that is very accurate, but I had to make an offset parameter anyway so whats the point, there are much cheaper modules that are easier to use that I will investigate too. 

Since it's going to be an xBee socket the final product will be able to use any of the xBee's out there so you should be able to connect through a zigbee network the way I do or with a "bluetooth bee" directly as a serial port to the computer or via wifi with the wifi bees that can be placed in the same sockets. Though the setup for those will be more complicated.

Wednesday, March 20, 2013

Arduino Thermostat part 1

We took a very close lightning hit here a month ago. I didn't lose anything plugged into the wall, I have good surge protection on each electric panel, but I lost several things connected to long serial cables including my very fancy RS485 serial thermostat from HAI. I've replaced the other components and added surge protection to their long serial lines to prevent future problems from induced current but I've decided to roll my own thermostat.

I've been supporting communicating thermostats in XTension for some years now. There are 4 models that I've implemented the protocols to and there are more lined up should they ever choose to document what those protocols are. (and if you have one, or have a favorite you think should be supported please let me know) so it's not like I have a lack of good thermostats laying around here that I could install. But I'm drawn to dangerous DIY like this.

I've decided that it should not do very much in the thermostat at all. Since it's going to be connected to XTension through an xBee radio link I really have no need of schedules or setbacks or anything, I can do that all in the logic of the computer. Since I've basically disabled that functionality of every thermostat I've ever installed and just run it from the computer anyway it seems like a lot of added complexity in them that I never use. I've been using those xBee radios for some time in lots of projects around the house and they are just awesome. XTension lets you control their pins, or read their analog inputs or use their remote serial ports for just about anything.

This device I"m making wont be a one size fits all for everyone, but then anybody considering doing this should have some info on what they are doing since getting this wrong could potentially ruin your house in the form of frozen pipes or destroy thousands of dollars worth of compressors in your AC or worse. So I'm not going to sell a kit or anything, but it's been interesting me for some time.

Here's the power board completed. It has the connections for the thermostat wiring, 3 solid state relays and the half wave bridge rectifier and smoothing capacitor to make the DC prior to feeding it into the arduino power supply. Since the furnace here is simple, only single stage only 3 are necessary. The fan relay, call for heat and call for cooling.




I debated how to switch the lines to the furnace. I could have used cheap relays, but they use not insignificant power that can cause heating inside the case and false readings (but you can get around this like more commercial thermostats do by putting the relays at the top of the case and the sensor at the bottom and using the heat to create a chimney effect of room air past the sensor making it read actually better) but it can also cause problems with voltage fluctuations causing false readings from analog temp sensors and other things. (this wont be a problem since I've decided to go with a digital temp sensor) Plus you can hear them click and that is just so last decade... The problem is that you're switching AC power, so just a single mosfet isn't going to work. You can use 2 wired in opposite directions to do it or an SCR or any number of other ways, but these SSR's are not expensive (I think I paid around $5 each for them from allelectronics.com) and I had them around. Additionally they provide complete isolation between the logic and the current being switched.

The capacitor is overkill by 3 or 4 times, but it's what I had around and it mostly fit on the board there. There are 2 diodes on the board wired in series. I used what I had, those are fancy fast acting low voltage drop schottky diodes which are totally overkill for this power supply too, but I had a bunch of them left over from switching LED power supply experiments. They are rated for an amp of power which is good, but only for 20 volts, so 2 in series are necessary to safely rectify the 24v from the furnace. I used a simple half wave bridge here because the output from a full wave bridge would have been more DC voltage than the switching regulator I've ordered for the arduino side is rated for on input.

Apart from just following good coding practices when I start writing the code, and making it as simple as possible I will be implementing a ping and response system between this and XTension so I can tell if it goes away or gets hung up. I've done a lot of smaller projects with Arduinos and I know they can run for extended periods without problems. Even so, this being a one off project I need a way to reset the thing automatically if it goes down. My first thought was to use one of the many unused pins on the xBee connected through a transistor to the arduinos reset pin. Then I can reset it from the XTension computer if I lose the ping. Though I am beginning to think a local circuit with some timer or capacitor that needs to be regularly restarted by a pulse from the arduino and will cause a reset if it doesn't get that pulse might be good too. A kind of local watchdog timer too. We shall see what happens.

Shortly I'll be connecting this board to the power from the furnace and measuring the output and making sure that all works even though there is no control logic yet.

Today I'll be putting together the arduino and hopefully the fancy temp/humidity sensor I ordered will arrive and I can begin that side of the project.


.code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; max-height: 200px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; }