4. Program the (Real) World
• Wireless sensor networks open new exciting
scenarios:
> pervasive monitoring of environment and structures
> massive distributed intelligence
> urban smart objects
• Programmable Objects for Real World
> connected: the Internet of Things
> autonomous: local CPU, local memory, local code
> environment-aware: sensors
> safe and robust
4
5. Sensors: New Frontier of Interaction
• To be programmable and connected is not enough!
• The ability to “perceive” the surroundings is the next
interaction frontier for consumer and mobile devices
• Gaming console, mobile phones, automotive
appliances, embedded systems: any object is
expected to “sense” and act according to physical
quantity such as temperature, light, acceleration,
position, humidity, proximity...
5
6. Sensors in the Java ME World
• Java ME is leading technology for mobile
applications, ranging from cellular phones to
embedded systems
• A rich set of standard API enables multimedia
capabilities, 2D and 3G graphics, local and remote
connectivity, location, NFC...
• The Java Community Process has published the
Mobile Sensor API (JSR 256) for accessing devices
such as accelerometers, thermometers, light sensor
6
7. Introducing the Project Sun SPOTs
Small Programmable Object Technology
• Project from Sun Laboratories
• Platform for intelligent wireless
sensors network
• Live-laboratory for implementing
new computing scenarios:
> The (Inter)net of Things
> Program the world
7
9. SPOTs Hardware
• Processor Board
> 180 MHz 32 bit ARM920T core
512K RAM/4M Flash
> 2.4 GHz IEEE 802.15.4 radio
with integrated antenna
> USB interface
> 3.7V rechargeable 720 mAh
lithium-ion battery
> 32 uA deep sleep mode
9
10. SPOTs Hardware
• Demo Sensor Board
> 2G/6G 3-axis accelerometer
> Temperature sensor
> Light sensor
> 8 tri-color LEDs
> 6 analog inputs, 2 switches
> 5 general purpose I/O pins
> 4 high current output pins
10
11. SPOTs Software
• Squawk Virtual Machine
> Fully capable J2ME CLDC 1.1
Java VM with OS functionality
> VM executes directly
out of flash memory
> Device drivers written in Java
> Automatic battery management
11
13. Free-Range and Basestation
• Sun SPOT Development Kit provides:
> Two free-range SPOTs, equipped with Processor Board,
radio interface, Demo Sensor and battery
> One basestation SPOT, with Processor Board and radio
interface
> SDK for Windows, Mac OS X, Linux
> USB cable
13
14. Development
• SDK comprises libraries and utilities for compiling
and packaging bytecode, updating SPOTs firmware,
running basestation applications
• SDK is based on Ant tasks and can be integrated in
any IDE, e.g. Netbeans
• SPOTs support remote installation, execution and
debugging of applications through wireless
connection
14
15. Applications
• Sun SPOT Applications
> Run on free-range SPOTs
> CLDC 1.1 and IMP 1.0 application model
> Full access to peripherals and demo board
• Sun SPOT Host Applications
> Run on a SPOT configured as basestation
> Stand-alone application model
> Simultaneous access to SPOT and JSE libraries
15
16. Classes, Devices, Sensors, Interfaces
• There are over 400 classes documented in the Sun
SPOT javadoc: nearly three times the MIDP 2.0
specification! :-)
• The Sun SPOT device library contains drivers and
high-level classes to access physical interfaces and
peripherals:
> ILed
> IlightSensor, IAccelerometer3D
> IFlashMemoryDevice
> IPowerController
> IPWMOutput
> IAT91_PIO, IAT91_IAC...
16
17. Radio Communication
• Sun SPOTs come with low-range IEEE 802.15.4
radio module
• Communication API is based on Generic
Connection Framework and provides:
> RadioConnection (radio://) from stream-based
communication
> RadiogramConnection
(radiogram://) for datagram
based communication
> basestation may act as
proxy for HTTP connections
17
18. Sun SPOTs Projects
• Many projects based on Sun SPOTs have been
published on the Web: just use your preferred
search engine or video repository to find them!
18
19. Mashing-up Hardware and Software
• The Sun SPOTs let developers build their custom
interfaces for virtually any kind of electronic
peripheral:
> sensors
> motors
> microcontrollers
> radio equipment
19
20. Be Careful with Solder... :-(
• However, soldering and designing circuits and
interfaces for physical components require some
specific expertise
• Wrong assembly or accidental short circuit may
definitively damage your SPOTs and/or your
peripherals
• How can we exploit Sun SPOTs potential without
setting-up a electronic lab?
20
21. Fun for Everyone! :-)
• Thanks to the basestation, we can use the PC as
gateway to any resource such as USB devices,
network hosts and Bluetooth peripherals
• LEGO Mindstorms NXT kit provides:
> Easy and flexible
> 3 outputs
> 4 inputs
> Bluetooth and USB interfaces
> Open source iCommand Java library provides easy and
powerful API for remote NXT control
21
23. Overview
• The Gesture Controller
> Runs on a free-range SPOT
> Reads tilt degrees on X and Y axes
> Sends message to Vehicle Controller
• The Vehicle Controller
> Runs on the basestation
> Receives messages from Gesture Controller
> Sends commands to NXT Vehicle
23
24. The Gesture Controller (source.1)
public class SunSpotApplication extends MIDlet {
private IAccelerometer3D accelerometer =
EDemoBoard.getInstance().getAccelerometer();
private ISwitch switch1;
private int st=0;
private RadiogramConnection conn;
protected void startApp() throws
MIDletStateChangeException{
switch1 =
EDemoBoard.getInstance().getSwitches()[0];
runSwitchWatcher();
}
24
25. The Gesture Controller (source.2)
protected void pauseApp() {
// This will never be called by the Squawk VM
}
protected void destroyApp(boolean arg0)
throws MIDletStateChangeException {
}
25
30. The Vehicle Controller (source.1)
public class SunSpotHostApplication {
private static final int FORWARD = 0;
private static final int BACKWARD = 1;
private static final int RIGHT = 2;
private static final int LEFT = 3;
private static final int STOP = 4;
private int last = STOP;
private static Pilot pilot; // iCommand Java NXT Library
public static void main(String[] args) {
SunSpotHostApplication app = new
SunSpotHostApplication();
startNXT();
app.start();
}
30
31. The Vehicle Controller (source.2)
private static void startNXT() {
try {
NXTCommand.open();
pilot = new Pilot(2.1f,4.4f,Motor.A, Motor.C,true);
} catch(Exception e) {
e.printStackTrace();
}
}
31
36. Conclusions
• Sensors are the new frontier of interaction
• The Sun SPOTs are the quot;cool Java wayquot; to create a
quot;live labquot; for innovative scenarios
of ubiquitous and
pervasive computing
• Extended class library
and full integration of
basestation with
desktop PC gives
everybody the opportunity to HAVE FUN with SPOT
36
37. References
• Sun SPOT World
> http://www.sunspotworld.com
• Sun SPOTs and Java robotics on java.net
> https://sunspot-robotics.dev.java.net/
> http://community.java.net/robotics/
• Sun SPOT purchasing:
> http://www.sunspotworld.com/products
> http://store.systronix.com
• LEGO Mindstorms NXT
> http://mindstorms.lego.com
> http://lejos.sourceforge.net 37
38. Contacts
• Stefano Sanna
> gerdavax@tiscali.it – http://www.gerdavax.it
• JUG Sardegna ONLUS
> http://www.jugsardegna.org
• Java Mobile Developers Forum
> http://www.jmdf.org
38