Project : linux APRS weather station

I have a lacrosse WS-2300-11 weather station. I run linux AX25 with ldsped.
How hard should it be to send out the weather data ?

At first, I thought of incorporating it into ldsped. But since it's not the main goal of ldsped and since *nix is about many little programs doing what they can best, I ended up with only a simple script.

This page explains how to implement this, you might take some ideas form it if you have another setup.

ON7LDS.


 

1. Prerequisites

To start, we need a working weather data collecting program. On my linux system, wview is running.
For the rest of this page, I assume you have a configured and running wview system.
The script also uses the ldsped configuration file to find out your position

 

2. wview

Wview saves its data in a sqlite database. But it is able to save the collected data in an archive text file.
This file is (on my debian system) /var/www/weather/Archive/ARC-YYYY-MM-DD.txt

You can configure wview to keep the archive multiple days. The standard 10 days is enough, we only need the last one.

3. APRS WX data

The APRS protocol reference specifies the weather reports. There are different possibilities (raw, positionless, complete with or without timestamp, ...)
I'm using the the complete weather report format with lat/lon position and timestamp :

weather report format


4. The script : Collecting the data

I'm using a shell script to collect and format the data :

The ldsped config file already holds your postition in nearly the right format. I only have to set the right APRS symbol. I don't like substitution patterns with lots of / and \ but I know no other quick solution, so :

grep trafficpos /etc/ax25/ldsped.conf | awk '{print $2}' | sed s/?/_/ | sed s/\\\\/\\//)
Read the last line of the wview archive data file into a variable :
DATUM=$(date +%Y-%m-%d)
DATA=($(tail /var/lib/wview/img/Archive/ARC-$DATUM.txt -n 1))

Then extract the data from the DATA variable. Next is the code for de wind direction (9 th position in the DATA array). First, three zeros are prepended. Then, the last 3 characters are taken. This way, we always have a 3 position string with prepended zeroes.

WDIR="000"${DATA[9]}
WDIR=${WDIR:(-3)}

The same for all needed data, recalculated when neccesary. Next is the temperature (position 2) which has to be in degrees Farenheit while my weather station gives me degrees Celcius. We need an integer, so the 0.5 is added to round the floating point result to an integer.
Dividing by an integer, gives us an integer result, hence the '/1'.

TEMP=${DATA[2]}
#Celcius to farenheit
TEMP="000"$( echo "($TEMP*1.8+32+0.5)/1" | bc)
TEMP=${TEMP:(-3)}

Finally, all data is put together and the length is checked.

BEACONTEXT="@"$DMH"/"$POS$WDIR"/"$WSPEED"g"$WGUST"t"$TEMP"r"$RAIN"p...P...h"$HUM"b"$BAR"lWS23"

if [ ${#BEACONTEXT} -eq 68 ]
...

The script is then invoked by a second script, pausing 900 seconds each time.

Both scripts can be found in the ldsped download section