Lab 1: Becoming familiar with the Java
Sun SPOT technology.
The goal of this lab is to introduce you to Sun’s new Sun SPOT (which stands for Small
Programmable Object Technology) wireless sensor network technology. Unlike
most motes that run
TinyOS and require applications to be written in NesC, Sun’s new motes are programmed in Java. For
people with experience in Java, learning to program applications for the Sun SPOTs should be relatively
easy. Sun makes use of familiar
techniques in the design of the SPOT API ; communication between
motes, for example, should be reasonably intuitive for anyone that has used Java sockets before. The
Sun SPOT software comes with a number of fun example applications that show off some of
motes are capable of. We will explore a couple of these, learning how to deploy applications on the
SPOTs as we go, and ultimately start looking at the code to see how the programs work.
Let’s get started.
Check your equipment
You should have
been provided with a Sun SPOT development kit. This
includes two motes and a basestation. You can tell the basestation apart from the free
SPOTs by the fact that it does not have a detachable semi
transparent plastic cover on top and is
not as tal
l off the table. You will also need at least one USB cable to hook your SPOTs up to the
Sun has made programming and deploying applications to the SPOTs extremely
simple by incorporating the functionality into Netbeans, the Inte
Environment (IDE) that Sun offers with their free version of the Java Development Kit (jdk). The
Netbeans modules that allow for this come with the SunSPOT sdk. In this lab, we will be
learning how to work with the SPOTs through Netbea
ns. You may already have another favorite
IDE of your own, or even already dislike Netbeans for whatever reason, however we will make
use of it in these labs to take advantage of the ease of developing and deploying SunSPOT
applications that it provides.
click the Netbeans icon on your desktop to start it.
Short tour of a Sun SPOT”
When you first open Netbeans, you should see a tab open called
“SunSPOTs info”, with a heading that reads:
“Welcome to the World of Sun Small
A little farther down the page,
you will see a link to the
Sun SPOT Quick Start Tutorial
. Click this. From there click on either the
link at the end of the introduction or on the sidebar to the “short tour of a Sun SPOT.” Q
read over this page. This will get your familiar with the basics of the SPOTs. Try taking the lids
off and locating the switches next to the LED’s (under the lid) and the control (power) button.
The tour will teach you about turning a SPOT on, ho
w to reset a SPOT, and how to interpret the
The Ectoplasmic Bouncing Ball Demo
Now that you’ve got the basics, let’s see what these things can do. The SPOTs come preloaded with a
very cool demo that utilizes the on
accelerometer, one of a number of sensors that the
range SPOTs are equipped with, and the eight tri
color LED’s under the lid. This demo is also
covered in the next section of the Quick Start Tutorial. You are welcome to refer the tutorial in addit
or instead of
the steps below (if anything is unclear, the tutorial has pictures).
Turn the SPOT on.
Most likely in the last step you pressed the power button on one of the
motes at some point and noticed a few of the LED’s on top (there are eight
total) light up. If not,
turn one of the free
range SPOTs on now. The two lights on the ends will be red, and there will
be a blue light somewhere that acts like a bouncing ball if you tilt or shake the mote back and
NOTE: if your SPOT doesn’t res
pond and refuses to power
up, it may not be charged. In
this case, request a new kit (you can also use the USB cable to plug it into the computer and
charge it, but it may take a minute or two before it will have enough power for the demo to
h the bouncing ball.
Take a moment to get a feel for the bouncing ball application.
Shake the SPOT furiously to get the ball bouncing between the two ends at lightning speed and
then hold it still and watch the ball gradually lose speed and settle back d
own to a final resting
place. When the ball is on one end, try tilting the mote gradually just until the ball falls and
watch it bounce back a few times (most likely ending up on the other end; though sometimes if
you just barely tilt it, the ball will go
back to where it started). Try to get the ball to stop in the
very middle (without spending too much time trying). Once you’ve had enough fun, go on to
the next step.
Introduce the second SPOT
If you haven’t already, start up the second free
should also have the bouncing ball application running. This time you will see a ball that is
green. Now turn both motes off (hold the control button for a couple seconds; if you just press
it without holding, it will reset and not shut down)
and then turn the one that previously had the
green ball back on again. Notice that it will now have a blue ball. This means that the SPOTs,
true to the spirit of wireless sensor networks, are aware of each others’ presence. We will
investigate this fur
ther when we look at the code later.
NOTE: if you are doing this lab in close
proximity to other groups, the colors may not match what is described here since all the
motes will be communicating and trying to assign themselves a unique color at startup. Th
is a maximum of three motes (and thus three unique colors) per self
assigning group, though.
Break down the walls.
Make sure both your motes are on. Now go ahead and take both the lids
off. If you were wondering earlier what the control switches do
, the answer is: it depends on
what the application developer wants them to. It just so happens that the developers at Sun
were nice enough to make bouncing ball demo even cooler by letting us use the control
switches to share multiple balls in one arena
that spans more than one SPOT. If that wording is
confusing to you, try it yourself and see what happens.
Press one of the control switches. The red light on that end of the mote will start to
blink. While that light is still blinking, press a switch
on another mote. The two
“walls” should disappear. Now you can have both balls going back and forth
between SPOTs! Unless you’re really good, the balls will probably quickly combine
into one. You can even put the walls back up and isolate both balls o
n one mote, or
take all the walls out altogether.
Play with this for awhile, taking walls down and passing balls back and forth
between multiple motes.
The point of the lab so far was to get you familiar with the basics and layout of the Su
SPOTs and hopefully get you excited about working with them by giving you a glimpse at some of the
fun, cool things that can be done with them.
What are some fun, useful, or interesting applications that you would like to see made to run on