The weather.sh Bash script

weather.sh was developed as a quick and simple way to view the data from the Argent Data Systems ADS-WS1 Weather Instruments. The objective was to NOT have to purchase a physical Display unit nor have to pay for any fancy software for Linux or Windows. This software provides nearly instant satisfaction that your weather instruments are working -AND- it can be used as your weather display just as it is! Leave it running in an Xterm, buried in a corner of your screen, or leave it minimized and pull it up when you wish to see the weather. Very simple!

This script is designed to be run as 'root' so it can grab the serial port without first modifying its permissions. It *can* be run as a 'user' if the /dev/tty device permissions are changed (see the code for instructions to do this). The script receives the 2400 baud serial data stream coming from the ADS-WS1 device, parses the respective fields, and displays them on the screen. The screen is TEXT based and requires NO additional software packages to be loaded or configured! Just open up a terminal window (xterm) and type "./weather.sh" and it runs! The screen will update once every 5 seconds (configurable). It's just that simple :)

When first started, several fields in the display are filled with zeros and will be replaced with real values as the script runs over the course of the first day. Each night at 1 minute before midnight, some statistics (Hi/Lo temps, Peak wind, Daily and Long-term rainfall) are written out to a log file (weather.log).

Completely FREE and licensed under the GPL. So if you modify it, *please* contribute your work back to us for possible inclusion in future releases.


Here is a sample of what the screen will display...

 
   Argent Data Systems - Weather Station Display 
    By: Jay Nugent - WB8TKL - V1.0 (c 2012) GPL 
 
   Sun May 13 11:20:55 EDT 2012 
   Day of Year: 133 Julian   Minute of Day: 667 (1440 mins/Day)
-----------------------------------------------------------------
Temperature    @6' : 64.1 degF
24-Hour High/Low   : 64 / 52
Humidity       @6' : 66 %
Dew Point          : 52 degF
Barometric     @6' : 1024 millibars   30.20 inHg
Barometric History : Mid=30.17  6am=30.19  Noon=30.17  6pm=30.14 
--------------------------------
Wind Speed     @11': 6 knots   7 mph
Wind Direction     : NNW
Wind Avg/Minute    : 5 mph
Max Gust (10 mins) : 8 mph
Max Daily Gust     : 16 mph
--------------------------------
Daily Rainfall @10': 00.04 inches
Long Term Rain     : 01.07 inches
Rain Rate (in/hr)  : 
   01=0.00   02=0.00   03=0.00   04=0.00   05=0.00   06=0.00 
   07=0.01   08=0.00   09=0.03   10=0.00   11=0.00   12=0.00 
   13=0.00   14=0.00   15=0.00   16=0.00   17=0.00   18=0.00 
   19=0.00   20=0.00   21=0.00   22=0.00   23=0.00   24=0.00 
-----------------------------------------------------------------


And here is the code that does all of the work...
Click to DOWNLOAD a copy of the weather.sh bash script.

#!/bin/bash
#
#  WEATHER.SH
# o A weather data display program (bash shell script) for Linux.
# o This code is for use with the Argent Data Systms ADS-WS1 unit.
#
# VERSION:
#=========
# 1.0 - First release
#
# DATA FORMAT:
#=============
# o The data stream is 2400 baud, 8 bit, 1 stop, no parity.
# o The data format is based on the Peet Brother's serial data format.
# o FORMAT: !!001F009F030A002E26AD030A01EA----0069043A002C001E
#  The leading !! will be stripped and replaced with "aaaa" in this code.
#  Each 4-byte hex block represent the following:
#  Speed (0.1 kph), Direction (0-255), Outdoor Temp (0.1 degF)
#  Long Term Rain (0.01 in), Barometer (0.1 mbar), Indoor Temp (0.1 degF)
#  Outdoor Humidity (0.1%), Indoor Humidity (0.1%), Day Of Year
#  Minute Of Day, Today's Rain Total (0.01 in), 1 Minute Wind Average (0.1 kph) 
#
# RUNNING THE SCRIPT:
#====================
# o Simply type the script name (weather.sh) into an XTERM window to start 
#   it running.  This usually requires root access to control the serial port.
#   The program will start, read the ADS-WS1 data, parse it, then display
#   the formatted results within the XTERM.
#   It will update the screen every 5 seconds (this is configurable).
#
# o To run the script with the output redirected to a file, enter the following:
#      ./weather.sh > weather.results &    (the "&" puts it in the background)
#   Then use 'tail -f weather.results' to watch the output.
#
# AUTHOR:
#========
# By: Jay Nugent  WB8TKL  jjn@nuge.com
# Date: 120406 thru 120508
# NOTICE: This software is free and Open Sourced under the rules
#         of the Linux GPL. Please contribute any improvements
#         back to the Open Source community.  Certainly send your
#         comments, fixes, improvements back to me for possible 
#         inclusion in the next version release!
#
# Known Bugs:
#============
# - Temperature will place the decimal point in the wrong place for temps
#   under 10 degrees (single digits).
# - Wind Direction *may* be reversed (CW vs CCW) as my wind vane is mounted
#   on the opposite end of the boom than what the directions state.
#
# TODO List:
#===========
# - Add Wind Chill
# - Add Heat Index
# - Produce web ready output (wrap inside PRE tags perhaps)
# - Run as a user rather than as root
# - Run as a daemon and use a seperate program to display to the screen
#
# Configuration Settings & Calibration:
#======================================
# Number of seconds between screen updates
DELAY=5
#
# Serial port that the ADS-WS1 is attached to:
# /dev/ttyS0 = COM1   /dev/ttyS1 = COM2
PORT=/dev/ttyS0
#
# NOTE: The default permissions of ttyS# work for root.  
#       To run as a 'user', then the permissions of /dev/ttyS0 must be 777(crwxrwxrwx). 
#       To do this, you must su to root and do 'chmod 777 /dev/ttyS0'
#       Now users can run this code (otherwise it can only be run as root).
#
# Set to 1 to show the Serial Data String coming in from the instruments 
# at the bottom of the display, including any bad receives.
COMMTEST=0
#
# Correction factor for the barometric pressure.  
# This is needed to calibrate the sensor for differences in altitude.
# It *MUST* be calibrated for your altitude/location!!!
# You can adjust it here, or adjust it within the ADS-WX1 using the 
# configuration software from Argent Data Systems (Windows software).
BAROFIX=20
#
# --- do not change any settings below this line ---
#
# Preset Wind Gust (MPHPEAK DAILYPEAK) variables and set 1st pass flag
# (will get reset to 0 after the first pass through the code)
FIRSTPASS=1
MPHPEAK=0
DAILYPEAK=0
#
# Daily logging
DAILY=0
LOGFYLE="weather.log"
#
# TEMP Min and Max must start somewhere...at the extreme opposites
TEMPHI="0"
TEMPLO="100"
#
# BARO needs to start somewhere...so show all zeros
BARO00="00.00"
BARO06="00.00"
BARO12="00.00"
BARO18="00.00"
#
# Hourly Rain needs to be preset to zeros so we don't get math errors
HR1=0  HR2=0  HR3=0  HR4=0  HR5=0  HR6=0
HR7=0  HR8=0  HR9=0  HR10=0 HR11=0 HR12=0
HR13=0 HR14=0 HR15=0 HR16=0 HR17=0 HR18=0
HR19=0 HR20=0 HR21=0 HR22=0 HR23=0 HR24=0
#
# Set the serial port (/dev/ttyS0) to 2400,8,1,no parity
#                      2400 baud, 8 bit, no parity, 1 stop bit
  stty -F $PORT ispeed 2400 ospeed 2400 cs8 -ignpar -cstopb
#
#
#============
# Main Loop:
#============
while true
do
   # Read in a string (ending with CRLF) then strip the !!
   read ADSWS0 < $PORT
   ADSWS1="`echo $ADSWS0 | sed s/\!!/aaaa/ `"
#
# Verify the string was the correct length:
#  (52 characters plus CR and LF equals 54)
   ADSLEN="`echo $ADSWS1 | wc -m`"
      if (expr $ADSLEN == 54) >& /dev/null
         then
            # Continue with the report...
            # else is at the bottom of this code...
#
#
# Prepare the screen for data:
#==============================
clear
DT="`date`"
echo " "
echo "   Argent Data Systems - Weather Station Display "
echo "    By: Jay Nugent - WB8TKL - V1.0 (c 2012) GPL "
echo " "
echo "   $DT "
#
#
# Parse and Display the Data:
#=============================
echo -n "   Day of Year: "
DOYHEX=`echo $ADSWS1 | cut -b 37-40`
JULIAN=`echo "ibase=16; $DOYHEX" | bc`
echo -n "$JULIAN Julian   "
#
echo -n "Minute of Day: "
MODHEX=`echo $ADSWS1 | cut -b 41-44`
MOD=`echo "ibase=16; $MODHEX" | bc`
echo "$MOD (1440 mins/Day)"
#
echo "-----------------------------------------------------------------"
echo -n "Temperature    @6' : "
TEMPHEX=`echo $ADSWS1 | cut -b 13-16`
TEMPDEC=`echo "ibase=16; $TEMPHEX" | bc`
echo -n `echo $TEMPDEC | cut -b 1-2`
echo -n "."
echo -n `echo $TEMPDEC | cut -b 3`
echo  " degF"
#
#----------
echo -n "24-Hour High/Low   : "
#
# Test for Midnight
if (expr $MOD == "0") >& /dev/null
    then
       # Reset values to opposite extremes
       let TEMPHI=0
       let TEMPLO=100
fi
#
let TEMPF=`echo $TEMPDEC | cut -b 1-2`
#
# Test if the current Temp is higher
if [ $TEMPF -gt $TEMPHI ];
   then
      let TEMPHI=$TEMPF
fi
#
# Test if the current Temp is lower
if [ $TEMPF -lt $TEMPLO ];
   then
      let TEMPLO=$TEMPF
fi
#
echo -n "$TEMPHI / "
echo "$TEMPLO"
#
#----------
#
echo -n "Humidity       @6' : "
HUMHEX=`echo $ADSWS1 | cut -b 29-32`
HUMDEC=`echo "ibase=16; $HUMHEX" | bc`
let HUMIDITY=$HUMDEC/10
echo "$HUMIDITY %"
#
#----------
#
echo -n "Dew Point          : "
# Formula:  TDEW = T - 9(100-RH%) / 25
# Get the integers of the temperature and humidity
let TEMPI=$TEMPDEC/10
let HUMI=$HUMDEC/10
let HUM100=100-$HUMI
let MULT9=$HUM100*9
let RHFACTOR=$MULT9/25
let TDEW=$TEMPI-$RHFACTOR
echo "$TDEW degF"
#
#----------
# Heat Index
#  - Need a good formula for this... the one below is mighty gnarly!
# 
# http://en.wikipedia.org/wiki/Heat_index#Formula
#
# The formula below approximes the heat index in degrees Fahrenheit, to within ±1.3 °F. 
# It is the result of a multivariate fit (over temperatures at least 80°F and relative 
# humidity at least 40%) to a model of the human body.
#
#    HI = c1 + c2 T + c3 R + c4 T R + c5 T^2 + c6 R^2 + c7 T^2R + c8 T R^2 + c9 T^2 R^2 
#
# where
#
#    HI = heat index (in degrees Fahrenheit)
#    T  = ambient dry-bulb temperature (in degrees Fahrenheit)
#    R  = relative humidity (in percent)
#    c1 = -42.38,  c2 = 2.049,  c3 = 10.14,  c4 = -0.2248,  c5 = -6.838 times 10^{-3},  
#    c6 = -5.482 times 10^{-2},  c7 = 1.228 times 10^{-3},  c8 = 8.528 \times 10^{-4}, 
#    c9 = -1.99 times 10^{-6}
#
# For example, with temperature 90 °F (32 °C) and relative humidity (RH) of 85%, the 
# result would be: Heat index for 90 °F, RH 85% =114.9.
#
# An alternative set of constants for this equation which is within 3 degrees of the 
# NWS master table for all humidities from 0 to 80% and all temperatures between 70 
# and 115 °F and all heat indexes < 150 °F is C1 = 0.363445176, C2= 0.988622465, 
# C3=4.777114035, C4=-0.114037667, C5=-0.000850208, C6=-0.020716198, C7=0.000687678, 
# C8=0.000274954, C9=0 (unused).
#
#----------
#
echo -n "Barometric     @6' : "
PRESHEX=`echo $ADSWS1 | cut -b 21-24`
PRESDEC=`echo "ibase=16; $PRESHEX" | bc`
# Ignore tenths of a millibar
let PRESDEC10=$PRESDEC/10
# Add a correction factor for your sites altitude
let PRESDEC10=$PRESDEC10+$BAROFIX
echo -n "$PRESDEC10 millibars   "
# 1 millibar = 0.0295 inHg (0.0295333727 to be exact)
let INHG10K=$PRESDEC10*295
let INHG=$INHG10K/100
echo -n `echo $INHG | cut -b 1-2`
echo -n "."
echo -n `echo $INHG | cut -b 3-4`
echo " inHg"
#
#---
#
if [ $MOD -eq 0 ];
   then
      BARO00=`echo $INHG | cut -b 1-2`.`echo $INHG | cut -b 3-4`
fi
if [ $MOD -eq 360 ];
   then
      BARO06=`echo $INHG | cut -b 1-2`.`echo $INHG | cut -b 3-4`
fi
if [ $MOD -eq 720 ];
   then
      BARO12=`echo $INHG | cut -b 1-2`.`echo $INHG | cut -b 3-4`
fi
if [ $MOD -eq 1080 ];
   then
      BARO18=`echo $INHG | cut -b 1-2`.`echo $INHG | cut -b 3-4`
fi
echo "Barometric History : Mid=$BARO00  6am=$BARO06  Noon=$BARO12  6pm=$BARO18 "
#
echo "--------------------------------"
#
echo -n "Wind Speed     @11': "
SPEEDHEX=`echo $ADSWS1 | cut -b 5-8`
SPEEDDEC=`echo "ibase=16; $SPEEDHEX" | bc`
let KNOTS=$SPEEDDEC/10
echo -n "$KNOTS knots   "
# Convert knots to MPH (knots * 1.151 = mph)
# but we have to do it with integer math
let MPH1K=$SPEEDDEC*1151
# Divide the results by 10,000 to get an integer result (no 1/10ths)
let MPH=$MPH1K/10000
echo "$MPH mph"
#
#----------
#
echo -n "Wind Direction     : "
# Ignore the upper two digits of the wind direction 
# We only need this one digit for a 16-point compass 
DIR="`echo $ADSWS1 | cut -b 11`"
if (expr $DIR == "0") >& /dev/null
   then
      echo "North"
fi
if (expr $DIR == "1") >& /dev/null
   then
      echo "NNE"
fi
if (expr $DIR == "2") >& /dev/null
   then
      echo "NE"
fi
if (expr $DIR == "3") >& /dev/null
   then
      echo "ENE"
fi
if (expr $DIR == "4") >& /dev/null
   then
      echo "East"
fi
if (expr $DIR == "5") >& /dev/null
   then
      echo "ESE"
fi
if (expr $DIR == "6") >& /dev/null
   then
      echo "SE"
fi
if (expr $DIR == "7") >& /dev/null
   then
      echo "SSE"
fi
if (expr $DIR == "8") >& /dev/null
   then
      echo "South"
fi
if (expr $DIR == "9") >& /dev/null
   then
      echo "SSW"
fi
if (expr $DIR == "A") >& /dev/null
   then
      echo "SW"
fi
if (expr $DIR == "B") >& /dev/null
   then
      echo "WSW"
fi
if (expr $DIR == "C") >& /dev/null
   then
      echo "West"
fi
if (expr $DIR == "D") >& /dev/null
   then
      echo "WNW"
fi
if (expr $DIR == "E") >& /dev/null
   then
      echo "NW"
fi
if (expr $DIR == "F") >& /dev/null
   then
      echo "NNW"
fi
#
#----------
#
echo -n "Wind Avg/Minute    : "
AVGSPDHEX=`echo $ADSWS1 | cut -b 49-52`
AVGSPDDEC=`echo "ibase=16; $AVGSPDHEX" | bc`
# Convert knots to MPH (knots * 1.151 = mph)
# but we have to do it with integer math
let AVGMPH1K=$AVGSPDDEC*1151
# Divide the results by 10,000 to get an integer result (no 1/10ths)
let AVGMPH=$AVGMPH1K/10000
echo "$AVGMPH mph"
#
#----------
#
echo -n "Max Gust (10 mins) : "
# Perform 10 minute test and reset the MPHPEAK counter if enough
# time has passed.
# 
# The FIRSTPASS flag is needed to run the following snippett of code 
# only the *first* time the program is started.  This is because we have
# no idea what the Minute Of Day (MOD) timer will contain at startup.
if [ $FIRSTPASS -eq 1 ];
   then 
      let MODSTORE=$MOD+10
      let FIRSTPASS=0
fi
#
#
if [ $MOD -eq $MODSTORE ];
   then
      # Reset the counter
      let MPHPEAK=0
      let MODSTORE=$MOD+10
   #
   else
   # Keep collecting the highest peak 
   if [ $MPH -gt $MPHPEAK ];
      then
         let MPHPEAK=$MPH
   fi
   # Store the highest peak for the Day
   if [ $MPH -gt $DAILYPEAK ];
      then
         let DAILYPEAK=$MPH
   fi
fi 
#
# How to deal with midnight and going too far
if [ $MODSTORE -gt 1439 ];
   then
      let MODSTORE=10
fi
#
echo "$MPHPEAK mph"
echo "Max Daily Gust     : $DAILYPEAK mph"
#
#----------
#
##echo    "Wind Chill         : "
#  There is a horrendous formula for this.
#  Maybe sometime I'll take a stab at it...
#
echo "--------------------------------"
#
echo -n "Daily Rainfall @10': "
RAINHEX=`echo $ADSWS1 | cut -b 45-48`
RAINDEC=`echo "ibase=16; $RAINHEX" | bc`
# Add 10000 so we have a few zeros to work with
let RAIN10K=$RAINDEC+10000
echo -n "`echo $RAIN10K | cut -b 2-3`"
echo -n "."
echo -n "`echo $RAIN10K | cut -b 4-5`"
echo " inches"
#
#----------
#
echo -n "Long Term Rain     : "
LONGRAINHEX=`echo $ADSWS1 | cut -b 17-20`
LONGRAINDEC=`echo "ibase=16; $LONGRAINHEX" | bc`
# Add 10000 so we have a few zeros to work with
let LONGRAIN10K=$LONGRAINDEC+10000
echo -n "`echo $LONGRAIN10K | cut -b 2-3`"
echo -n "."
echo -n "`echo $LONGRAIN10K | cut -b 4-5`"
echo " inches"
#
#----------
echo    "Rain Rate (in/hr)  : "
#
# Get a running total of all previous hours.  Subtract that total from 
# the Daily Rainfal total (RAINDEC) and the difference is the rainfall 
# for the past 60 minutes.
#
if [ $MOD -eq 60 ];
   then
      let HR1=$RAINDEC
      # Add 1000 so we have a few zeros to work with
      let HR1K1=$HR1+1000
fi
#
if [ $MOD -eq 120 ];
   then
      let HR2=$RAINDEC-$HR1
      let HR2K1=$HR2+1000
fi
#
if [ $MOD -eq 180 ];
   then
      let HR3="$RAINDEC-($HR2+$HR1)"
      let HR3K1=$HR3+1000
fi
#
if [ $MOD -eq 240 ];
   then
      let HR4="$RAINDEC-($HR3+$HR2+$HR1)"
      let HR4K1=$HR4+1000
fi
#
if [ $MOD -eq 300 ];
   then
      let HR5="$RAINDEC-($HR4+$HR3+$HR2+$HR1)"
      let HR5K1=$HR5+1000
fi
#
if [ $MOD -eq 360 ];
   then
      let HR6="$RAINDEC-($HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR6K1=$HR6+1000
fi
#
if [ $MOD -eq 420 ];
   then
      let HR7="$RAINDEC-($HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR7K1=$HR7+1000
fi
#
if [ $MOD -eq 480 ];
   then
      let HR8="$RAINDEC-($HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR8K1=$HR8+1000
fi
#
if [ $MOD -eq 540 ];
   then
      let HR9="$RAINDEC-($HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR9K1=$HR9+1000
fi
#
if [ $MOD -eq 600 ];
   then
      let HR10="$RAINDEC-($HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR10K1=$HR10+1000
fi
#
if [ $MOD -eq 660 ];
   then
      let HR11="$RAINDEC-($HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR11K1=$HR11+1000
fi
#
if [ $MOD -eq 720 ];
   then
      let HR12="$RAINDEC-($HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR12K1=$HR12+1000
fi
#
if [ $MOD -eq 780 ];
   then
      let HR13="$RAINDEC-($HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR13K1=$HR13+1000
fi
#
if [ $MOD -eq 840 ];
   then
      let HR14="$RAINDEC-($HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR14K1=$HR14+1000
fi
#
if [ $MOD -eq 900 ];
   then
      let HR15="$RAINDEC-($HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR15K1=$HR15+1000
fi
#
if [ $MOD -eq 960 ];
   then
      let HR16="$RAINDEC-($HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR16K1=$HR16+1000
fi
#
if [ $MOD -eq 1020 ];
   then
      let HR17="$RAINDEC-($HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR17K1=$HR17+1000
fi
#
if [ $MOD -eq 1080 ];
   then
      let HR18="$RAINDEC-($HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR18K1=$HR18+1000
fi
#
if [ $MOD -eq 1140 ];
   then
      let HR19="$RAINDEC-($HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR19K1=$HR19+1000
fi
#
if [ $MOD -eq 1200 ];
   then
      let HR20="$RAINDEC-($HR19+$HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR20K1=$HR20+1000
fi
#
if [ $MOD -eq 1260 ];
   then
      let HR21="$RAINDEC-($HR20+$HR19+$HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR21K1=$HR21+1000
fi
#
if [ $MOD -eq 1320 ];
   then
      let HR22="$RAINDEC-($HR21+$HR20+$HR19+$HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR22K1=$HR22+1000
fi
#
if [ $MOD -eq 1380 ];
   then
      let HR23="$RAINDEC-($HR22+$HR21+$HR20+$HR19+$HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR23K1=$HR23+1000
fi
#
if [ $MOD -eq 1439 ];
   then
      let HR24="$RAINDEC-($HR23+$HR22+$HR21+$HR20+$HR19+$HR18+$HR17+$HR16+$HR15+$HR14+$HR13+$HR12+$HR11+$HR10+$HR9+$HR8+$HR7+$HR6+$HR5+$HR4+$HR3+$HR2+$HR1)"
      let HR24K1=$HR24+1000
fi
#
echo -n "   01="
echo -n "`echo $HR1K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR1K1 | cut -b 3-4`"
echo -n "   02="
echo -n "`echo $HR2K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR2K1 | cut -b 3-4`"
echo -n "   03="
echo -n "`echo $HR3K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR3K1 | cut -b 3-4`"
echo -n "   04="
echo -n "`echo $HR4K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR4K1 | cut -b 3-4`"
echo -n "   05="
echo -n "`echo $HR5K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR5K1 | cut -b 3-4`"
echo -n "   06="
echo -n "`echo $HR6K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR6K1 | cut -b 3-4`"
echo " "
#
echo -n "   07="
echo -n "`echo $HR7K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR7K1 | cut -b 3-4`"
echo -n "   08="
echo -n "`echo $HR8K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR8K1 | cut -b 3-4`"
echo -n "   09="
echo -n "`echo $HR9K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR9K1 | cut -b 3-4`"
echo -n "   10="
echo -n "`echo $HR10K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR10K1 | cut -b 3-4`"
echo -n "   11="
echo -n "`echo $HR11K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR11K1 | cut -b 3-4`"
echo -n "   12="
echo -n "`echo $HR12K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR12K1 | cut -b 3-4`"
echo " "
#
echo -n "   13="
echo -n "`echo $HR13K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR13K1 | cut -b 3-4`"
echo -n "   14="
echo -n "`echo $HR14K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR14K1 | cut -b 3-4`"
echo -n "   15="
echo -n "`echo $HR15K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR15K1 | cut -b 3-4`"
echo -n "   16="
echo -n "`echo $HR16K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR16K1 | cut -b 3-4`"
echo -n "   17="
echo -n "`echo $HR17K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR17K1 | cut -b 3-4`"
echo -n "   18="
echo -n "`echo $HR18K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR18K1 | cut -b 3-4`"
echo " "
#
echo -n "   19="
echo -n "`echo $HR19K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR19K1 | cut -b 3-4`"
echo -n "   20="
echo -n "`echo $HR20K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR20K1 | cut -b 3-4`"
echo -n "   21="
echo -n "`echo $HR21K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR21K1 | cut -b 3-4`"
echo -n "   22="
echo -n "`echo $HR22K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR22K1 | cut -b 3-4`"
echo -n "   23="
echo -n "`echo $HR23K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR23K1 | cut -b 3-4`"
echo -n "   24="
echo -n "`echo $HR24K1 | cut -b 2`"
echo -n "."
echo -n "`echo $HR24K1 | cut -b 3-4`"
echo " "
#
#----------
# Save daily statistics on the last minute of the day into a log file
if [ $MOD -eq 1439 ];
   then
   # Test if we have already logged it today
   if [ $DAILY -eq 0 ];
      then
      # Timestamp the entry
      echo "------------------------------" >> $LOGFYLE
      echo "$DT" >> $LOGFYLE
      #
      # Save Temperate High/Low
      echo "High = $TEMPHI" >> $LOGFYLE
      echo "Low  = $TEMPLO"  >> $LOGFYLE
      #
      # Save Peak Wind Gust 
      echo "Peak Wind = $DAILYPEAK mph" >> $LOGFYLE
      #
      # Save Daily and Long Term Rain Totals
      echo -n "Daily Rainfall = " >> $LOGFYLE
      echo -n "`echo $RAIN10K | cut -b 2-3`" >> $LOGFYLE
      echo -n "." >> $LOGFYLE
      echo -n "`echo $RAIN10K | cut -b 4-5`" >> $LOGFYLE
      echo " inches" >> $LOGFYLE
      #
      echo -n "Long Term Rain = " >> $LOGFYLE
      echo -n "`echo $LONGRAIN10K | cut -b 2-3`" >> $LOGFYLE
      echo -n "." >> $LOGFYLE
      echo -n "`echo $LONGRAIN10K | cut -b 4-5`" >> $LOGFYLE
      echo " inches" >> $LOGFYLE
      #
      # Set flag that we have already logged today
      let DAILY=1
      #
   fi
fi
#
if [ $MOD -eq 0 ];
   then 
   # Reset the daily flag and daily peak wind value
   let DAILY=0
   let DAILYPEAK=0
fi
#
#
echo "-----------------------------------------------------------------"
#
#
      else
      # ...we come here if the serial string was the wrong length.
      #
      # Determine if we want to display the errored data string
      if [ $COMMTEST -eq 1 ];
         then
         echo -e '\a'
         echo "    String Length is:  $ADSLEN  (should be 54) "
         echo "    String to parse: $ADSWS1 "
         sleep 1
         echo -e '\a'
      fi
fi
#
sleep $DELAY
done
#
#=========================================
exit 0
#
# --- end ---
#


These pages are maintained by: jjn@nuge.com

Copyright © 2012 John (Jay) Nugent - WB8TKL
All Rights Reserved. All other Copyrights and
Trademarks are property of their respective owners.


INFORMATION ON THIS WEB SITE IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSIONS OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU.