I live in the Arizona Desert, Southwestern USA. It gets hot here, and my power bills got out of hand. This is a journal of my various efforts to bring this problem under control using the cheapest technology I could find. Saving money shouldn't cost a fortune.
Tuesday, June 28, 2011
Bragging about the house controller ... again.
I'm actually pretty impressed with the capabilities of these little computers (as if you couldn't tell). I added a short video of the House Controller to the tab above. It isn't real impressive since it only does the mundane stuff like help me save around $100 bucks a month on my power bill, but it is fun and still growing.
Monday, June 20, 2011
House Controller
Finally started documenting the House Controller. I've mentioned it several times, but the darn thing is a ton of code and has been the focus of most of my efforts for a few weeks now. It uses XBee to connect into the network I constructed and has an ethernet board so that I can tell it what to do as well as get information from it. It also uses the ethernet board to control my two web enabled thermostats. I control the pool and the thermostats as well as sample the data from my various devices. I can see the inside temperature, outside temperature, power usage and such from my laptop in a chair anywhere in the world. I use the Arduino TimeAlarm library like a task controller to schedule various events like turning off the A/C at certain times. I also turn the pool pump off in the evening just in case someone (me most likely) left it on.
It has an LCD display that shows various items I like to watch in sequence and a ton of colored LEDs that show the various conversations going on around the house. Naturally, it isn't done yet, not by a long shot. Heck, I've only used about a fifth of the memory on it and I have CPU cycles to spare. I will be expanding it to control the X10 devices I have, and as I add new devices, I'll put in code to handle them.
It's on the House Controller tab above and I'll have pictures so you can see it soon. If you want to sample the web output, click here.
It has an LCD display that shows various items I like to watch in sequence and a ton of colored LEDs that show the various conversations going on around the house. Naturally, it isn't done yet, not by a long shot. Heck, I've only used about a fifth of the memory on it and I have CPU cycles to spare. I will be expanding it to control the X10 devices I have, and as I add new devices, I'll put in code to handle them.
It's on the House Controller tab above and I'll have pictures so you can see it soon. If you want to sample the web output, click here.
Monday, June 6, 2011
Stupid Arduino 2560 Board
The Arduino mega2560 board is cool. It has several rs232 ports and a ton of digital io ports to play with. It has enough ram and rom to make a really nice little computer for coordinating other devices around the house and a really small footprint. The problem is the boot loader is brand new and suffers from a couple of pretty severe bugs. I left town for a few days and the device died. No, I couldn't use the watchdog timer; a bug in the boot loader stopped me. Seems that once you use the watchdog timer, you can't boot back up. Sad. I spent last night working up a timer interrupt to do basically the same thing by timing out and then checking a flag I keep resetting in the main loop.
Actually, this is a pretty elegant solution since I can decide within the timer interrupt service routine if I really want to reboot or not and set flags and such to act on when it comes back on line. However, it is unfortunate that the darn boot loader hasn't been fixed yet.
#include <TimerThree.h>
// pick this library up at http://www.arduino.cc/playground/Code/Timer1
// scroll down the page to the Timer3 entry.
unsigned long resetTimer = 0;
unsigned long timerRate = 2000000; // this is the MICRO seconds to wait between interrupts
int resetWait = 10000; // this variable is in MILLI seconds for how long to wait
// before resetting
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void resetMe(){ // There are certain compiler items that this little trick
resetFunc(); // can over come. Like putting this in a callback.
}
void checkActive(){
// this routine gets called every timerRate (see above)
// and here I check resetWait to see if the device has been
// hung up for resetWait number of milliseconds
if(millis() - resetTimer > resetWait){
Serial.println("Fake Watchdog Timer Reset..........");
resetMe();
}
// Serial.print("Timer3 at "); // uncomment these two lines to watch what's
// Serial.println(millis()); // going on
}
void setup()
{
int errorCount = 0;
Serial.begin(57600);
Serial.println("Initializing..");
}
boolean firsttime = true;
void loop(){
if(firsttime == true){
Serial.print("First time through loop, set up timer");
firsttime = false;
resetTimer = millis();
// set timer3 to expire in 2 seconds. So, every 2 seconds the checkActive routine
// will get called and it will check the resetTimer variable to see how long in
// milliseconds it has been since the variable was last updated.
Timer3.initialize(timerRate); // This sets timer3 to expire in 2 seconds
Timer3.attachInterrupt(checkActive);
// Note that this could have been in the setup() routine above, but
// I put it here because sometimes I have a LOT of stuff to do during
// the setup() routine.
}
// to test this, comment out the line below and the board should reboot.
resetTimer = millis(); // This keeps resetting the timer
}
Update 10/29/2011: I found a way to use the watchdog timer and documented it here. The solution uses the watchdog interrupt as a timer interrupt and works nicely. A little bit more code, but it is actually pretty cool.
Actually, this is a pretty elegant solution since I can decide within the timer interrupt service routine if I really want to reboot or not and set flags and such to act on when it comes back on line. However, it is unfortunate that the darn boot loader hasn't been fixed yet.
Sketch to illustrate the Timer3 watch dog trick
#include <TimerThree.h>
// pick this library up at http://www.arduino.cc/playground/Code/Timer1
// scroll down the page to the Timer3 entry.
unsigned long resetTimer = 0;
unsigned long timerRate = 2000000; // this is the MICRO seconds to wait between interrupts
int resetWait = 10000; // this variable is in MILLI seconds for how long to wait
// before resetting
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void resetMe(){ // There are certain compiler items that this little trick
resetFunc(); // can over come. Like putting this in a callback.
}
void checkActive(){
// this routine gets called every timerRate (see above)
// and here I check resetWait to see if the device has been
// hung up for resetWait number of milliseconds
if(millis() - resetTimer > resetWait){
Serial.println("Fake Watchdog Timer Reset..........");
resetMe();
}
// Serial.print("Timer3 at "); // uncomment these two lines to watch what's
// Serial.println(millis()); // going on
}
void setup()
{
int errorCount = 0;
Serial.begin(57600);
Serial.println("Initializing..");
}
boolean firsttime = true;
void loop(){
if(firsttime == true){
Serial.print("First time through loop, set up timer");
firsttime = false;
resetTimer = millis();
// set timer3 to expire in 2 seconds. So, every 2 seconds the checkActive routine
// will get called and it will check the resetTimer variable to see how long in
// milliseconds it has been since the variable was last updated.
Timer3.initialize(timerRate); // This sets timer3 to expire in 2 seconds
Timer3.attachInterrupt(checkActive);
// Note that this could have been in the setup() routine above, but
// I put it here because sometimes I have a LOT of stuff to do during
// the setup() routine.
}
// to test this, comment out the line below and the board should reboot.
resetTimer = millis(); // This keeps resetting the timer
}
Update 10/29/2011: I found a way to use the watchdog timer and documented it here. The solution uses the watchdog interrupt as a timer interrupt and works nicely. A little bit more code, but it is actually pretty cool.
Subscribe to:
Posts (Atom)