An instrumentation
network for weather data on the
Web
Tutorial Details:
An instrumentation network for weather data on the Web
An instrumentation network for weather data on the Web
By: By Rinaldo Di Giorgio and Brian Hindman
Use Java to display data from realtime devices to Web browser clients
his is the first installment in a series of Java Developer columns devoted to the concept of instrumentation over the Web. This month we'll build a low-cost weather station and interface it to the Web. First, we'll introduce the concepts of building Web-based data collection, monitoring, and control systems. Next, we'll present an application, the 1-wire weather station, that uses Java servlet technology to post weather data to a Web server. This will be followed by a discussion of how to use Java to build systems with similar and/or different requirements. We'll point you to established and recognized sources of expertise on the Web that are already running weather data but that don't use Java. You can judge for yourself whether using Java technology could improve the current status quo.
In this article we'll also lay the groundwork for new combinations of Java technology -- for example, XML and object stores -- so that low-cost, easy-to-maintain systems for storing large amounts of time-varying data can be understood and prototyped. We'll cover this theme in greater detail in future articles in this series, introducing Jini implementations and embedded-server versions, as well as introducing an authenticated interface to home-automation devices, which you will actually be able to build yourself. So, if you forget to turn the air conditioner on or want to change the thermostat, with just a few bucks and the information in these upcoming articles, you'll be able to do these things securely with Java technology.
Enabling devices for the Web really does create new services. We aren't talking about making your printer Internet-aware or using your PalmPilot to browse the Web; we're talking about smaller things, like pool temperatures, door locks, weather data -- actually, more data than we can list here -- that could be used by factories and business offices with geographically dispersed locations. The most common example of this is a WebCam. If you've never seen a WebCam, we've included a URL for one in the Resources section . Cameras are easy to interface because well-defined interfaces already exist for them. What if you were asked to make the services or data from some other device available on the Web? Common wisdom in the past has been to connect instrumentation to private networks. This article explores this huge new growth area for Web-based interfaces using Java and Jini. How would you do it? That's the question we'll start to answer in this series. To bring this home, we'll provide code examples that can be used with a real device. This article demonstrates how to interface Dallas Semiconductor's low-cost weather station to the Internet so that data from this weather station is available around the clock to interested Web users.
The article is divided into five parts:
An introduction to the weather station
Building the weather station
Posting realtime weather observations to a weather servlet (a Dallas Semiconductor example of an application using servlets)
A code example for a simple Swing application using the Dallas Semiconductor weather station API
Going forward
Before we launch into a discussion of these four issues, it's important to provide an explanation of realtime data collection and how Java enables this -- a central concept behind the weather station application presented in this article.
Java and realtime data collection
What we mean by realtime is that the readings are from a peripheral unit that is directly connected to a computer -- not collected from some database that was loaded even as recently as a few hours ago in preparation for vector operations on a supercomputer. Although this article focuses on the weather station from Dallas Semiconductor, the goal is to encourage discussion and design of solutions in line with the Java spirit of being open; in other words, diverse types of implementations (meaning different weather stations or other architectures) could be integrated that depart from this particular implementation.
In the future, several different types of weather stations could be offered by different manufacturers. These could use Ethernet and/or wireless protocols on the link layer as the communication media, with diverse protocols and APIs. The beauty of Java technology is that it has so many APIs that use a consistent methodology, enabling mere mortals to connect up different legacy applications with new applications and actually understand what they're doing! For example, you can connect a Jini application with an RMI-based application and, yes, some of that horrible CGI code that you don't want to change. The net result of having this power is to present an interface to users that hides all this complexity, yet leverages components that work. Java really facilitates migration to new technologies very well. We'll demonstrate this in later articles about embedded Web servers.
In the early 1970s, coauthor Rinaldo Di Giorgio worked for the Environmental Protection Agency (EPA), and the organization had as a national goal the instrumentation of the entire water system of the United States. If Java had been available then, applying the concepts in this article would have resulted in a system that would be useful to many countries interested in getting a handle on pollution and global warming. The architectures and techniques we're proposing here are ideally suited to massive deployments of data-collection systems, and Jini goes a long way toward making this type of deployment a reality.
Why does XML matter in realtime data collection?
Recently, there has been much discussion of XML. XML is an emerging standard that may solve the problem of data and formatting being bundled together as it is on an HTML page. JavaWorld featured a comprehensive article on XML, " XML for the absolute beginner ," in its April issue. XML provides a mark-up language that allows weather data to be tagged independently of the source data. In this article on the weather station, whenever you see data that is in a format that seems proprietary, assume it will eventually be tagged with XML as the standard matures and its adoption increases. Collecting realtime data requires an understanding of the data format, the ability to save the data as quickly as it arrives, and the ability to process this data. Data from realtime devices comes in many different formats. As a developer you will have to decode this data and store it. At the current time we're not aware of devices that send XML data, but this would be useful in the marketplace -- although embedding the necessary circuitry for this would probably increase costs significantly. If a device could send XML data directly, you wouldn't need to develop proxies that take the input data stream, decode it, then process it, and then reformat it as XML when users request or want to use this data.
An introduction to the weather station
There are many weather sites on the Web. A partial list thereof is provided in the Resources section .
Recently, Dallas Semiconductor introduced its low-cost 1-wire weather station, which provides realtime readings of the following data:
Temperature
Wind speed
Wind direction
Here's what the weather station looks like:
Figure 1. The Dallas Semiconductor
1-wire weather station, left, replaces the items on the right
with electronic components
One of the reasons we chose the 1-wire weather station jointly produced by Dallas Semiconductor and Texas Weather Instruments is its low-cost architecture that uses a one-wire bus with inexpensive support components. The weather station can communicate both data and power over a single wire cable. The station has various sensors that require power and the ability to transmit data. These sensors are the DS2401 directional indicators for the compass, the DS2429 for wind speed, and the DS1820 for temperature. For those of you interested in a very technical description of the circuitry, the 1-wire weather station article published in Sensors magazine (see Resources ) provides an excellent description. Information on the core technical components, the technical data sheets for the DS2401, DS1820, DS2429, and the one-wire protocol can also be found there.
Building the weather station
To obtain a 1-wire weather station, see Resources . Here you'll also find directions on building the weather station. Once you have the kit in hand, building the weather station requires a modest amount of manual skill and a few tools. The following includes a list of the tools needed to build a weather station, a segment on mistakes to avoid while building it (based on personal experience!), and a note about testing the weather station.
Construction tools
Here's a list of the tools you'll need to build the weather station from the components contained in the kit:
A Phillips screwdriver
Adjustable pliers
Good silicon caulk (clear or white)
A compass
Additional cable -- enough of the twisted-pair type to place the device where you need it
Common construction mistakes and how to avoid them
The weather station kit contains two long rods with rectangular PCB boards on the end. One PCB board contains one magnet; the other contains two magnets. The PCB board with one magnet should be connected to the wind vane, which requires only one magnet. When the vane turns, the magnet passes between eight one-wire chips. These relate to the 8 points of the compass (north, northeast, east, southeast, south, southwest, west, and northwest). To resolve 16 points of the compass, as the magnet passes between two chips, both chips show up on the one-wire bus. Hence, we get NNE, ENE, ESE, SSE, SSW, WSW, WNW, and NNW. The PCB board with two magnets should be turned by the anemometer cups
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: An instrumentation
network for weather data on the
Web
View Tutorial: An instrumentation
network for weather data on the
Web
Related
Tutorials:
JavaWorld - Distributed
applet-based
massively parallel processing
(DAMPP) - January
1997
JavaWorld - Distributed
applet-based
massively parallel processing
(DAMPP) - January
1997 |
An instrumentation
network for weather data on the
Web
An instrumentation
network for weather data on the
Web |
Multicast the chatwaves - JavaWorld October 1999
Multicast the chatwaves - JavaWorld October 1999 |
Make room for JavaSpaces, Part 2 - JavaWorld January 2000
Make room for JavaSpaces, Part 2 - JavaWorld January 2000 |
One, two, three,
or n tiers? - JavaWorld January 2000
One, two, three,
or n tiers? - JavaWorld January 2000 |
Create automated and distributed
management applications with Jiro
technology, Part 1 - JavaWorld February
Create automated and distributed
management applications with Jiro
technology, Part 1 - JavaWorld February 2000 |
XML for the
absolute beginner - JavaWorld - April 1999
XML for the
absolute beginner - JavaWorld - April 1999 |
WAP for Java developers - JavaWorld June
2000
WAP for Java developers - JavaWorld June
2000 |
The Gnutella file-sharing network
and Java - JavaWorld October 2000
The Gnutella file-sharing network
and Java - JavaWorld October 2000 |
The Jxta solution to P2P
The Jxta solution to P2P |
Pushlets: Send
events from servlets to DHTML client browsers
Pushlets: Send
events from servlets to DHTML client browsers |
A birds-eye view of Web services
A birds-eye view of Web services |
Use Web services
to integrate Web applications with
EISs
Use Web services
to integrate Web applications with
EISs |
Test networked
code the easy way
Test networked
code the easy way |
Navigate through
virtual worlds using Java 3D
Navigate through
virtual worlds using Java 3D |
Call on extensible RMI
Call on extensible RMI |
Java Application Instrumentation with Log4J
Java Application Instrumentation with Log4J
Application metrics, such as performance metrics, are key to understanding and improving application efficiency. Profiling and monitoring tools yield valuable information on CPU and resource usage, including OS |
Overview of Servlets and JSP
Servlets are Java technology's answer to CGI programming. They are programs that run on a Web server and build Web pages. Building Web pages on the fly is useful (and commonly done) for a number of reasons. |
Servlets and JavaServer Pages (JSP) : A Tutorial
An excellent tutorial on JSP and Servlets. |
What is WAP? Wireless Application Protocol
What is WAP? Wireless Application Protocol
Tutorial
What is WAP?
W ireless Application Protocol or WAP for short is simply a protocol - a standerized way for delivering Internet data over wireless networks. Thus WAP links Wireless Network with |
|
|
|