git-hanjo / fowsr

Automatically exported from code.google.com/p/fowsr
0 stars 0 forks source link

Seems like the Barometer values are off when posting to Wunderground with the included script. #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use Wunderground script
2. Look at station data and was seeing instead of 29inch of Barometric 
pressure, it was in the 50's.
3.

What is the expected output? What do you see instead?
It should have been in the 29.x range but was 50.x.

What version of the product are you using? On what operating system?
#define VERSION "V2.0.130910"

Linux.

Please provide any additional information below.

As a side note, I went ahead and used the fowsr with 'console' switch and I'm 
parsing this with a bash script to do my uploads. I don't know if you want to 
share this as a wiki attachment for someone else that wants to leverage 
wunderground and potentially manually parse the station data. But thanks for 
including the '-c' option as it works perfectly for me as I can do the math in 
a script to convert to US values for Wunderground.

Just a thought.

-Jeremy

#=============================================================================
#!/bin/bash
# Version 1.0     9-26-2013   Jeremy Georges

# This script requires fowsr and executes it with the -c (console) option.
# By using that output, we convert all of the units to the appropriate type
# that wunderground requires.
# The idea is, we don't care about locally storing the data (such as typically 
done with a Database)
# but we want to upload this every 60 seconds and this gets archived at 
wunderground.
#
#The idea was to run this on a small beaglebone or Raspberry Pi; so keep it 
simple and don't store anything locally..

# Thanks to Arne-Jørgen Auberg & Josch for keeping fowsr open and putting in 
the -c option :-)
# using normal updates (i.e. not rapid fire).
#
#Also note that we're using the system time instead of the weather station. I'm 
assuming that we're running NTP
# on the linux box and that should be our reference;

while [ 1 ]
do

ROOTDIR=/home/fowsr
# Grab raw current output
RAWLOG=/home/fowsr/rawoutput.log
/usr/local/bin/fowsr -c > $RAWLOG

#We should see 'success' in this file if everything uploads to wunderground ok.
STATUSFILE=/home/fowsr/wgetfile.log

# Need to parse this data and create variables for uploading to wunderground
# ********
# Either Change the ID and Password for your use case below....
# or supply them on the command line when executing the script so they are 
taken as arguments.
ID=$1
PASSWORD=$2

THETIME=`date -u +"%Y-%m-%d+%T" | sed 's/:/%3a/g'` 
WINDDIR=`cat $RAWLOG | grep DIR | cut -d' ' -f2`
WINDSPEED=`cat $RAWLOG | grep WS | cut -d' ' -f2`
WINDGUST=`cat $RAWLOG | grep WG | cut -d' ' -f2`
TEMPERATURE=$(cat $RAWLOG | grep To | cut -d' ' -f2)    #in Celcius
OUTHUMIDITY=`cat $RAWLOG | grep RHo | cut -d' ' -f2`
PRESSURE=`cat $RAWLOG | grep AP | cut -d' ' -f2`   #In hPa
RAINTOTAL=`cat $RAWLOG | grep Rtot | cut -d' ' -f2`    #in millimeters

EPOCHTIME=`date +%s`

#Convert from C to fahrenheit 
TEMPF=`echo "$TEMPERATURE * 1.8 + 32" | bc`

#Convert RAINTOTAL to inches
RAININCHES=`echo "$RAINTOTAL * 0.039370" | bc` 

#Convert barometer from hPa to inches
BAROINCHES=`echo "$PRESSURE * 0.0295" | bc`

# Calculate dewpoint
# Td = T - ((100 - RH)/5.)   Td is dewpoint
DEWPOINT=`echo "$TEMPERATURE - (100 - $OUTHUMIDITY)/5" | bc`

#Convert dewpoint to Fahrenheit
DEWPOINTF=`echo "$DEWPOINT * 1.8 + 32" | bc`

#Convert windspeed from m/s to MPH
#2.237 * m/s = mph
WINDSPEEDM=`echo "$WINDSPEED * 2.237" | bc`

#Convert Windgust from m/s to MPH
WINDGUSTM=`echo "$WINDGUST * 2.237" | bc`

#RAIN LOGIC. Wunground wants hourly rainfall, not total which is provided from 
the weather station.
# We need to save the total at an hourly period, save epoch time (in seconds) 
and then calculate delta for the hourly rollup.
# by subtracting current rainfall total from the snapshot value we had.
# We'll use Epoch time as this is easier to calculate figuring 3600 seconds per 
hour.
#Then at the next hour or (3600 seconds), we replace time stamp in file and 
take another total rainfall snapshot to base our delta.
if [ -f $ROOTDIR/RAINLOG.LOG ]
   then
    echo "We got a snapshot"
    #Compare
    #Use command substition to grab values in RAINLOG.LOG file.
    SNAPSHOTTIME=`cat $ROOTDIR/RAINLOG.LOG | grep ET | cut -d'=' -f2`
    RAINSNAPSHOT=`cat $ROOTDIR/RAINLOG.LOG | grep RAIN | cut -d'=' -f2`
    RAINDELTA=`echo "$RAININCHES - $RAINSNAPSHOT" | bc`
    echo "Rain delta is: $RAINDELTA"
    TIMEDELTA=`echo "$EPOCHTIME - $SNAPSHOTTIME" | bc`
        if [ "$TIMEDELTA" -gt 3600 ]
        then
          echo "We hit the hour mark"
          #Lets reset our values in RAINLOG.LOG
          #This is just like taking an initial snapshot.
          rm $ROOTDIR/RAINLOG.LOG
          echo "ET=$EPOCHTIME" > $ROOTDIR/RAINLOG.LOG
          echo "RAIN=$RAININCHES" >> $ROOTDIR/RAINLOG.LOG
          #Set rain delta for Wunder to zero since we're taking the initial snapshot
          RAINDELTA=0
        fi
   else
    #create initial snapshot since file does not exist
    echo "ET=$EPOCHTIME" > $ROOTDIR/RAINLOG.LOG
    echo "RAIN=$RAININCHES" >> $ROOTDIR/RAINLOG.LOG
    #Set rain delta for Wunder to zero since we're taking the initial snapshot
    RAINDELTA=0 
fi

wget -O$STATUSFILE 
"http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?
ID=$ID&PASSWORD=$PASSWORD&dateutc=$THETIME&winddir=$WINDDIR&windspeedmph=$WINDSP
EEDM&windgustmph=$WINDGUSTM&tempf=$TEMPF&rainin=$RAINDELTA&baromin=$BAROINCHES&d
ewptf=$DEWPOINTF&humidity=$OUTHUMIDITY&weather=&clouds=&softwaretype=vws%20versi
onxx&action=updateraw"

#echo 
"http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?
ID=$ID&PASSWORD=$PASSWORD&dateutc=$THETIME&winddir=$WINDDIR&windspeedmph=$WINDSP
EEDM&windgustmph=$WINDGUSTM&tempf=$TEMPF&rainin=$RAINDELTA&baromin=$BAROINCHES&d
ewptf=$DEWPOINTF&humidity=$OUTHUMIDITY&weather=&clouds=&softwaretype=vws%20versi
onxx&action=updateraw"

echo "Sleeping for 60seconds"
sleep 60
done

Original issue reported on code.google.com by jrmg...@gmail.com on 24 Sep 2013 at 7:59

GoogleCodeExporter commented 9 years ago
Just to clarify on #2. I'm looking at the station data on Wunderground and that 
showed the barometer at 50.x instead of 29.x.

When looking at the log file (where you're doing the wget of the log data) the 
barometer values are off.
This is for a ws-2080 Ambient weather console.

-J

Original comment by jrmg...@gmail.com on 24 Sep 2013 at 8:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
There was an error calculating the pressure offset for relative pressure. This 
has been fixed in version 2.0.131015. If you call fowsr with verbose level >=2 
(-v2c), the determined pressure offset (depends on your station settings) is 
printed out. Please let me know, if it now works with your wunderground 
account. With mine it does.

Original comment by Josch600 on 17 Oct 2013 at 9:51