Exercise 1: Getting familiar with the Sun SPOT

Exercise 1: Getting familiar with the Sun SPOT device

Expected time

10 minutes

Learning goals of this exercise

The goal of this exercise is to get you familiar with what a Sun SPOT device is. You will learn about the different parts visible and accessible on a Sun SPOT device.

How to Open a Sun SPOT

Pick up one of the Sun SPOTs. There is a lid on the Sun SPOT, sometimes called a Sun roof. You will need to take the lid off to get at some of the switches and LEDs. To open the lid, press firmly on the lid, down and back, on the edge of the lid near the small raised dot. You can think of that small-raised dot as the fingernail-catching dot. The closer to the edge that you press, the easier the lid will open. See the illustrations below:

The opposite end of the lid will pop up. Grasp that opposite end to remove the Sun SPOT lid.

Now that you have opened it, you can see the LEDs and switches on the sensor board.

These are under Java program control, so they will act differently, depending on the application that is running. That fin at the top of the SPOT is the radio fin housing the antenna for the wireless communication.

Anatomy of a Sun SPOT device

See Figure 2 for the complete anatomy of a Sun SPOT.


Figure 2: The anatomy of a SunSPOT

The sensor board has the following sensors and input/output components (see Figure 3)


Figure 3: The Demo Sensor Board

The Sun SPOT Main Board has the following components(see Figure 4)


Figure 4: The Sun SPOT Main Board

The back of the Sun SPOT is where you will find various components useful to the functioning of the Sun SPOT (see Figure 5)

Turning on and off a Sun SPOT device

If you tilt the SPOT so that the fin is away from you, you will see the Control Button.

The Control Button is used to reset the SPOT, to put it to sleep, and to wake it up. If the SPOT is asleep, clicking once, briefly - just a tap - on the Control Button will wake the SPOT up. You may have to press hard, but you don't have to press long. If the SPOT is awake, clicking once on the Control Button will reset the SPOT and restart whatever program it was running. Pressing the Control Button down and holding it down for five seconds will put the SPOT to sleep. Let's try it out:

That's it! You have mastered the SPOT Control Button.

NOTE: If the Sun SPOT does not boot, if the LED to the right doesn't flicker when you tap the Control Button, the Sun SPOT probably needs to charge its battery. To charge a Sun SPOT battery, attach the SPOT, using the supplied USB cable, to the USB port on a working computer. The USB power will fully charge the Sun SPOT in approximately three hours.

Here is a little more detail on the LEDs that are on either side of the SPOT Control Button.

Those LEDs can be controlled by Java programs on the SPOT, but in ordinary circumstances, they are controlled by the operating environment on the SPOT. The LED on the left will tell you about the power status on the SPOT. Here are its most important signals:

Power LED Signal Meaning
Two red flashes Powering down
Slowly alternate between bright and dim green Charging from USB; CPU active
Slowly alternate between dim green and off Charging from USB; CPU asleep
Steady dim green Attached to USB, fully charged; CPU active
Slowly alternate between dim red and off. Battery low.
One short green flash Resetting, restarting program.
One bright green pulse, sharp on, soft off
Powering up

The LED on the right is under application control. If that behavior is not changed, the system programs will use it to tell you about the communication status of the SPOT. Here are its most important signals.

Activity LED Signal Meaning
Rapidly flash green
Searching for the host workstation on the USB connection
Flash green Packets being received from the host workstation
Flash red Packets being sent to the host workstation.

Differentiating two Sun SPOTS

On the underside of the Sun SPOT device, you will find a sticker inside the upper radio fin housing, which specifies the last two numbers of the 802.15.4 MAC address of your Sun SPOT. The complete 802.15.4 MAC address is derived by combining "0014.4F01" with the 2 numbers found on a Sun SPOT device. If the sticker mentions 1234.5678, then the address is 0014.4F01.1234.5678.

If you are an attendee of the Java One 2007 hands on lab session, you will also find an additional sticker. This sticker is on the outside of the plastic case, directly on the bottom of the Sun SPOT device. On this sticker you will find a number, prefixed with "HOL". This number is used to identify the Sun SPOT devices allocated for the hands on lab you are attending.

After you have completed Exercise 1 , it will be important to distinguish between the two Sun SPOT devices you have. We will identify each one by attaching a logical label to each. After you have completed this exercise, we will logically identify each sun SPOT device as Bendy SPOT and device Servo SPOT.



Figure 6: 802.15.4 MAC address and HOL number as found on underside of Sun SPOT device.   1) Location of last 8 digits of MAC address

Steps to follow

  1. Connect one end of a USB cable to the USB connector of one of the Sun SPOT devices, and the other end of the cable to the desktop machine. The device should turn itself on automatically.
  2. If the Power LED is not showing the Sun SPOT device as on, then turn the device on by pressing the Control button. Wait for Activity LED to stop blinking, indicating that the Sun SPOT device has completed booting.
  3. At the command line, change your working directory to <lab_root>/spot/exercises/Ex1-Identify and get information about your Sun SPOT device with the ant info command
  4. $ ant info
    
         [java] SPOT Client starting...
         [java] Waiting for target to synchronise... 
         [java] (please reset SPOT if you don't get a prompt)
         [java] [waiting for reset] 
    
         [java] Sun SPOT bootloader (orange-070322) 
         [java] SPOT serial number = 0014.4F01.0000.0292
    
         [java] Application slot contents:
    
    slots:
    
    BUILD SUCCESSFUL
    Total time: 3 seconds
    
  5. See Troubleshooting if you do not get output that ends similar to the above.
  6. The ant info command display a significant amount of information. For this exercise we are only concerned with one thing, and that is the SPOT serial number. Search for a line the line above that has the following information on it
  7. 
         [java] SPOT serial number = 0014.4F01.0000.0292
    
    
  8. Extract the 16 digit number and note it in the table below. Note that this number is in HEX, which means that there may be the letters A through F, as well as digits. The first 8 digits will always be the same for Sun SPOT devices.

    It is possible that this information will no longer be visible, simply scroll up slightly to find the line.

  9. Now note what the HOL label is for this Sun SPOT device as well.
  10. You can confirm that the last 8 digits conform to the digits found on the inside of the upper radio fin housing
  11. This will now be SPOT #1.
  12. Unplug this Sun SPOT device and plug in the other device.
  13. Repeat Steps 1-9, except that this time you will be identifying SPOT #2.
  14. Jot down the numbers you found here, and reference back if you have any questions about which device you need to be using
    Bendy SPOT: 802.15.4 MAC: 0014.4F01.        .         HOL              
    Servo SPOT: 802.15.4 MAC: 0014.4F01.        .         HOL              

Troubleshooting

This section outlines different scenarios that may occur when attempting to issue commands that require communication with a Sun SPOT device. The commands that require communication with a Sun SPOT device are

The following scenarios are documented

Please reset Spot if you don't get a prompt

  1. It is possible that you will receive ouput that ends in something like
    -run-debugclient:
    [java] Devel Library
    [java] =========================================
    [java] Native lib Version = RXTX-2.1-7pre17
    [java] Java lib Version = RXTX-2.1-7pre17
    [java] Waiting for target to synchronise...
    [java] (please reset Spot if you don't get a prompt)

    This indicates that the device is busy doing something else other than listening for commands from the SDK. The attention of the device must be grabbed in order for it to listen to new commands from the desktop.

  2. Press the Control button, located beside the USB connector. This will cause the device to reset, which will make it ready to listen to commands from the SDK.

Waiting for Reset

  1. It is possible that you will receive ouput that ends in something like
    -run-debugclient:
    [java] Devel Library
    [java] =========================================
    [java] Native lib Version = RXTX-2.1-7pre17
    [java] Java lib Version = RXTX-2.1-7pre17
    [java] Waiting for target to synchronise...
    [java] (please reset SPOT if you don't get a prompt)
    [java] [waiting for reset] <...>
    [java] [waiting for reset] <...>
    [java] [waiting for reset] <...>
    [java] [waiting for reset] <...>
    This will happen if you have forgotten to plug in a Sun SPOT device, or that the Sun SPOT device was not properly recognized by operating system. Press the Control button to reset the Sun SPOT device.

Input your port selection

  1. It is possible that you will receive ouput that ends in something like
    -main-find-spots:
    [java] If the selection does not respond to
    [java] input, cancel the build and set the
    [java] property spotselector.noninteractive=true


    [java] Sun SPOT devices found on multiple ports:
    [java] 1. /dev/term/0
    [java] 2. /dev/term/1
    [java] Input your port selection [1-2] or 'c' to cancel:

    This will happen if you have more than one Sun SPOT device connected at the same time.

  2. It is strongly recommended that you ensure that only one Sun SPOT is connected at a time, in order to simplify your efforts while going through these exercises. Otherwise, you will be required to answer this question for every command requiring communication with a device, and you will have to learn how to identify which device you are wishing to actually communicate with.
  3. Unplug one of the devices, select c and re-issue the command that caused this message to appear.

Port not found

  1. It is possible that you will receive ouput that ends in something like
    BUILD FAILED
    <lab_root>\sdk\ant\find-spots.xml:150: >
    No Sun SPOT devices found. Connect a device
    and retry or, if you know that one is already
    connected, specify its port using the "port"
    property (either in a properties file or using
    -Dport=XXX at the commandline). This will force
    the build scripts to use that port.

    Total time: 0 seconds
    $
    This will happen if you have forgotten to plug in a Sun SPOT device, or that the Sun SPOT device was not properly recognized by operating system.
  2. Please plug a Sun SPOT device in and re-issue the command.
  3. If a Sun SPOT device is plugged in, the device may need not have been properly detected by the operating system. This requires that the device be turned off, then back on again.
  4. Turn off the Sun SPOT device, by pressing the Control button and hold it in for at least 5 seconds.
    This will cause the Power LED to flash red twice.
  5. Turn Sun SPOT device back on by pressing the Control button again.
    This will cause the Sun SPOT device to come back on and have its Activity LED to flash for a few seconds.

Spotselector failed or was cancelled

  1. It is possible that you will receive ouput that ends in something like
    -run-spotselector:
    [java] Please wait while connected Sun SPOTs are examined...
    [java] No suitable SPOT is available
    [java] Experimental: JNI_OnLoad called.
    [java] Java Result: 255

    -collect-spotselector-result:

    -clean-up-spotselector-output-file:

    -spotselector-fail:

    BUILD FAILED
    <lab_root>/../SunSPOT/sdk/ant/find-spots.xml:294: Spotselector failed or was cancelled
    This will happen if you plug in a Sun SPOT device which is configured as a basestation, and you are attempting to deploy to this device
  2. Please plug a Sun SPOT device in and re-issue the command.
  3. If a Sun SPOT device is plugged in, the device may need not have been properly detected by the operating system. This requires that the device be turned off, then back on again.
  4. Turn off the Sun SPOT device, by pressing the Control button and hold it in for at least 5 seconds.
    This will cause the Power LED to flash red twice.
  5. Turn Sun SPOT device back on by pressing the Control button again.
    This will cause the Sun SPOT device to come back on and have its Activity LED to flash for a few seconds.

Summary:

In this exercise, you became familiar with the basic layout and functioning of a Sun SPOT device.

Go on to next exercise