{"id":469,"date":"2017-08-12T10:39:33","date_gmt":"2017-08-12T15:39:33","guid":{"rendered":"http:\/\/www.k2dls.net\/blog\/?p=469"},"modified":"2017-08-12T13:18:45","modified_gmt":"2017-08-12T18:18:45","slug":"aprx-and-weather-reporting","status":"publish","type":"post","link":"https:\/\/www.k2ie.net\/blog\/2017\/08\/12\/aprx-and-weather-reporting\/","title":{"rendered":"aprx and weather reporting"},"content":{"rendered":"<p>I&#8217;ve been sending weather reports via <a href=\"http:\/\/www.aprs-is.net\/\">APRS-IS<\/a> and RF for some years and have recently re-architected the way it works.\u00a0 My APRS station uses <a href=\"http:\/\/thelifeofkenneth.com\/aprx\/\">aprx<\/a> software running on a Raspberry Pi Model B.<\/p>\n<p>My weather station is a <a href=\"https:\/\/www.amazon.com\/gp\/product\/B002LLVFK0\/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B002LLVFK0&amp;linkCode=as2&amp;tag=k0a5c-20&amp;linkId=28d59f5830e67523bed0cf185c2f318e\">Davis Vantage Vue<\/a> with <a href=\"https:\/\/www.amazon.com\/gp\/product\/B0012OGFAW\/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;tag=k0a5c-20&amp;camp=1789&amp;creative=9325&amp;linkCode=as2&amp;creativeASIN=B0012OGFAW&amp;linkId=b17ef7ae0e3e381db3020c9b930474cf\">WeatherLinkIP<\/a> module. The module allows the weather station to plug directly into my ethernet network. I formerly used WeatherLinkIP to feed the data to <a href=\"http:\/\/wxqa.com\/\">CWOP<\/a> which would in turn show up on APRS-IS.\u00a0 I would then gateway my reports back to RF using an aprx filter.\u00a0 This seemed convoluted to me, so I wanted to improve things.<\/p>\n<p>I now use a program called <a href=\"http:\/\/www.weather-display.com\/index.php\">Weather Display<\/a>, a very capable weather program, which has the capability to generate an APRS <a href=\"http:\/\/wiki.sandaysoft.com\/a\/Wxnow.txt\">WXNOW.TXT<\/a> file.\u00a0 Weather Display can directly poll the Davis station via IP.\u00a0 Through the steps documented below, I now send my weather reports via RF and APRS-IS in the same step.<\/p>\n<p>Every 10 minutes, via crond, I perform some preprocessing on the WXNOW.TXT file to embed the weather report in the APRS &#8220;<a href=\"http:\/\/www.aprs.org\/doc\/APRS101.PDF\">Complete Weather Report Format<\/a> \u2014 with Lat\/Long position and Timestamp&#8221; and then secure copy the file over to my Raspberry Pi APRS system:<\/p>\n<pre>#!\/bin\/bash\r\n#\r\nif [ ! -f ~\/tmp\/WXNOW.TXT ]; then\r\n   exit 1\r\nfi\r\n# Change to the Lat\/Long of your weather station\r\nLATLONG=\"4023.75N\/07412.53W\"\r\nline=0\r\nwhile read FILE; do\r\n   if [ $line = 0 ]; then\r\n      # Change America\/New_York to your timezone\r\n      TIME=`TZ=UTC date --date=\"TZ=\\\"America\/New_York\\\" $FILE\" +%d%H%M`\r\n      line=$((line+1))\r\n   fi\r\nWX=$FILE\r\ndone &lt; ~\/tmp\/WXNOW.TXT # echo \/$TIME\\z$LATLONG\\_$WX &gt; ~\/tmp\/wxnow.tmp\r\n# \r\necho `cat ~\/tmp\/wxnow.tmp | tr -d '\\r'`XDsIP &gt; ~\/tmp\/wxnow.txt\r\n# You must setup ssh key based authentication for this to work\r\n# Another method could be a file copy via NFS or CIFS\r\nscp ~\/tmp\/wxnow.txt pi@aprs:\/dev\/shm\/wxnow.txt\r\n# \r\nrm ~\/tmp\/wxnow.txt ~\/tmp\/wxnow.tmp\r\n<\/pre>\n<p>On the APRS host, I defined the following beacon section in \/etc\/aprx.conf:<\/p>\n<pre>beaconmode both\r\ncycle-size 10m\r\n\r\nbeacon via WIDE2-1 \\\r\nsrccall N0CALL-13 \\\r\nexec \/usr\/local\/bin\/aprx-wxnow.sh<\/pre>\n<p>Finally, the beacon exec script, is installed in \/usr\/local\/bin\/aprx-wxow.sh:<\/p>\n<pre>#!\/bin\/bash\r\n#\r\nTIME=$(printf `date -u \"+%d%H%M\"`)\r\nif [ -f \/dev\/shm\/wxnow.txt ]; then\r\n   if [ -f \/dev\/shm\/wxold.txt ]; then\r\n      FULLWXOLD=`cat \/dev\/shm\/wxold.txt`\r\n   else\r\n      FULLWXOLD=\"\"\r\n   fi\r\n   FULLWXNOW=`cat \/dev\/shm\/wxnow.txt`\r\n   if [ \"$FULLWXOLD\" == \"$FULLWXNOW\" ]; then\r\n      # Convert date\/times to minutes for date arithmetic\r\n      CURDAY=`echo $TIME | cut -b 1-2`\r\n      OLDDAY=`echo $FULLWXOLD | cut -b 2-3`\r\n      CURHR=`echo $TIME | cut -b 3-4`\r\n      OLDHR=`echo $FULLWXOLD | cut -b 4-5`\r\n      CURMIN=`echo $TIME | cut -b 5-6`\r\n      OLDMIN=`echo $FULLWXOLD | cut -b 6-7`\r\n      CURTIME=$((10#$CURDAY * 1440 + 10#$CURHR * 60 + 10#$CURMIN))\r\n      OLDTIME=$((10#$OLDDAY * 1440 + 10#$OLDHR * 60 + 10#$OLDMIN))\r\n      # If report older than 20 minutes then not updating\r\n      if (( $(($CURTIME-$OLDTIME)) &gt; 20 )) ; then\r\n         echo -n \\&gt;$TIME\\z\r\n         echo \" WX rpt not updating\"\r\n         exit 0\r\n      fi\r\n      # Unchanged report but &lt;= 20 min old then don't transmit\r\n      echo\r\n      exit 0\r\n   else\r\n      OLDRPT=`echo $FULLWXOLD | cut -b 9-`\r\n      NEWRPT=`echo $FULLWXNOW | cut -b 9-`\r\n      #if new and old report are same then don't transmit\r\n      if [ \"$OLDRPT\" == \"$NEWRPT\" ]; then\r\n         echo\r\n         exit 0\r\n      fi\r\n      # Transmit report and copy wxnow.txt to wxold.txt\r\n      echo $FULLWXNOW cp \/dev\/shm\/wxnow.txt \/dev\/shm\/wxold.txt\r\n   fi\r\nelse\r\n   echo -n \\&gt;$TIME\\z\r\n   echo \" WX rpt not found\"\r\nfi<\/pre>\n<p>While debugging, I noticed that the wxnow.txt file would sometimes disapper from \/dev\/shm.\u00a0 This turned out to be systemd cleaning up interprocess communication whenever the pi user logged out.\u00a0 I fixed this by adding the following line to \/etc\/systemd\/logind.conf:<\/p>\n<p><code>RemoveIPC=no<\/code><\/p>\n<p>Following this change, you must restart systemd-logind.service:<\/p>\n<p><code>sudo systemctl restart systemd-logind.service<\/code><\/p>\n<p>If you implement this on your aprx system, please leave a comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been sending weather reports via APRS-IS and RF for some years and have recently re-architected the way it works.\u00a0 My APRS station uses aprx software running on a Raspberry Pi Model B. My weather station is a Davis Vantage Vue with WeatherLinkIP module. The module allows the weather station to plug directly into my &hellip; <a href=\"https:\/\/www.k2ie.net\/blog\/2017\/08\/12\/aprx-and-weather-reporting\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;aprx and weather reporting&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[64,61,63,62],"class_list":["post-469","post","type-post","status-publish","format-standard","hentry","category-radio","category-technology","tag-aprs","tag-aprx","tag-cwop","tag-weather"],"_links":{"self":[{"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/posts\/469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/comments?post=469"}],"version-history":[{"count":23,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/posts\/469\/revisions"}],"predecessor-version":[{"id":492,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/posts\/469\/revisions\/492"}],"wp:attachment":[{"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.k2ie.net\/blog\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}