Collecting Data with RF Sensors

Version Information

A new version 1.1 of the python and matlab code is released 26 Sept 2012. A zip of the new code is here. Links below are redirected to point to the latest files.

How to Collect Data

This page maintains instructions for collecting data with your wireless sensors. These are called the "TI dongle nodes", and you have three of them:

  • The two with the lowest dongle numbers (see label on bottom side) are the "sensor nodes". They are to be plugged into power using the battery pack. Be sure to turn the switch to ON to power them up. You can also use any iPhone charger. They transmit to each other. When one receives a packet, it records the RSS, and then when it is its turm to transmit, it sends a packet containing the RSS it measured.
  • The one node with the highest dongle number is the "listen node". Plug this one into your laptop or desktop. It listens to the packets transmitted by the sensor nodes, and forwards the packet information to the USB port.

You will use a python program that listen to the packet data from the USB port, and outputs the data to either stdout or to a file. This is the program (you need to download this and remove the ".txt" characters or extension after the ".py" in the filename).

To run python, you need to have a python environment on your computer. There is an easy way to install Python on Windows and Macs called the Enthought Python Distribution. On Ubuntu, go to the Software Center, search for Python, and select Install.

You will need to edit the python code for your sensors. Where it says:

channelList   = [11, 15, 19, 23]

Set these four numbers to the channels measured by your nodes. Then, where it says:

nodeList      = [1,2]

Change these to the two node IDs for your two sensors. This is NOT the dongle number, it is a number from 1 to 6, printed on the node handout sheet.

Finally, change the line:

linksToPlot = [ (1,2,11), (1,2,15), (1,2,19), (1,2,23)]

A link is a (txId, rxId, chNum) combination. Channels are generally 11 <= chNum <= 26, but are limited to those in "channelList". TxId and RxId are positive node ID integers, again, depending on your nodes.

To run the program, type on the command line:

   python > filename.txt

This will send the output to "filename.txt". If this doesn't work, you may need to put "sudo" before the python command. If you look in that file, you'll see rows like these:

33617 -43 33623 -41 33629 -39 33635 -41
33641 -43 33647 -41 33653 -39 33659 -41
33665 -43 33671 -41 33677 -39 33683 -41
33689 -43 33695 -40 33701 -39 33707 -40
33713 -43 33719 -41 33725 -39 33731 -40
33737 -43 33743 -41 33749 -39 33755 -40
33761 -43 33767 -41 33773 -39 33779 -40
33785 -43 33791 -41 33797 -39 33803 -40
33809 -43 33815 -40 33821 -39 33827 -40

Each row has format:

time1 rss1 time2 rss2 .... timeN rssN

where timex is the time the data was collected, and rssx is the received signal strength recorded for link x.

You can then write code to process the data. I don't really care what you use for your programs, whatever you like.

As an example, I have code to plot the data, reading it from stdin. My python code is called (remove any characters like "_0" and extension ".txt" after the ".py"). You would run this on the same command line that you use to run the, as:

   python | python 

I also have a Matlab example, plotColumnsTS_v1.m. You would tell matlab to run this script, which reads in the filename.txt file you are creating via the "python > filename.txt" command. You can either display the data in a file that you recorded earlier, or run it in real time by running the Matlab program while the text file is being created.

What now? Test it out. Write your own code. See what you can do. Have fun!

Problem Solving

Here is a note from Arslan on how he fixed his problem:

Listen node not being recognized by Windows (Windows 7 and Windows Vista have this problem). Therefore, COM port not being assigned to listen node.
Command Prompt returns error pertaining to the following line in the code- ser = Serial(serial_line, 38400)

Make sure sensor nodes are turned on and plug listen node into PC
Restart computer with listen node still connected to PC. Make sure to update your Windows system (when I restarted my laptop, it had updates to install so I'm not sure if it was the act of simply restarting the computer or updating it)
Replace the following line-
serial_line = '/dev/ttyACM0'
With this: serial_line = 'COM3'
And it should work.
Note- I had to check device manager to determine the COM port that the listen node was using. Mine was using COM3.