14 Dec 2009

I’ve had my orb sat beside my TV for over a year now and it has served its purpose very well. I’ve never got beyond using it to display my energy usage – or more specifically, to display when my energy usage is above ‘normal’. This has always felt a bit of waste; only using 2 colours out of the entire spectrum.

Over tea with Andy a few weeks ago, we managed to place our collective fingers on a basic problem with ambient orbs like this; whilst they may be capable of displaying any colour, the key thing is they can only display one colour at a time – they are a single channel of information.

For example, if I used blue to signify new messages for me on twitter, what should the orb do when my energy goes over 500 watts and someone has @knolleary’d me? The orb could alternate between the two colours, but that would feel too distracting for what is supposed to be an ambient device. A third colour could be defined for this combined state, but that wouldn’t scale very well.

This train of thought brought us to identify what it would take to have an ambient orb capable of displaying more than one piece of information at any time. When put like this, the answer is fairly obvious; have an orb that can glow more than one colour at any time. An evening of soldering later, here’s where I got to.

Multi-Channel Ambient Orb

The orb has three RGB leds in it that are individually controllable. When they all show the same colour, the orb is a solid colour, but when they are different, the orb displays multiple colours at once.

This one doesn’t use blinkm’s for the simple matter of cost – I found a supply of the leds on e-bay that got me 50 for £15 – although this does mean I need to implement fading between the colours.

The plan is to put a small controller in the base to drive all the leds – for now it’s plugged straight into an arduino.

5 Jan 2009

I spoke at Homecamp recently about how an ambient orb could be used to monitor home energy usage. I’ve finally gotten around to putting some of it into practice so thought I would share some of the details of the setup as well as some more of my thoughts on the subject.

There are three key pieces of hardware in use. The Viglen MPC-L is the heart of the system. As I’ve mentioned previously, this is a low powered linux box running Ubuntu. The CurrentCost meter is connected to the MPC over USB-serial and my trusty arduino acts as an integration point for homebrew toys – including my ambient orb.

The MPC is running a Really Small Message Broker (RSMB). This is a small-footprint pub-sub message broker that talks MQTT. Each time the CurrentCost sends out a update, a piece of perl (“cc_pub.pl“) parses the data, sticks it into an RRDTool database for graphing and also publishes it to the home/cc/power and home/cc/temp topics.

Another piece of perl (“orbcontrol.pl“) is subscribed to the house/orb topic. When messages arrive on that topic, they are passed over serial to the arduino.

The sketch on the arduino currently listens on its serial port for commands that are then passed to the BlinkM in the orb. The format of the commands is identical to those in the BlinkMTester sketch that comes with the BlinkM. In the future this will do more as more things are attached to the arduino.

So far I have described how the orb is controlled and how the power data gets into the system. The next piece is how the two are plumbed together. Unsurprisingly, yet another perl script is running the on the MPC that provides the glue for this mixed metaphor.

orblogic.pl is subscribed to the home/cc/power topic so it receives all of the updates from the CurrentCost. It then makes a decision as to what colour the orb should be and then publishes the appropriate command to the house/orb topic.

Orb setup sketch

That is pretty much it – simple eh? Well, I did skip over the most interesting part – how to decide what colour the orb should be.

There are two key philosophies that come into play here:

  • Alert the unusual – have the ‘default’ state be the least obtrusive, such as ‘off’
  • Band the data – don’t react to single-point changes in the value. For example, when monitoring temperature, nothing is worse than constantly saying “its 19°C, its 18°C, its 19°C…”

These points should be applied whenever thinking about how to turn a raw stream of data into a useful stream of information.

I currently have a very simple piece of logic controlling the orb:

  • If power < 400, turn the orb off
  • If power between 400 and 1000, turn the orb orange
  • If power > 1000, turn the orb red

When we’re sat in the living room watching TV, we typically use under 400 watts, so the orb will only show anything if we’re over this value. It is very unusual to go over 1 kw unless we’re cooking, which is why that gets a stronger alert.

powergraph sketch

Despite its simplicity, this has already had the effect of making us more aware of when lights have been left on or when the kettle has finished boiling.

But as with all things, it could get much smarter. Having said we typically use under 400 watts watching TV, I also made the caveat ‘unless we’re cooking’. Given the system has a history of our power usage, it could feasibly determine suitable bands dynamically – so going over 1 kw between 6pm and 7pm isn’t necessarily a bad thing. Also, it chould only go red if the value goes over 1 kw for more than the time it takes to boil the kettle.

It all comes back to determining what is ‘unusual’.

25 Nov 2008

Orb

Orb Base

RJ11

/************************************************
 * Enables a BlinkM to be controlled over MQTT.
 *  - subscribes to the topic 'blinkm'
 *  - expects messages of the format 'RRGGBB'
 *  - doesn't do any error handling
 *
 *    Nicholas O'Leary
 *    http://knolleary.net
 ************************************************/
#include <Wire.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <BlinkM_funcs.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 172, 16, 0, 50 };
byte server[] = { 172, 16, 0, 100 };

void callback(char* topic, byte* payload,int length) {
  byte a = toHex( payload[0],payload[1] );
  byte b = toHex( payload[2],payload[3] );
  byte c = toHex( payload[4],payload[5] );
  BlinkM_fadeToRGB( 0x09, a,b,c);
}

PubSubClient client(server, 1883, callback);

void setup()
{
  BlinkM_beginWithPower();
  BlinkM_setAddress( 0x09 );
  BlinkM_stopScript( 0x09 );

  Ethernet.begin(mac, ip);

  if (mqttClient.connect("blinkr")) {
    mqttClient.subscribe((uint8_t*)"blinkm");
  }
}

void loop()
{
  mqttClient.loop();
  delay(500);
}

// a really cheap strtol(s,NULL,16) - taken from BlinkMTester
#include <ctype.h>
uint8_t toHex(char hi, char lo)
{
    uint8_t b;
    hi = toupper(hi);
    if( isxdigit(hi) ) {
        if( hi > '9' ) hi -= 7;
        hi -= 0x30;
        b = hi<<4;
        lo = toupper(lo);
        if( isxdigit(lo) ) {
            if( lo > '9' ) lo -= 7;
            lo -= 0x30;
            b = b + lo;
            return b;
        }
    }
    return 0;
}
19 Jul 2008

Take one garden light bought at M&S for £3.50 and dissect it:

Dissected Ambient Light

Connect a BlinkM up to an arduino and set it running:

BlinkM

Combine the two and you have a home-brew ambient orb:

Next step, do something interesting with it.

I’ve been on the lookout for suitable materials to make an ambient orb for a while – particularly something to diffuse the light. My original plan, which I may still do, was to take an ordinary lightbulb and put an RGB led inside it. However, modern lightbulbs prove quite tricky to take apart without shattering something. When I spotted these lights in M&S last week I knew they were exactly what I wanted. So I bought three.

They were pleasingly easy to dissect – just some gentle persuasion with a craft knife. The led’s they come with, which you can see here, are going to be handy to reuse in the future.

I still need to work out how best to mount the BlinkM beneath it. Given their I2C interface, it is going to be very easy to chain lots of them together, working as a group.

Ambient orbs are fascinating interfaces – they provide an abstraction that can convert an data source into a simplified, yet powerful, source of information.

Converting data into information is something I have been meaning to write about for a while. But given it’s my wife’s birthday and we’re heading out for the evening in 5 minutes, that post will have to wait for another day.