CS199-9: Sensor Network Systems
When/Where: Fall 2004, TuTh 1-2PM, 405 Soda Hall
Instructor: Philip Levis (pal@cs.berkeley.edu)
Advisor: Professor David Culler (culler@cs.berkeley.edu)
Details: CS199-9, 2-credit P/NP, CCN 26692

Introduction

This assignment involves using the Maté virtual machine to aggregate and process sensor readings. The first part of the assignment is learning how to use Maté the second is to write new functions and handlers to support a simple data aggregation program that reports temperature spikes and mote battery status, both of which will have some significance in the class project (detecting fires and keeping a network up, respectively).

Every person in the class should complete this assignment individually, and hand in individually.

Part 1: Maté

Download and install Maté, following the instructions on the website. Go through the full set of tutorials. Don't forget that, since you have Telos motes, you need to use the BombillaLight and not the full Bombilla VM.

Part 2: Energy Monitoring

When you write new functions and handlers, put them in an extensions directory, so you can email me a tarball as your handin. Also include the scripts you wrote, as text files with meaningful names.

Unfortunately, the Telos motes you're using don't have any populated sensors. However, they do have some internal sensors: for example, they can report their battery voltage and internal temperature, presented by components InternalTempC and InternalVoltageC.

The first step in building your application is to write Maté functions that give access to these sensors: call them tvoltage and ttempi. Test that they work by warming a mote and by comparing the voltage of motes that have spent different amounts of time on (have varying charge left in their batteries).

Using the Timer handler, have motes periodically advertise their voltage. However, we just want to know which mote has the lowest voltage, that is, which mote will need its battery replaced most soon. One way to do this is to have a mote suppress its advertisement if it hears one that's lower. Initially, everyone will advertise, then everyone who heard the lowest will suppress in the next time step. Every time a mote hears another report, send it to the UART; you can now monitor which mote has the lowest energy reserves. This is essentially a MIN query over a one-hop neighborhood.

Part 3: Temperature Spikes

Voltage reporting lets us know when motes need recharging; this lets us avoid network failures. But we need the network to do something, in this case, monitor temperature. When a mote detects a very high temperature, it triggers some action. In this assignment, it will just make the mote turn on its LEDs; you could imagine sounding a buzzer or some other action, if the mote had a proper actuation board.

One could imagine detecting temperature spikes in two ways: the first would be to write a Maté script that periodically samples the temperature sensor and tests if it is over a threshold. However, we're already using the timer handler for voltage monitoring. Instead, write an event handler that executes when the temperature goes over a threshold. The underlying handler component samples the temperature sensor periodically (in nesC, not TinyScript) and submits its context for execution. Name the component TempAlarmContext.

Figuring out the right threshold for a temperature alarm will require a bit of experimentation, and reinstalling a new binary image each time is a real waste of time. Add a function to TempAlarmContext that allows you to customize the threshold value.

Make a new VM specification file that's similar to BombillaLight, but replace the Trigger handler with TempAlarm. Build and install this new VM on your motes. Introduce a voltage monitoring script, then an alarm script that toggles the LEDs.

Using the Reboot context, experiment with temperature threshold values. You can use a hair dryer or the exhaust of a computer to find a good triggering value.

Handing In

When you've completed the assignment, make a compressed tarball of the components, scripts, and VM specification file, and email it to Phil.