February 2012 Archives

Weather display

I've had this little weather station, a La Crosse WS2300, for quite some time. It works fine, but the display leaves something to be desired, mainly because it requires pressing buttons to flip between viewing temperatures, rainfall, etc.. I want weather at a glance.


Fortunately I have a large number of monitors, including a 24" monitor just for running TweetDeck, so I took the bottom inch for my current weather display. This is exactly what I wanted. It took most of a day, and involves a surprisingly large amount of technology, but it was fun.

That's: Inside temperature, inside relative humidity, outside temperature, outside relative humidity, dewpoint, wind speed and direction, wind chill, rainfall in the last hour, pressure, outside low temperature in the last 24 hours, outside high temperature and rainfall in the last 24 hours. The display updates every 20 seconds.

All of the historical information is pulled right out of the weather station so it doesn't need to have a database in the server and it works even when the computer is off. 

There are a number of weather display tools, including one I had used in the past, wview. Now wview has many features my little weather viewer does not, like graphs, database support, weather uploading, etc. but it's a very heavy-weight program that periodically generates pages and graphs in image files and uploads them to a web server. And it's very web 1.0, it looks old school and when the page updates, the page goes blank and everything reloads. 

wview: full-featured, but not what I was looking for.

Fortunately, the WS2300 has a serial interface and there is a very handy free program, Open2300, that speaks the arcane, sparsely documented WS2300 serial protocol. That saved days and days of development. It was tested on Linux and Windows but fortunately it built with no problems on the Mac.

There's a server component that I wrote Java and runs in Apache Tomcat. This is overkill - it could have easily been written in PHP, for example, but originally I was going to use OpenJ2300, the Java version of Open2300 until I ran into a problem with 64-bit Java serial drivers.

My Java webapp takes the output from Open2300 and caches it. And it contains a servlet that takes the data, converts units, and outputs JSON.

The user interface is HTML, CSS3 and AJAX. It uses jquery to download a block of JSON data from the server with the current weather conditions every 20 seconds then it updates the HTML DOM. The beauty of this technique is that very little data is transferred between the server and the client and since the page never reloads the updates are flicker-free. And it's image-free and even table-free. It's all rendered in CSS3, even the shadowed boxes.

Here's the source: ws2300.zip. This was a quick one-day hack so it's not designed to run out of the box. You'll need to compile the Java and run it on a Tomcat server. And build an install Open2300. This is left as an exercise for the reader. 

The last piece is that I use the MacOS X Automator to make a "Web Popup App" so the web page displays in a standalone window without all of the regular web brower stuff like a URL bar, controls, etc.. 

Update #1: Automator worked okay, but Fluid works better. Fluid makes regular apps instead of the weird floating window that Automater makes. The apps appear in the dock normally and there isn't that annoying animated gear icon in the toolbar that Automater has. So Fluid is the way to go.

I'm really liking the weather-at-a-glance. Not bad for a day's work!

Update #2: And now the alarm system monitoring server queries the temperature monitoring server and if the inside temperature in my house falls below 45°F it sends me a text. Neat!

Update #3: I wrote a quick iPhone version of the weather viewer. It's a real Objective-C iOS app. The app communicates with the same server, though it uses the SSL encrypted external version of the server so I can check on the weather conditions at my house from anywhere. Piece of cake with ASIHTTPRequest to pull the data down and JSONKit to parse the data and throw it into a table view. 

Update #4: When the temperature is above 70°F the Wind Chill box now changes to Heat Index/Humiture. This is the formula, really!

wcOrHeatIndex = 0.363445176 + (0.988622465 * data.To) + 
(4.777114035 * data.RHo) +
(-0.114037667 * data.To * data.RHo) +
(-0.000850208 * (data.To * data.To)) +
(-0.020716198 * (data.RHo * data.RHo)) + 
(0.000687678 * (data.To * data.To) * data.RHo) + 
(0.000274954 * data.To * (data.RHo * data.RHo));

About this Archive

This page is an archive of entries from February 2012 listed from newest to oldest.

March 2011 is the previous archive.

March 2012 is the next archive.

Find recent content on the main index or look in the archives to find all content.