INTRODUCTION  · PROGRAMS  · NEWS · HARDWARE · DOCUMENTS · DOWNLOAD · MISCELLANEOUS · LINKS  

Plotting Oww data with rrdtool

There are several ways you might plot data collected by Oww:

  1. Write logs to text files, and run a separate utility to plot them.
  2. Write logs with owwlog, and run a separate utility to plot them.
  3. Use the postlog facility to write an SQL database, and plot from this with, for example, php.
  4. Use the postlog facility to write an rrdtool round-robin database, and plot from this with rrdtool called from php.

If you'd like to try the last of these I have put together a package of files that should help. You will need rrdtool (version 1.2.10 or later) and a php-enabled Web server.

I am using an NSLU2 "slug", with the unslung firmware. In this case, obtaining the necessary software is simply a case of:

ipkg install php-thttpd
ipkg install rrdtool

On a main-stream platform, your usual server, e.g. Apache, should be fine.

Download and unpack the oww_plotter archive. It should contain the following files:

createRRDcs.sh
This creates the database. Run it and move the resulting database file to an appropriate directory. Ensure that the file ownership and permissions are set so that oww can write to it.
setupNG
This contains the postlog entry from my setupNG file. Copy it to your setup or setupNG file, remembering to change the filename to suit.
wx_plot.php
This is the script that plots a single plot. You may have to change the filename references, and provide for a different set of sensors.
wx_plots.php
This is the top-level script. It returns a Web page with a table of plots made by wx_plot.php.

If you're using unslung you can simply create the database and put it into /opt/share, put the postlog in your /opt/share/setupNG, and copy the php scripts to /opt/share/www.

There is an example plot page here.

You may notice an entry to select alternative formats. This is especially useful when running on an NSLU2, since currently rrdtool takes about 5 seconds to produce each png plot. Other formats are much quicker. Browser support for svg is becoming more wide-spread. It looks good in konqueror (linux) and opera renders it too.

About the database

It pays to think hard about your database before settling on a design. It is very difficult to change later, without losing all your data collected so far. If you may add more sensors in the future, allow for them from the start – you don't have to plot them.

The plots are mostly trivial to construct. The exception is the wind direction plot. Simple averaging will not work here. For example if the direction is alternately just east and just west of north, this will average to south!

So, the data collection stage has to resolve the wind direction and speed into separate notherly and easterly components using cos and sin functions, which are then averaged separately. At plot time these are converted to an angle with the atan2 function I added to rrdtool.

  
SourceForge.net Logo    SUMMARY  · PROJECTS  · SIMON  · MELHUISH.INFO