Monday, January 28, 2013

Water Heater Power Control

In the last post I talked about how short burst of high power usage can be OK, but long periods of high power usage can kill me.  Remember, I'm on demand billing where they average the usage across every sixty minute period and charge me a ton of money if I let my peak period usage get too high.  I discuss this extensively on my Power Usage page <link>.  I've managed to keep it at or under 2Kw for quite a while and saved a lot of money on power bills.

However, the water heater has been a continuing problem.  I have a solar water heater for the house and it will make hot water for free if there is sun.   One wouldn't think that is a problem here in Arizona, but occasionally we get several days of overcast weather and that means no hot water.  The water heater works great if there is sun, even if it's 30F outside.  The collector temperature goes up to 150F pretty quickly and that's enough to create plenty of hot water.  When the weather is overcast and especially when it's rainy, the collector won't generate any hot water and I have to rely on a heating element inside the device as a back up.  Obviously, I don't want that heating element drawing power during the peak period because it will pull at least a couple of Kw and mess up all my work saving power.  I actually had this happen once <link> and it cost me a whole lot more than the water was worth.

At first, I had an Intermatic timer that worked quite well, but since I live in the realm of power failures, it wouldn't stay on time.


If I lived where the power was more reliable, this would have been fine, but I often lose power during thunderstorms and sand storms, so I looked for another solution.  Since I had X10 controls in the house to operate the outside lights, I went with that solution.  Yes, I could have gotten a digital timer for the water heater that has a built in clock with battery backup to keep the time, but I had already given up on a $60 device and I didn't want to spend that much again.  I got an X10 appliance module from an ebay vendor, a contactor from an A/C supplier, and an electrical box from a neighbor and built a remote control for the water heater.  Frankly, I didn't save any money, but I had remote control and my light timers for the house could turn the power on and off to the water heater.

X10 sucks.  Sure, that's a little severe, but if you're using it for anything that isn't monitored all the time, you have trouble.  X10 will false, fail to receive, and just refuse to work.  In unattended circumstances, this will turn on lights, leave them on when they're not supposed to be, and turn them off for no reason at all.  Same with water heaters.

So, last Saturday I decided to turn on the water heater for the day to get enough hot water for a nice long shower.  It wouldn't turn on.  I even changed the appliance module, but nothing seemed to work.  It was chilly, and raining, but I turned off the breaker, dried off, and bypassed the stupid thing to force the water heater on.  Then, I started reprogramming my Garage Controller <link> and House Controller <link> to take over this job.  I had two unused relays in the garage controller and lots of memory on the House Controller, so a little rewiring and programming and I had control of the power to my water heater.

I use regular text transmitted from XBee to XBee to control and monitor status for the various controls I've built around the house, so every 15 seconds or so, the garage transmits: 'garage,closed,closed,off<cr>'
with the items being the two garage doors and the water heater, so it knows the state of the garage devices.  To change the state of the heater, I have the controller transmit, 'waterheateron', or 'waterheateroff'.  Using text like this allows me to debug things with a sniffer <link> that I can watch the various devices with.  I can also transmit the commands by hand using the XBee X-CTU configuration tool.  All of my household commands are sent in broadcast mode so they can be seen by any device.

I also added items to the web interface the House Controller supports so that I can see the state of power to the water heater using a web browser.  There's also a button to turn the power on and off as needed.  This means the house controller can schedule power to the heater as needed with the garage controller having final say in the situation.  For example, I have the water heater hard coded to turn off just before the peak billing period and back on just after.  This keeps the water heater off when the prices are high.  If the power fails, the water heater defaults to off; I may change that if it becomes a problem.  Here's a picture of the Garage controller with the new wires in it from the water heater:

And here is the electrical box that houses the contactor that actually controls the power to the water heater:


I still have one relay left in the Garage Controller, wonder what I'm eventually going to use it for.


Saturday, January 19, 2013

Speaking of Electrical Appliances

My previous post on my electricity usage got me to thinking about appliances and how they use power.  This is a chart of my usage today.  The spikes are my electric range.  I cooked a pork butt roast (actually, it's the shoulder of a pig) in a Dutch Oven at 275 for most of the day.  I do this so the meat is really tender and just falls apart.  This gave me an opportunity to examine how efficient the oven is over a long period.

Turns out, it's not too bad.  As long as you keep the door closed and don't constantly check it to see how it's doing, the device works pretty well.  Notice on the left there is a wide spike of about 5Kw to initially heat the oven; then spikes at about 15 minute intervals.  There is a double spike at just before 2PM when I opened the door to check on it.  These spikes use a lot of power, for a very short time.


I don't have an easy way to measure the usage over all since the levels change so much, but it looks like the oven is very efficient.  Those little spikes, when expanded are less than two minutes long and shouldn't cause to much usage.  They look really huge, but actually they don't represent much power.

Unlike the compressors for the heat pumps on the house which run for hours at a time in the winter and intervals measuring several minutes in the summer, this is an extremely short period.  I need to measure some of the other appliances that really chew up the power, I may be able to reduce my power bill even more.  Things like cooking in the morning during the week to build up some heat in the house to help during the after noon may work well.

But, winter is almost over for me.  Notice that it got up to 82F today; this is the middle of January.  I just love Winter in the desert.

Monday, January 14, 2013

Alternatives to Cosm (Pachube), Part 3

Edit: Naturally, the cloud service changed and things quit working. I didn't fix it, instead I'm leaving this as an example of what you get into using cloud services. They change, go away, whatever, and you're left with fixing it.

Found another one to try out.  The site thingspeak.com has apparently been around a couple of years, but didn't turn up on any of my searches.  I stumbled across it today and had to go try it out.  After a number of false starts and some serious reading, I managed to create a data store and put some data in it.  Then began the laborious task of modifying my House Controller to send data to it.

You'd think I'd be getting pretty good at this by now, but I tried for two hours to get data to upload to the site with zero success.  Then, in typical form, I went back to beginning, found my silly mistake and got it to work.  This site works like Cosm.com in that you construct a POST and include the data to send it.  They use fixed field names field1, field2, etc. instead of numbers and the data doesn't have to be constructed in a JSON format, just named as parameters.  I'm using something on the order of:

("field1=%d&field2=0.%d&field3=%d.%02d&field4=%d.%02d&field5=%d&field6=%d")

to send the data (hope you understand printf).  This is actually easy to understand and could work quite nicely.  Yes, they have embeddable charts.  Here is a daily chart of my power usage with their facilities:


The extremely cool thing about their charts is that, if you set them up for it, they are dynamic.  That means new dots will appear in the chart as my house updates the data on their site.  If you put your mouse on the chart and move it around, each of the datapoints will be highlited and the actual data will be shown.  This is really a nice way to chart the data. They don't have the ability to zoom in on the data or subset it by manipulating scrollbars or highliting areas, but the ease of making charts if phenomenal.

There are a number of other features to play with.  They even let you record a status for the data being sent. This is a text field that can be retrieved and displayed.  So, I could display, "Currently Offline" on a feed that was having trouble if I wanted to.  There's also an API for location data for things that move and an interface to twitter for people that like that kind of thing.  I haven't found any use for a twitter interface at all, but someone must like it since it turns up all over the place.

The site supports JSON data retrieval so it can be used in a plugin.  This is different from the emoncms.org site.  Security of one's data is a serious concern, but it's not much use to put data out there if you can't get it back to be used.  That's the most serious problem I ran into with emoncms.  The fact that you can get the most recent data back gives you the ability to do this:
This is an iframe that contains an AJAX query that fills in the value for a SteelSeries gauge.  I have this on a cloud server so that I can use it anywhere by just pointing to it.  The site, thingspeak.com, takes care of automatically updating it, so this is updated periodically with the data my house sends up.  I could (relatively) easily construct a AJAX query that would feed into the Google chart API and produce one of their great charts with zoom and everything.  That is currently left as an exercise for the student.  Wait long enough and I'll probably do it.

So, I've researched and actually set up data stores on several of the repositories out there.  They each have something unique to offer and seem to do the job of holding, displaying, and supplying data.

Try them out and have fun.

Part 2 of this effort <link>
Part 1 of this effort <link>

Friday, January 11, 2013

Let's Examine My Power Usage

After a couple of years of monitoring my power closely and installing various devices to check, examine, and control this usage; what have I learned? Let's walk through a typical Friday. I choose Friday because it's a weekday where the power company enforces demand billing and it's winter and getting cold here in the desert. I'll do something similar in the summer as a comparison. First, here is a graph of the power usage for the last 24 hours:

Yes, at 10PM last night I had spikes in my usage; I was doing laundry.  The spikes are the clothes dryer switching it's element on and off to dry the clothes.  Notice that the spikes are hitting around 7.5Kw?  That's a heck of a lot of power.  I do the drying at night in the winter to save some of the heat inside the house; not all of it gets blown out the vent into the air.  Immediately to the right of the dryer, the heater kicked on and stayed on until 1:15AM.  The heater uses around 4Kw, and since it was cold, stayed on for quite a while.  Then there was a low period for a couple of hours with only the recirculation fans running before the heater kicked on again and ran until almost 9:00AM.  Notice that the temperature took a quick upward climb at the same time?  That's when the sun finally came up over the mountain to my East and hit the house.  There was another period after 10:00AM where the wind got up and the cold breeze caused the heater to kick on again.  When it was getting close to noon, the heater came on, but the peak demand controls I have built into the house kicked in and shut it off at noon.  From noon to 7:00PM the demand is held low, less than 2Kw to save cost.  Then at 7:00PM, the recirculation fans kick back in and start equalizing the house out again.  The huge spike just after 8PM is me making a pizza.  The narrow spikes in the period from noon to 7:00PM is me doing a little welding in the garage.  Yes, I have projects that aren't electronic and require the use of tools bigger than a soldering iron.

Some people may criticize me for the amount of power I use, but I didn't create these appliances that pull 10Kw doing some task.  It takes a lot of power to run an electric clothes dryer, electric oven, microwave; people just don't think about it until the bill comes in.  I've seen consumption at my house exceed 20Kw.  When I have a cold evening and both heaters are on, I have clothes in the dryer, and decide to bake cookies, the usage can easily top 20Kw in short intervals.  Do you realize that is more than 200 amps coming in the power lines?  And this is not an unusual thing for people to do.

Now, do you understand why I have automated controls in place to keep this in check?  Heck, I complained to one of my neighbors about my power bill coming it at around $117 last month.  I actually thought they were going to attack me.  It seems their bill for last month was a little over $350.  

A couple of months ago the power company wanted me to install a smart meter to, "better control my power usage".  I asked them to pull up my records and take a look at them over the phone.  The 'Energy Usage Advisor' was astounded at the controlled usage my bill reflected.  I asked him to show me an example of what their smart meter with household controls could do....crickets chirping....  No, they couldn't show me anything that even came close to the level of control I already have, and I ain't even close to being done with the project.  See, the power company wants to control the temperature inside my house, limit the usage of large appliances, and put special controls on my swimming pool to "Save me money and lower my carbon footprint".  Yep, I'm going to let that happen (not).

I'm not going to get into one of my lectures about letting a corporation control anything inside my house.  How things like 'carbon footprint', 'impact on environment', and 'delayed usage' I consider to be buzz words that let them get into and try to control my life for their benefit.  Heck, if they had built the power plants back when they were cheaper, before inflation and needless regulations force prices to skyrocket, we might not be in this mess.  But, no, they wanted to delay it as much as possible.  

Needless to say, I don't have a smart meter at my house.  If I did, these smart meters use Zigbee communications to control things.  Heh, heh, I have a full dozen Zigbee devices in my house; how long would it be before I was feeding them the data I wanted them to see.

Have a nice day power company 'Energy Usage Advisor'.

Saturday, December 15, 2012

Really Nice Gauges

Recently I was shown an extremely nice set of gauges by a fellow on the Arduino forum, graynomad.  They were metalic looking and had a great set of parameters to mess with.  Well, I couldn't resist, and decided to figure out how to use them and somehow get them on this site.

Well, I sort of got it working.  It seems that Google (Blogger) has a problem with iframes, and that's pretty much the only way to include one of these.  The problem is that it messes with the scrollbar in Chrome, their own browser.  I'm not sure how they show up in IE, except they won't show up at all in IE8 because it doesn't support canvas.  For something this complex, the canvas is the only practical solution short of using something like Flash.

So, if you're using Chrome, look over to the right where the scrollbar is, notice it doesn't look right?  If you put your mouse over there and click, you'll see that it actually works, but just doesn't look right.  I don't have a solution to this yet.

But, let's look at the gauge.  Notice it has an LCD display and a moving hand.  When my energy usage goes above the red indicator (it's on the dial), the little red LED will light up.  These are all parameters that can be set for the gauge.  I chose the brass look simply because it fit my taste, there are many, many combinations possible.  The gauge is sort of real time.  What I do is update it every 10 seconds from my datastore at Cosm which is updated every 60 seconds.  So, every minute or so, it will be updated to reflect the current power usage at my house.  I plan on working with these gauges quite a bit more; they're just too nice to leave alone.

So, if you want to use them also, or just admire the tremendous amount of work that went into creating them, they're known as the SteelSeries and apparently were initially designed for weather displays.  Just go to Google and start looking.  If I gave a URL, it would be the wrong one or outdated or something, so check it out yourself.

And, sorry about your scrollbar; it'll come back when you go leave this page.

Thursday, December 13, 2012

Let's Talk About Septic Tanks

Nice subject....right?  Since I live out in the sticks, there are no services here except power and phone.  I have my own well, propane tanks, and septic system.  Since it's a relatively new septic system, it has all the new and improved features.  This usually means there is more to worry about and take care of, and at least in my case, this is certainly true.

My first problem came a few years ago when sewage backed up into the house.  Since I had only a general idea where the tank was actually located, the service guy had to hunt a while to find the access ports on the tank.  See, newer septic tanks have two access points for different stages of sewage treatment and both of them have to be pumped out.  When he uncovered it, I found out I had a filter inside the tank.

Yes, there is a filter that stops solids from making their way out into the leach field.  The filter had plugged up and was not releasing fluid into the leach field.  That filled the tank and caused me to have a mess in the bathroom.  Nice.  So, obviously, the tank filter needed to be cleaned and the tank pumped out to restore service.  So, I had the service company install risers with nice green covers on them to allow (relatively) easy access to the septic tank so I could clean the filter.  Total bill, around $800.  Not something I wanted to repeat very often.  Here's a picture that illustrates the kind of thing I'm talking about:
All you see at ground level is the green plastic covers.  Just remove these to service the tank.  Here is what the filter looks like:
To clean it, just grab the blue handle, pull the filter out, and bang it around.  Once you knock the debris off, rinsing it is easy, just spray it down with a water hose.  Here is the basic configuration of the tank and the various parts inside:
Except I have a riser on both sides so each tank can be easily pumped out.  Notice the 'sanitary tee' on the inlet side?  That causes problems as well; more on that below.

Fast forward a year.  I had company with kids and the darn tank filled up again.  I opened the wonderful new access points, and sure enough, the tank was full again.  Called the same service company and they came out and cleaned it out for me again.  I chose this solution to get the house working again since I had company at the house that needed to use the bathroom.  Total bill, $340.

A couple of weeks ago, it happened again.  This time I didn't have company, so I went out and cleaned the filter.  The tank immediately started to drain into the leach field and drop the level, and by the next day, it was back to a normal level.  No costs, this is the way to do it.  However, about four days later the house backed up again.  When I opened the access point, the tank was at the proper level, and the filter was clean.  What the heck was up with that?

Seems when the tank was full, a clot of toilet paper formed on the inlet side and had turned to concrete.  See, what happens is that the 'sanitary tee' caught all the toilet paper and allowed a plug to form on the inlet.  When I lowered the level of the tank, the plug hardened and I had a new problem to deal with.  I spent most of the day with a water hose and jet nozzle breaking up the plug and restoring septic service to the house.  This needs some solution that doesn't require me to remember that the darn filter needs to be cleaned, and a way of clearing the pipes that doesn't entail a days work with a water hose.

So, I bought one of these:
This is a hose and special jet that you hook to your power washer and run through the sewer system to clear out clogs.  It won't work on tree roots or cave ins, but it will clear most clogs quite nicely.  Since I had never used one before, I was skeptical, but it did a great job.  It pulls itself along breaking up stuff and washing it down the sewer line.  If it stops at a bend or a clog, just pull it back a little bit and let it go; it will work its way through the clog and around the corner after a couple of tries.  Really nice tool.  Total time to clean out the pipes was around 30 minutes and most of that was figuring out how to hook the device up to the power washer.

But, to prevent the problem from sneaking up on me and flooding the bathroom was still a problem.  With a little searching I found out that there were floats that are specifically designed to tell you when the septic level rises.  I got one of these:
This is a normally closed float switch.  I chose normally closed so that I would know that the level was OK by a closure and it would open when the level got too high.  This way I knew the switch was OK and wouldn't have to wait for the sewer to back up to find out the switch was broken.

Total cost for both items: $150 including shipping.  I consider this a wise investment since now I can tell if the tank is rising and clean the filter long before it backs up into the house.  I also have a way of clearing the pipe easily each time I open up the tank to prevent the toilet-paper-turned-to-concrete-plug problem.  Sure, I could just clean the filter every six months or so, but who remembers that kind of thing?  Especially since this is probably the nastiest job one can take on around the house.  'Sanitary tee' ?  Who the heck thought of that name?

I haven't hooked the float into the house network yet, but that will come over the next month or so.  That's a problem that I already know how to deal with.  I plan on having a little light come on somewhere inside the house that I can't ignore; heck, I may have it send me email also.

I have the coolest septic tank in the area.


Friday, December 7, 2012

Alternatives to Cosm (Pachube), Part 2

(edited heavily on Dec 11, look below to see why)
Previously <link> I discussed the possible use of Sen.se as an alternative to Cosm.  This is becoming important to me because Cosm seems to be slowing down over time.  The users on their forum have brought this to the developers attention and there have been responses, but I'm having trouble loading a single day of data without a server error and failure to display the data.  So, I just tried out another offering emoncms.org.  It's pretty darn compelling.

The problem with most of the services that I've investigated though is there just isn't enough documentation on what it does, how it does it, where it stores the data, etc.  This is somewhat true of emoncms, but at least there's enough (including its forum) to actually use it.  It took me most of an afternoon to prowl through enough documentation and user comments to get it working.  The part that held me up the most was finding out how to get my data to the service.  It turns out that it's relatively easy to have an Arduino send the data to the service and then construct graphs and things using emoncms tools.

However, there are a number of odd problems relating to embedding their graphs into a blog page.  When I first put this page up I had a multigraph and a gauge that showed real time usage.  The problem was that using the scripts turned off the scroll bar for the page.  That's a bit unacceptable, so I edited the page to remove the visual display.  There are also a few display problems when using their dashboard, but it mostly works.  Here's the link to my dashboard with gauges and graphs that indicate real time data <link>.

Like I said, this is a very compelling site.  One problem may be that this site is open source and maintained by a community of interested users.  That means that it will grow quickly and capabilities will be added as they are thought of and users make the changes (unfortunately, it's the same for bugs).  That makes it somewhat unpredictable.

I can deal with that.


Like I said though, it's a bit tough to find out how to send data from an Arduino to the site.  I got it to work with minimal trouble after searching a lot on the site and its forum.  Here's a code snippet to illustrate how to do it:


The Arduino Sketch

void sendEmoncmsData(){
  char dataBuf[100];

  if(emoncms.connected()) // already trying to get data, just leave
    return;
  // construct the data buffer so we know how long it is
  strcpy_P(Dbuf2, PSTR("{RealPower:%d, PowerFactor:0.%d, PowerVoltage:%d.%02d, PowerFrequency:%d.%02d, InsideTemp:%d, OutsideTemp:%d}"));
  sprintf(dataBuf,Dbuf2,
    (int)round(realPower),
    (int)(powerFactor*100),
    (int)rmsVoltage,
    (int)(((rmsVoltage+0.005) - (int)rmsVoltage) * 100),
    (int)(frequency),
    (int)(((frequency+0.005) - (int)frequency) * 100),
    (ThermoData[0].currentTemp + ThermoData[1].currentTemp)/2,
    (int)round(outsideSensor.temp));
    Serial.println(dataBuf); // take this out when you've got it working
//    return;  // so you can see the buffer before you actually send it
  strcpy_P(Dbuf,PSTR("emoncms Connecting..."));
  Serial.print(Dbuf);
  if(emoncms.connect()){ // set a limit on how long the connect will wait
    strcpy_P(Dbuf,PSTR("OK..."));
    Serial.print(Dbuf);
    tNow = now();
    strcpy_P(Dbuf,PSTR("GET http://emoncms.org/input/post?apikey=secretnumbers &json="));
    emoncms.write(Dbuf);
    emoncms.write(dataBuf);
    emoncms.write("\n");
    emoncms.stop();
  }
  else {
    strcpy_P(Dbuf,PSTR("failed..."));
    Serial.print(Dbuf);
    emoncms.stop();
    while(emoncms.status() != 0){
      delay(5);
    }
  }
}

See, it's a simple json interaction that names the variable that you want to save data for.  emoncms will create the data store and name it for you.  All maintenance for the data can be done from their site.

This could well become my new cloud storage for data.