Wiggle Portsmouth Olympic Triathlon 2013

After doing the Blenheim Triathlon earlier in the year I’ve been looking have a go at something a bit further, so last weekend I did the Wiggle Portsmouth Olympic Distance Triathlon.

Olympic Triathlons are basically double all the distances of the Sprint version, so 1500m swim, 40km cycle and a 10k run.

I got round Blenheim in 1:30:02 (if I’d known I was that close, I’d have managed to sprint a little harder) so I was aiming to get round this course in sub 3 hours.

Swim 1500m

The swim was in the sea from down by Southsea Castle to the Pier. It was first sea swim and I was a bit concerned about waves and basically having my face stuck in salt water for about 30mins. The weather was pretty good and with no wind the water was totally flat. What I hadn’t really thought too much about was the tide, it was great on the 3 sides of the rectangle, just having to adjust a little as I crossed the short ends, but on the way back it was a hard slog. I stormed the first 1k in about 15mins, but the last 500m took 25mins.

Again Strava seams to be showing a strange time for the swim.

Time: 0:41:56

T1

I clocked this at 4:39 which includes the run up from the beach and I also didn’t hit the button until I’d been on the bike for about 200m so this was probably actually a bit quicker than Blenheim (4:25).

Cycle 40km

This was a really nice flat course with a long first lap up round the naval base followed by 4 laps round the sea front at Southsea. I pushed pretty hard on this leg and was pleased to average more than 30kph but was still getting passed by guys going a lot quicker on serious all carbon tri bikes.

Time: 1:16:12

T2

2:08 this time, which is about the same as Blenhiem(2:05)

Run 10km

The run was 2 laps of a loop the other way up the sea front from the cycle leg, again nice and flat apart from a really short climb up over the old defensive wall. I probably set off a little bit too quick as I had aimed for a 50min 10k and was doing 4:30 to 4:40 k’s early on, but I ended up with a total average of 4:55.

Time: 0:46:47

Total time 2:51:47

I came 176th out of 313 (including relay teams) and 46th in my age group. I was well under my 3 hour goal and I think if there had been no tide I could have taken nearly 10 more mins out of that as I can cover a 1500m in the pool in under 30mins.

One of the new challenges for this distance was working out how to take on food while on the move, as the research shows you can go for about 90mins on the reserves and carb loading before an event. I had tried a couple of flavours of gels the week before (I should have sorted this out a lot earlier) and not been too impressed with the black cherry or the chocolate orange. In the end I plumped for a lemon & lime flavoured one, I took the first one as I was starting the second lap on the bike along with a hand full of jelly babies. I saved the second one for while I was running the first lap.

I think I’m up for doing some more Sprint and Olympic distances, but I’m not mad enough to try a 70.3 or a Iron Man yet. Targets for the next Sprint is 1:15:00 and Olympic has to be 2:40:00 with a stretch of closer to 2:30:00

Taking a look at the neighbourhood

A recent article about detecting offline social networks from information about preferred WIFI networks leaked by mobile devices led me to have another look at the work I’d done looking at WIFI location detection to see what other information I could derive.

I had been having problems with finding WIFI adapters with the right chipsets to allow me to use them in monitor mode in order to capture all the available packets from different networks, but recent updates to some of the WIFI drivers in the Linux kernel have enabled some more of the devices I have access to.

Previously I build a small application which works with the Kismet wireless scanner application to publish details of each device spotted to a MQTT topic tree. With a small modification it now also published the data about the WIFI networks that are being searched for.

Then using 2 simple Node-RED flows this data is stored into a MongoDB instance

You can have a look at the flow here.

From the device’s MAC address it is possible to determine the manufacture, so with another little node application to query the MongoDB store I can generate this d3js view of what type of devices are in use in the area round my flat.

The view dynamically updates every 5 seconds to pick up the latest information.

Now I know who owns what type of device, time to see who might know who. By plotting a force directed graph of all the clients detected and linking them based on the networks they have been searching for I can build up a view of which devices may belong to people who know each other.

Force directed network graph

There are a couple of clusters in the data so far, but most of them are from public WIFI networks like BTOpenzone and O2 Wifi. After filtering these services out there was still the 3 devices that look to be using Mike’s Lumina 800 for internet access and 4 devices connected to the same Sky Broadband router. I expect the data to be a lot more interesting when I get to run it somewhere with a few more people.

At the moment this is all running on my laptop, but it should run fine on my raspberry pi or my home server, as soon as I’ve transferred it over I’ll put a link up to live version of the charts.

Node-Red – Digispark RGB Node

Following on from last weekends post about adding a pause node to Node-Red this weekend I’ve been trying to create a node to support my Digispark RGB USB LED.

The RGB shield for the Digispark came with a sketch and a some python code to send colours to the device using the HID protocol. I had a bit of a poke round and I found node-hid and thought things where going to be easy.

Unfortunately just trying to duplicate the python code in nodejs didn’t seam to work no matter what I tried.

After a bit more digging I found this blog post by Dougal Campbell who looked to have been pursuing a similar idea a little earlier in the year. I couldn’t see any follow up post on his blog but a quick comment later and I had pointers to what he’d managed to get working. I was hoping to leave the default sketch on the digiSpark but it needed a little change to the USB library to make things work properly, you can find the changes here.

88-digiRGB.js


// Require main module
var RED = require("../../red/red");
var HID = require('node-hid');
var device;
var node;

// The main node definition - most things happen in here
function DigiRGBNode(n) {
    // Create a RED node
    RED.nodes.createNode(this,n);
    node=this;
    //look up the matching devices
    var devices = HID.devices(0x16c0,0x05df);
    for (var i=0; i< devices.length; i++) {
      if (devices[i].product == 'DigiUSB') {
        path = devices[i].path;
        node.log("found: " + path);
        try {
          device = new HID.HID(devices[i].path);
          //only work with the first one found
          break;
        } catch (e) {
          node.log(e)
        }
      }  
   }
   
   if (device) {   
      this.on("input", function(msg) {
        if (msg != null) {
          var args = msg.payload.split(',');
          if (args.length == 3) {
            device.sendFeatureReport([115,parseInt(args[0]),parseInt(args[1]),parseInt(args[2])]);
          }
        }
      });
   } else {
      node.warn("no digispark RGB found");
   }
   
}

// Register the node by name. This must be called before overriding any of the
// Node functions.
RED.nodes.registerType("digiRGB",DigiRGBNode);


DigiRGBNode.prototype.close = function() {
    // Called when the node is shutdown - eg on redeploy.
    // Allows ports to be closed, connections dropped etc.
    // eg: this.client.disconnect();
    device.close();
}

If you want to have a play unzip 78-digiRGB.zip in the node-red directory to unpack the whole node into the nodes/hardware directory. I have now saved this a Github GIST which you can check out directly into /node-red/nodes/hardware directory as follows:

[user@node node-red]$ git clone https://gist.github.com/6573158.git

You will also need to run npm import node-hid in the node-red directory to add the dependency.

(Remember you will need to modify the DigiUSB.cpp and the usbconfig.h in the DigisparkUSB example as mentioned in the link above).

This is unlikely to make it into core Node-RED as the hardware is a little specialist, but if Nick and Dave decide to host a collection of hardware nodes it may end up in there.

Node-Red – Pause Node

Two guys from my team (Nick O’Leary and Dave Conway-Jones) at IBM released a very cool tool for wiring up IoT last week called Node-Red.

Node-Red lets you wire together a selection of inputs, things like MQTT messages, Twitter feeds, serial port and a whole lot more, perform transforms on them with Javascript functions before outputting them to a similar collection of options.

I’ve been playing with it to replace a couple things that used to be standalone scripts, but one of the things that was missing was the way to delay an action happening until a certain time after a message has arrived. For example if I want to set my Blink(1) clone to green when somebody mentions me in the tweet I may want to reset it to off 20 seconds later

To help with this I have written a new node called pause that delays passing on a given message by a configurable amount of time. Nodes are made up of 2 files and are placed in the node-red/nodes directory. As well as all the built in nodes there is a example node (99-sample) which you can use to

Each node is made up of 2 parts, the first is javascript file which controls how the node should behave and a html file which contains the descriptive text,

99-pause.js

...
// Simple node to introduce a pause into a flow

//Require main module
var RED = require("../red/red");

function PauseNode(n) {
   RED.nodes.createNode(this,n);
   
   this.timeout = n.timeout * 1000;
   
   this.on("input", function(msg) {
       var node= this;
       setTimeout(function(){node.send(msg);}, node.timeout);
   });
}

RED.nodes.registerType("pause",PauseNode);

You can see in the code above I’ve attached a small function to the ‘input’ event for the pause node, all it does setup a callback after the timeout expires to send the passed in message object to the next node in the flow.

99-pause.html

...
<!-- First, the content of the edit dialog is defined.                       -->
<script type="text/x-red" data-template-name="pause">
  <div class="form-row">
     <label for="node-input-topic"><i class="icon-tasks"></i> Pause</label>
    <input type="text" id="node-input-timeout" placeholder="Time">
  </div>
    
  <div class="form-row">
    <label for="node-input-name"><i class="icon-tag"></i> Name</label>
    <input type="text" id="node-input-name" placeholder="Name">
  </div>
</script>

<!-- Next, some simple help text is provided for the node.                   -->
<script type="text/x-red" data-help-name="pause">
    <p>Introduces a pause into a flow</p>
    <p>Default pause is 5 seconds but can be configured</p>
</script>

<!-- Finally, the node type is registered along with all of its properties   -->
<script type="text/javascript">
    RED.nodes.registerType('pause',{
        category: 'function',      // the palette category
        color:"#E6E0F8",
        defaults: {             // defines the editable properties of the node
            name: {value:""},   //  along with default values.
            timeout: {value:"5", required:true, validate:RED.validators.number()}
        },
        inputs:1,                // set the number of inputs - only 0 or 1
        outputs:1,               // set the number of outputs - 0 to n
        icon: "arrow-in.png",    // set the icon (held in public/icons)
        label: function() {      // sets the default label contents
            return this.name||this.topic||"pause";
        },
        labelStyle: function() { // sets the class to apply to the label
            return this.name?"node_label_italic":"";
        }
    });
</script>

The HTML sets up configuration dialog for the node, the help text, the nodes look and behaviour and the default values for any properties the node has.

The configuration dialog for the pause node looks like this:

I’ve checked this new node into my fork of the Node-Red project here, but I’ll be submitting a pull request to get it included in the main project as soon as I get a chance to have a chat with Nick and Dave.

EDIT:
This is now a core node called delay and is also capable of rate limiting messages