Now there are three lines in this that we’re interested in. The first one states the MAC address of our access point. Next, we want the line describing the ESSID (the “name” of the network), and, finally, the line showing us how strong our signal is, in dBm.

Now whenever I have a bit of text parsing to do, I always go to Perl. Unfortunately, I haven’t got enough space on the Ubiquiti’s measly 4 MB of flash to install Perl. Instead, I’m writing all of this in Bash. So I wrote a small shell script in Bash that parses the output from our iwlist command and prints only the useful information: ap_scan_and_format.sh.

Alright, let’s walk through that really fast. First thing I do is grab the output of our iwlist command and extract the useful lines (the ones containing Address, Signal, or ESSID), and put all of that into variable $aplist. I then step through the lines one by one and extract only the most useful information.

So the output now would look something like this:

001E4EABCCDF
Sun
-29

Neat. Now I’ve got to come up with a clever way to send it back to our SunSPOT.

head -n 1 /dev/ttyS0 > /dev/null
./ap_scan_and_format.sh > /dev/ttyS0

So now I just wait for the serial to hear a new line character ‘\n’ and then I can pipe the nicely formatted list back to my SunSPOT. Perfect.

That’s all we need to send the newline character and read in our list of APs.

Now to get that data back to sensor.network. I’m running a project called Yggdrasil on my Spot so that I can report my sensor readings back to sensor.network.com.

A bit of code later and I can get a nice look at how my wifi signal strength varies over time.

How about for all of the access points in the building?
The cool thing about using sensor.network is that I can now, say, try to correlate these readings against humidity, or other sensor readings in the area.