(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?

Comments are closed.