But unlike in cell phones, Java for Sun SPOT sensors, called Java 2 Micro Edition, runs directly on the hardware and acts as an operating system. This means that Java programmers can write a program, load it onto the device, run it, and debug it, with basic programming knowledge of Java, Meike says. The hardware and software are designed to work together, he says, which allows the Java sensors to be easily reconfigured to different tasks, unlike TinyOS. Java also manages power resources well, according to Meike, an important feature, since some sensors need to be on at all times. “Java is in control over a small battery and it can be very smart about when to put the system to sleep,” he says.
Sun SPOT’s Java runs directly out of flash memory, a type of storage that doesn’t use as much power as RAM memory. This reduces the need for vigilance about how to best allocate resources. Moreover, the Java platform allows applications to be halted in mid-operation and relocated to another device, explains Meike, “So you can imagine if the battery dies on one device, you can move your application to another.”
This mobility feature is especially important for debugging the sensor hardware and software, which “is very much a nightmare,” says Srivastava, who has developed a sensor operating system at UCLA called SOS. “Bugs can really bring something down,” he adds. Therefore, it’s useful to be able to transfer a malfunctioning application to a computer where it can be fixed, something Sun SPOT is capable of doing.
But Srivastava also notes that Java is a “heavy” programming language, meaning it requires more memory than TinyOS or SOS. Indeed, Sun’s new sensors require a 32-bit central processing unit, as opposed to the 8-bit sensor processors that can run TinyOS. In addition, Sun’s sensors have 512 kilobytes of RAM, 4 megabytes of flash memory, a 2.4 gigahertz radio, and a USB interface -– making them veritable goliaths compared to most sensors.
But large sensors could be useful, says Matt Welsh, computer science professor at Harvard. “It’s clear that in any real application, you’re going to end up with a diverse population of devices,” he says. “You might have a large number of very low power wireless sensors, but you also need devices that can collect information, do processing, and aggregate data. The Sun SPOT device looks like it could be a nice candidate for that wireless device.” However, it is unlikely, he says, that Java will replace TinyOS or SOS for the smallest sensors.
Sun’s Meike expects that processors, memory devices, and radios will continue to shrink and Sun’s sensors won’t be so large in a couple of years. “The trends are telling us that these devices are going to get more capable,” he notes. In the meantime, Meike says, the clever applications that Java programmers will devise will be ready for future generations of smaller sensors.
Meike believes that playing around with sensors will offer a compelling experience for Java hobbyists and students. “This means that Java programmers can have a device that fits in the palm of their hands,” he says. “Instead of programming desktop computers, they can program the whole world.”