Weather station in APRS

This article is a sequel to my article about the construction of my weather station. As this extension is only relevant for radio hams, I have outsourced it.

Transmission into the APRS network

Since the data of the weather station are available cleanly in raw form and with openHAB the possibility exists to convert these without problems into each other format. Therefore it was also possible to feed the data into the APRS network.

With a small PHP script and with rules in openHAB a file is created which prepares the information for APRX. This program then sends the data under my callsign and SSID 13 (for weather station) over the Internet to the APRS network.

If you want to rebuild this, here is the PHP script and the openHAB rules, which I use.

aprs.php

#!/usr/bin/env php
<?php

date_default_timezone_set('UTC');
$outfile = '/opt/wxbeacon.txt';
$settings = '/etc/openhab2/wxvalues.txt';
$line = '@'.date('dHi', time()).'z4956.14N/01132.19E_';
$line_static = '000/000g000';
$software = 'WX/IGate';
$comment = '';
$change = false;

// Werte lesen
$fp = fopen($settings, 'r');
$settings_array = unserialize(fread($fp, 4096));
fclose($fp);

switch($argv[1]) {
case 'T':
  // Temperatur
  $settings_array['temp'] = $argv[2] * 1.8 + 32; // C in F
  $change = true;
  break;
case 'H':
  // Luftfeuchtigkeit
  $settings_array['humidity'] = $argv[2];
  $change = true;
  break;
case 'B':
  // Luftdruck
  $settings_array['barometer'] = ($argv[2] + 46) * 10;
  $change = true;
  break;
}

// Werte speichen
if($change == true) {
  $fp = fopen($settings, 'w');
  fwrite($fp, serialize($settings_array));
  fclose($fp);

  // Statische Werte
  $line .= $line_static;

  // Temperatur
  $line .= 't'.sprintf("%'.03d", $settings_array['temp']);
  // Luftfeuchtigkeit
  $line .= 'h'.sprintf("%'.02d", $settings_array['humidity']);
  // Luftdruck
  $line .= 'b'.sprintf("%'.05d", $settings_array['barometer']);

  // Parameter
  $line .= $software.' '.$comment;

  $fp = fopen($outfile, 'w');
  fwrite($fp, $line);
  fclose($fp);
}
?>

wetterstatino.rule

rule "Wetterstation Temperature"
  when
     Item ws_balkon_temperatur_out received update
  then
      executeCommandLine('/etc/openhab2/scripts/aprs.php T ' + ws_balkon_temperatur_out.state.toString)
end

rule "Wetterstation Humidity"
  when
     Item ws_balkon_luftfeuchtigkeit_out received update
  then
      executeCommandLine('/etc/openhab2/scripts/aprs.php H ' + ws_balkon_luftfeuchtigkeit_out.state.toString)
end

rule "Wetterstation Pressure"
  when
     Item ws_balkon_luftdruck_out received update
  then
      executeCommandLine('/etc/openhab2/scripts/aprs.php B ' + ws_balkon_luftdruck_out.state.toString)
end

View the data

The data is then regularly available in the APRS network. One way to view the station publicly is APRS.fi. There you can also see the recordings of the weather station.