This post will show you how to generate weather data from LA Crosse WS2300 series weather stations for submission to the APRS network.
APRS software I’m using is Xastir, but you can use this setup to push the weather data to other APRS applications also. Digipeater mode is already set up in Xastir. This post will not cover digipeating WX data.
1. Install packages
apt-get update apt-get install bc ncat unzip gcc build-essential
2. Download open2300 and compile fetch2300
Fetch2300 is part of open2300, it’s used to connect to the weather station and return the data. Credit goes to Kenneth Lavrsen (http://www.lavrsen.dk/foswiki/bin/view/Open2300)
wget -O "open2300-1-10.zip" https://sourceforge.net/projects/open2300/files/open2300/1.10/open2300-1.10.zip/download" unzip open2300-1-10.zip cd open2300-1.10 make fetch2300 cp fetch2300 /usr/local/bin/fetch2300
3. Edit and rename open2300 config file named open2300-dist.conf or copy mine to /etc/open2300/open2300.conf
mkdir -p /etc/open2300 nano /etc/open2300/open2300.conf
SERIAL_DEVICE /dev/ttyUSB1 #/dev/ttyS0, /dev/ttyS1, COM1, COM2 etc
TIMEZONE 1 # Hours Relative to UTC. East is positive, west is negative
WIND_SPEED km/h # select MPH (miles/hour), m/s, or km/h
TEMPERATURE F # Select C or F
RAIN IN # Select mm or IN
PRESSURE hPa # Select hPa, mb or INHG
Note: make sure you select the correct SERIAL_DEVICE in the config. The station in my setup
is connected via USB to RS232 converter so the device is ttyUSB0. Also, don’t change the units, bash script will automatically convert them to be compatible with APRS network.
4. Copy bash script to desired location
mkdir -p /root/ws2300/ nano wxdata_v1.6.sh
#!/bin/bash #This script reads weather data via fetch program which is part of Open2300 suite written by Kenneth Lavrsen (http://www. #lavrsen.dk/foswiki/bin/view/Open2300/WebHome). #It outputs the right data needed to feed Xastir for APRS weather reports. The scripts utilizes Ncat utility as server to #serve the fetched output to Xastir. #Fetched Data is pushed to Ncat server and then to Xastir. (Fetched data -> Ncat server -> Xastir) #Ncat is part of Nmap, get it by installing Nmap. #This script should work for LaCrosse weather stations, WS23xx series. Testing was done with WS2307. #Written by S55MA and S56IUL, May 2016 #DEFINE VARIABLES host="127.0.0.1" port="1234" #Start the Ncat server chkncat=$(netstat -ant | grep $host:$port | grep -c LISTEN) if [ "$chkncat" -ge "1" ] then echo "ncat already running, nothing to do" else nohup ncat -k -l --broker $host $port &>/dev/null & fi #Start while loop while true; do echo "start `date`" datetime=$(date '+%Y%m%d%H%M%S') ws2300config="/etc/open2300/open2300.conf" /usr/local/bin/fetch2300 $ws2300config > /tmp/wxdata-"$datetime".tmp fetch_path="/tmp/wxdata-$datetime.tmp" chkfile=$(ls -la $fetch_path | awk -F ' ' '{ print $5 }') if [ "$chkfile" -le "43" ] then echo "No Data" sleep 30 else tempF=$(cat "$fetch_path" | grep To | grep -v 'min\|max\|DRtot\|TRtot' | awk '{print $2}') temp1=$(echo "$tempF" | awk '{ printf ("%d\n",$1 + 0.5)}') if [ "$temp1" -ge "99" ] || [ "$temp1" -le "-99" ] then temp="$temp1" else if [ "$temp1" -le "-1" ] then if [ "$temp1" -ge "-9" ] then temp2=$(echo "$temp1" | sed 's/[-]//g') temp=$(echo -0"$temp2") else temp2=$(echo "$temp1" | sed 's/[-]//g') temp=$(echo -"$temp1") fi else temp=$(echo 0"$temp1") fi fi windspeed2=$(cat "$fetch_path" | grep -m1 WS | grep -v 'min\|max\|DRtot\|TRtot'| awk '{print $2/1.609344}' | awk '{ printf ("%d\n",$1 + 0.5)}') if [ "$windspeed2" -le "9" ] then windspeed=$(echo 00"$windspeed2") else if [ "$windspeed2" -le "99" ] then windspeed=$(echo 0"$windspeed2") else windspeed=$(echo "$windspeed2") fi fi winddirection2=$(cat "$fetch_path" | grep DIR0 | awk '{print $2}' | sed 's/\..*$//') if [ "$winddirection2" -le "9" ] then winddirection=$(echo 00"$winddirection2") else if [ "$winddirection2" -le "99" ] then winddirection=$(echo 0"$winddirection2") else winddirection=$(echo "$winddirection2") fi fi rain1h=$(cat "$fetch_path" | grep R1h | grep -v 'min\|max' | awk '{print $2}' | sed 's/[.]//g') rain24h=$(cat "$fetch_path" | grep R24h | grep -v 'min\|max' | awk '{print $2}' | sed 's/[.]//g') airpressureR=$(cat "$fetch_path" | grep RP | grep -v 'min\|max' | awk '{print $2}') airpressure2=$(echo "scale=1;$airpressureR / 1" | bc | sed 's/[.]//g') if [ "$airpressure2" -le "9999" ] then airpressure=$(echo 0"$airpressure2") else airpressure=$(echo "$airpressure2") fi relhumidity=$(cat "$fetch_path" | grep RHo | grep -v 'min\|max' | awk '{print $2}' | sed 's/\..*$//') #Combine variables to forge Xastir string xastir="c${winddirection}s${windspeed}t${temp}r${rain1h}p${rain24h}b${airpressure}h${relhumidity}xDvs" printf "%s\n" "$xastir" | ncat --send-only $host $port echo "$xastir" sleep 3 rm -f /tmp/wxdata-*.tmp echo "stop `date`" echo "-----------------------------------" fi done #EOS
If there are some formatting mistakes, the script is also available on pastebin: http://pastebin.com/29q8epF8
5. Start the script
/root/ws2300/wxdata_v1.6.sh
You should see output similar to that:
start Tue May 3 00:36:47 CEST 2016 c112s013t048b10037h85xDvs
Leave the script running, open another terminal and check if ncat is getting data:
ncat localhost 1234
Wait a few seconds and you should get the result similar to that:
c112s018t048b10037h85xDvs
6. Go to Xastir and add the WX interface
Interface -> Interface Control -> Add -> Networked WX
WX Host: 127.0.0.1
WX Port: 1234
Save and start the interface.
7. Go to Xastir, View -> Own Weather Data
You should see your own weather data from the station
8. Start the script at boot and run it in background
Open /etc/rc.local and add
screen -d -m /root/ws2300/wxdata_v1.6.sh
Save and exit
Note: make sure you set your own path of the script location
Hi,
I’ve just implemented your script and i’m having problems with the temperature readout in xastir.
c225s001t011r000p000b10075h71xDvs
this is what is coming out of the script. Xastir sees this as -11 degrees c.
if i manually change to let’s say 1 degree i get a xastir readout at -17
any ideas ?
regards Jan ON6ZG
APRS temperature format is in fahrenheits. So, if you convert t011 (which means 11F) to celsius you get -11°C.
Was wondering if anyone has done this for the Acurite 5 in 1 wx station to be able to have Xastir use the wx data from it?? It has a serial USB connection but I’ve not got any combination of settings to work just in case its format was the same. I’m sure it needs some coding and a coder I’m not.
Thank you for your excellent instructions! I managed to get my La Crosse WS2300 working. Since I connected the weather station to a headless Raspberry Pi without a GUI, I opted not to use Xastir. Instead, I modified your script, wxdata_v1.6.sh, to send data directly to the APRS-IS network. You can see the results here: https://aprs.fi/weather/a/DL9BGG-13 . Would it be alright if I upload the modified script to my GitHub account and include a link to this post to share it with others?
73 & 55 de Stephan 9V1LH / DG1BGS
Sure, no problem.