Homework #5. Wireless Sensor Network Programming

Goal:

Assignment Date: 4/15/2005
Due Day: Part 1 4/22/2005; Part 2 5/5/2005

For Part1, you can use the TinyOS installed in the xpvm1 virutal machine of your designated EAS 140 PCs (same as the one for hw2). You can also download it from http://www.tinyos.net/download.html to carry out the exercises at home. Note that the TinyOS version for XP is about 171MB. It includes the cygwin, a linux like environment for Windows. Try to use the cygwin that comes with the TinyOS distribution for compatibility.

Part 1. Familiar with TinyOS, TOSSIM, and TinyViz.

Assume you choose to carry out exercises using the xpvm1 in EAS 140 PC.

For part1 of hw1, we will get familar with the TinyOS compilation and simulator.

After relogin with "Edward Chow", click the Cygiwn icon on the top left corner. It will start a cygwin shell window. It starts with a bash shell. We will first add the path of a visual GUI tool called TinyViz to the PATH environment variable.

You can hit tab key to allow cygwin bash to complete the file/director name.

to back up the demo applications directory.

In apps directory there are many sensor demo programs. Some are referenced in the TinyOS tutorial http://www.tinyos.net/tinyos-1.x/doc/tutorial/index.html
Each directory contains the source code and Makefile. The makefile allows option for generating the actual sensor code or for generating the simulated version.

We will first try the run the Blink demo which turn on and off the red LED.

To compile a simulation version of the sensor application, type "

If you were to generate the actual sensor code, "make mica2" is used.

You will see the compilation process. At the end it will report the the size of the generated program both in terms of code and data size.

To run the simulator, first set the the envrionment variable which the simulator reads for generating certain diagnosis or simulation log. In our case, use

Since the simulated program are saved as build/pc/main.exe, let us start the program with


You will see the mesage similar to

0: LEDS: Red off
0: LEDS: Red on
...


Now let us start Lesson 5 of the tutorial.

See if you see the same messages in http://www.tinyos.net/tinyos-1.x/doc/tutorial/lesson5.html

Now let us try the TestTinyViz, which is sensor application used to demonstrate the TinyViz, a Java GUI for displaying the sensor simulation results.

Note that TinyViz is buggy as indicated by Philip Levis. If we follow the steps in Tutorial lesson 5,

We will get a Tinyviz that only shows 30 sensors but does not animate the direct message sending as a red lines.
To fix that let us follow the fix suggested by Philip Levis.

You should see the java gui shows the random placement of the 30 sensors and when simulation started. Click the plugin menu and select the radio model. Then click on the sensor symbols. It will display the links to its neighbors and label them with signal strengths of the radio link.

Email me the url of the TinyViz image file as your part 1 submission.

Part 2. Mote Programming Exercise

For part 2, we will use the Crossbow Mica2 Mote Professional Development Kit in EAS 172 to carrry out the exercises in TinyOS Tutorials 1-4 with two additional exercises. Use the following reservation web page to reserve the one-hour time slot. http://cs.uccs.edu/~cs526/cgi-bin/reserve/wsnlab.htm

By doing that, ideally you only need to download those code from CS Unix machines to the EAS 172 laptop connected to MIB 500.

Here are list of exercises:

  1. In Tutorial 1, repeat the Blink application.
  2. Modify Blink called it BlinkCycle to display red, green, yellow leds in sequence every second. See http://cs.uccs.edu/%7Ecs526/hw/hw5/jhhollan/apps/Ex1/Ex1a/ as an example. Improve it if you can.
  3. Create an application called BlinkDot for mica2dot with the blink patterns starting at once per second, twice per second, ..., to 6 per seconds and then repeat.
    Note that Mica2dot only has one LED. See http://cs.uccs.edu/%7Ecs526/hw/hw5/jhhollan/apps/Ex1/Ex1b/ as an example. Improve it if you can.
  4. In Tutorial 2, repeat Sense application.
  5. Extend the capability of the application by chirping the sensor board's sounder when it is dark! The TinyOS component for the Sounder is located in tos/sensorboards/micasb/Sounder.nc and provides the StdControl interface. Modify SenseM.nc to add a StdControl as SounderControl, wiring it as appropriate in Sense.nc. Remember to call init() to initialize the Sounder component. To make the sounder turn on from SenseM.nc, call SounderControl.start(). To turn off the sounder, call SounderControl.stop(). Be sure to test this new application many times to annoy everyone sitting around you.
    See example in http://cs.uccs.edu/%7Ecs526/hw/hw5/jhhollan/apps/Ex2/. Improve it if you can. You may want to change the threshold value of light intensity for turning on/off the sound.
  6. In tutorial 4, programming one mote with CntToLedsAndRfm and programming another mote with RfmToLeds causes it to display the received counter on its LEDs.