Saturday, June 29, 2013

How to use the SteelSeries Gauges with the Xively API

Over the last months I've gotten compliments and questions on how I created the SteelSeries gauges and how I hooked them to the Xively (pachube -> cosm -> Xively) API.  First, let me give credit where credit is due.  I didn't create the SteelSeries gauges, Gerrit Grunwald did.  He has a great blog here <link> where he describes the various displays he's created.  I stumbled across them a while back and hooked them into my Xively data feed to display the last updates so I would have a nice display of current power usage and temperature.  They worked really well and look great.

It took a little work to get them going, but it was well worth it.  Basically, I query Xively for the last value, then give it to the gauge to display.  Here's the current (a minute ago) temperature at my house in the Arizona, USA desert.

Edit: This used to be a live gauge, but I replaced it with a picture.

So, the source to do this looks like this:

<head>
<title>Dave Testing</title>
</head>
<body onload=init()>
<canvas id=gaugeCanvas width=200 height=200>No canvas in your browser...sorry...</canvas>
</body>
<script>
function init()
{
// Initialzing gauge
    tempGauge = new steelseries.Radial('gaugeCanvas', {
             gaugeType: steelseries.GaugeType.TYPE4,
 minValue:0,
                  maxValue:150,
                  size: 200,
                  frameDesign: steelseries.FrameDesign.BRASS,
 knobStyle: steelseries.KnobStyle.BRASS,
         pointerType: steelseries.PointerType.TYPE6,
         lcdDecimals: 0,
                  section: null,
                  area: null,
                  titleString: 'Outside Temp',
                  unitString: '°F',
                  threshold: 100,
                  lcdVisible: true
                  });


  // Start the gauge update
setInterval(function(){
            var site = "http://api.pachube.com/v2/feeds/9511.json?&key=GtGuoMKJSqv2tzqGvWaITLhlEDUxrYXSixqPSmlyj-s&&datastreams=7";
//alert('going for ' + site);
$.ajax({
    type: 'GET',
    url: site,
    dataType: 'json',
cache: false,
data: {},
processData: true,
    async: false, // you have to have this so the data will arrive before display
    success: function(data_archive) {
  //alert("the url returned success");
//alert("got back " + data_archive.datastreams[0].current_value);
                        tempGauge.setValueAnimated(eval(data_archive.datastreams[0].current_value));
},
error: function(a){
//alert("here I am in the error routine");
}
});
//alert('after the get');
}, 10000);
}
</script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/tween-min.js></script>
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/steelseries-min.js></script>


There's too much up there to try and explain each item; this blog post would go on forever.  However, there's lots of documentation on the web that can explain what I did and the SteelSeries library has enough in it to get you started there.

Good luck and have fun with it.  I'll be showing how I use the Google Graph API in an upcoming post as well.

Wednesday, June 26, 2013

Back to the Swimming Pool Acid Pump

A couple of folk have sent me notes pointing out that I have spent more money and time on the Acid Pump <link> than is justified.  They're right.  Totally, absolutely right.  That doesn't change the fact that I'm going to continue this project until I finally get a nice working device that maintains the Ph of my pool with minimal human intervention.  Yes, it's cost me more time than just pouring acid from a jug into the pool every few days and more money than many, many gallon jugs of acid.  But that's not the point to automating a house.

The latest problem is a failed check valve.  Originally, I had a problem finding a check valve that was acid resistant and had a pipe fitting on one end and a tubing barb on the other.  I finally got one from the people that supply the pump I'm currently using.  It has been in service for the last year and did a good job.  However, when I replaced the tubing as part of my twice yearly maintenance, the valve stuck and wouldn't open.  I had a spare and installed it to get things going but I wanted to know what went wrong.  This is the valve I'm talking about:

 Notice that the two ends seem to be removable.  Turns out they are.  That's how this manufacturer designed maximum versatility into the device.  You can specify the end pieces to any configuration you need (within reason).  That way special purpose valves can easily be created.  So, being the curious monkey I am, I took it apart to see what was wrong:
Notice it's a basic ball valve complete with a spring that is a simple effective design.  What happened in this case was the black seal failed in the acid and the black debris in the picture is parts of it that plugged up the ball mechanism.  The material is Viton, which has a high resistance to acid, but apparently, not enough for prolonged exposure in the hot desert sun.  Not a big problem, just keep a couple on hand and replace them each year to be sure they hold up over time. I can live with that since every other valve I tried died in less than a month.

The problem came when I tried to get a replacement.  There were lots of them out there in the marketplace, but suppliers wanted between $17 and $50 for these little plastic parts.  Frankly, that ridiculous.  I called the manufacturer and asked for advice.  A nice lady there found me the industrial number of the same device and a supplier of their valves in Colorado that I could call.  I called him and ordered six of them because that's all he had in stock.  The cost was $8.60 each, and the shipping was around $10.  Quite a savings going the industrial part route instead of a swimming pool repair part.  Especially since the swimming pool suppliers wanted from $15 to $18 for shipping and handling to get them to me.

Basically, I got six of the valves for the price of one of them as a swimming pool repair part.  That makes treating it as an expendable part reasonable.  So, now each year I replace the tubing with tubing I get from Home Depot, a piece of Tygon tubing that I order in five foot lengths, and a check valve I buy from this supplier.  Sure, that's a bunch of stuff to remember, but just write down in a book somewhere the part numbers and suppliers and there shouldn't be any problem, and I won't have to pay more than twice what it's worth.

When I get the new ones in I may sacrifice one of them to see what the Viton seal looks like and how it fits in place.  It may be possible to get a Viton seal and just replace it as a maintenance part.  There are places out there that make Viton and even Teflon seals and washers; it could be possible to build up a replacement that will last even longer, or be easily repaired.

I'm starting to understand why so many people buy from Chinese suppliers.