I just got my hands on a few motes and a Crossbow Stargate Netbridge (runs debian!) to manage them all. It’s too late in the day to really explain motes, but in the simplest sense they are little wireless sensors that can be theoretically be combined to form a wireless sensor network. The CrossBow Netbridge serves as a bridge between the (Zigbee?) Motes and a normal TC/IP network — Xserve is what they call their bridge/server application.

In any case out of the box they come with a nice management console Mote Explorer, which let’s you view data from the motes, graph it, and.. that’s about it, — although it does have a pretty slick Flash/Flex interface. Stanza ( http://www.stanza.co.uk/emergentcity/?tag=motes ) has written pretty extensively on his trouble using motes, I sent him an email requesting source code — as it is really hard to find any meaningful source code that uses both motes, and the Xserve (especially because of Apple’s Xserve).

Apparently there is some method of reading the current status of MOTES, or at least tapping into a MOTE sensor feed using the Xserve’s sensor bridge. It appears that you can make XMLRPC calls to the Crossbox Xserve, but these XMLRPC calls are not over standard HTTP (like normal XMLRPC) and require you to write your own custom client. It doesn’t look that hard to do, but I couldn’t actually find an XMLRPC call to read values from a sensor, so decided it wasn’t worth it to write CrossBow Python XMLRPC libraries.

Long story short I found another place to hook into the mote sensor feeds that is very easy to implement, and pretty clean. [ I am sure there is a nice way to accomplish this using XSERVE, but there documentation includes no examples, and thus is not — quick hack friendly]

So here’s the trick. We get the sensor feed directly from the XSERVE console. (I think I may also be using an older version of XSERVE, they might have a newer edition now I am using 2.4.10)

We SSH as too to the StarGate and create a FIFO to handle the console output from the XSERVE

ssh root@____
mkfifo /tmp/mote_feed
chmod 777 /tmp/mote_feed

Then we create our own little startup script for XSERVE that will write to our FIFO

export LD_LIBRARY_PATH=/usr/xserve/bin
export XSERVE_PARAMETER_FILE=/usr/xserve/xparams.properties
export XSERVE_ARGS_FILE=/usr/xserve/xparams.args
/usr/xserve/bin/xserve  -u=user -s=/dev/ttyUSB1 > /tmp/mote_feed

Finally we write a quick parser for the output from the log file that can be dropped into another piece of code to send the data to a remote server, or do whatever you plan on doing with the data. The below parser is sort of ugly, but gets the job done. I prefer ruby or perl for parsing, but Python will get the job done.

import re
f = open("/tmp/mote_feed")
  a = "q"
  good_entry = False
  item = {}
  while( a != ''):
    a = f.readline()
    if( re.search("^\[", a)):
      good_entry = False
      # print the entry I suppose
      if(item != {}):
        print item
      item = {}
        #print a
        d = a.split(":")
        #print d
        if(len(d) > 1 and d[1] !=''):
          if(d[0].strip("\t\n ") == "health"):
            d[1] = d[1].replace("parent=0","")
            d[0] = "node"
          item[d[0].strip("\t\n ")] = re.sub("[^\d\.]","", d[1].strip("\t\n "))
      #print a
    if( re.search("^\[[^\]]+\] MTS", a)):
      good_entry = True

The Resulting output looks like:

{'node': '272', 'battery': '438', 'mic': '438', 'light': '756'}
{'node': '272', 'battery': '2.859251', 'mic': '438', 'light': '2112'}
{'node': '272', 'battery': '438', 'mic': '437', 'light': '757'}
{'node': '272', 'battery': '2.859251', 'mic': '437', 'light': '2115'}
{'node': '272', 'battery': '438', 'mic': '438', 'light': '757'}
{'node': '272', 'battery': '2.859251', 'mic': '438', 'light': '2115'}

Before parsing the data appears in the below format. So the batter level is in Volts?, temperature in degrees centigrade, light in mV ??, and microphone is in ‘counts??’. I also have no idea why the battery level is fluctuating between 438 and 2.859 — and light is fluctuating between 757 and 2115. It seems like there is some sort of error with the sensors, because it’s not with the parsing.

battery: = 2.859251 V
temperature=25.436247 degC
light: = 2112 mV
mic: = 437 counts