Hackathon @ Pachube

Just a quick temporary post before I get my head down. We had a ton of fun at Pachube’s first international hackathon.

I built one of the first Pachube Apps called “Averager”. It takes any user-submitted gas and electricity datastreams (kW only) and posts 15 minute averages on feed 22414.

This is rather crude to say the least but it works thanks to stirling help from Ben and Paul. (Writing jquery when knackered is not my strong suit). Code samples are needed and I’ll post one in due course if no one else gets there first.

Future plans include making the results secure to participants only. (The basis for socialmeter.)

I need to sort out a couple of things such as picking up submitters’ icons and doing a nice visualisation (another Pachube app using websockets – watch this space). [PS. Have done a multi-stream graphing tool and will put it up when I figure out how.] Hopefully the icons can be referenced through with the app’s “user” attribute. If “Install App” is not extensible this could be done with an email dialogue.

My big question is how to make the app configurable so that each group of users will have their own feed for averages. The answer seems to lie within Pachube Groups once I have permission to create and maintain one (Ben please). The group will give registered users access to the Averager feed which will otherwise be private.

So all these features of the platform show the usual Pachube prescience.

Add some “how to” here. Basically just find apps on beta.api.pachube.com, log in and follow the instructions. Psychic powers always useful. It’s under the heading of “mashups and converters”.

… to be continued …

Enjoy :-)

(Fun with) MBED, Pachube and Sockets

With the Pachube hackathon upcoming, I gave myself a deadline for moving forward with a couple things that had been brewing for a while.

  • Substituting MBED for Arduino where a little more horsepower is needed
  • Trying out Pachube’s raw sockets APIs to get a couple of key improvements

(At the hackathon I’m looking forward to familiarising myself with their new apps platform. More on this after the event.)

For those not familiar with MBED please see the doc on mbed.org. Highlights:

  • ARM chip on DIL carrier with decent amount of flash and RAM
  • Has onboard USB for program loading/ power and Ethernet support – everything but the RJ45 connector.
  • Online IDE compiler and docs – needs only browser and USB – no downloaded app – I find that rather convenient.
  • Libraries (official and contributed) – quite a wide range of peripheral device support
  • Cookbook pages – fast start for all the common things you might want to build
  • Contributed notes on hardware aspects and such things as how to roll your own IDE

This is not really open source as we know it. However, you get many of the benefits and you can see a good deal of contributed code. And you can join in of course if you have code to share. My main concern is that this could get very fragmented as, while there is good tech support, there’s little in the way of curation of the contributed stuff. All in all it feels like a fairly productive way to do prototypes.

I got hold of a couple of ways to prototype: breadboard with a few widgets and a small board with key connectors.

MBED

Ideally I would have liked the larger board with a solderable breadboard area but those seemed to be out of stock recently.

Anything for production would need a surface mount PCB. On the upside, the MBED in its carrier costs a lot more than the chip on it so the cost of the board could be offset somewhat. I’ll return to the question of cost in a later blog.

Arguably, you would not use an MBED if Arduino or PIC would do. However, I have always wanted a platform that had more horsepower and better real-time support and MBED seems to promise that. I’m unlikely to invest the effort in porting an RTOS but someone else might. In any case, the speed and capacity of this platform would eliminate the headaches I had when working on a cheap heating control. (Of course I no longer need one – see blog on Intuition box).

Putting it to work

Pachube have raw socket interfaces now. This is excellent because it allows us to cut down on the protocol overhead for connected sensors and actuators. Once you get the hang of this it’s a very tidy way to do things. The really great bit is the ability to use publish and subscribe. This is a very nice way to hook up an actuator. Before, actuators had to poll the Pachube or had to be servers (with attendant firewall issues). Now, they can listen on a socket which seems to me to be far more elegant.

In building a simple demo I hit a couple of issues:

  • Socket library doc could be better – it is automatically produced stuff that doesn’t explain how sockets should be used. I plan to post something to help people not very familiar with socket programming. Some of the available example code was not suited to my actuator requirement (i.e. socket client).
  • Pachube used JSON for these APIs. This is goodness but it implies a need for decoder library. The only one I found did not work in the MBED environment. I lashed up something quick and dirty – will tidy that up and post when time allows. Pachube provided their usual fast and very helpful answers to my questions about the new APIs on the forum.

To let the actuator switch 240VAC I used a ByeBye Standby socket and an AM Radio Tx chip. This connects directly to the MBED with no other components required.

So my first demo is up and running. Now what did I want this for?