Wednesday, May 22, 2013

xBee Motion Sensor testing

I've been meaning to do some battery tests with these things for a long time. An xBee can sleep at nearly no power use until it gets a wakeup signal. I'm not sure what the power usage of the PIR sensor is, but we'll find out.

In full on mode it works fine, but that will run the battery down fairly quickly. I'd like to set a periodic wakeup once an hour or so to just report in battery voltage or at least to give a ping that it's still there and of course it needs to wakeup whenever the PIR fires.

So now off to study the sleep settings.

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, the diavolino board from 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, 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.