Author Topic: PI gateway also sending data to wunderground.com  (Read 4965 times)

LukaQ

  • Sr. Member
  • ****
  • Posts: 283
  • Country: si
Re: PI gateway also sending data to wunderground.com
« Reply #15 on: October 17, 2017, 01:22:19 PM »
is the NAME_YOUR_FILE the same file name and extension as SOMENAME.sh or different?
Indeed it is, I wasn't that consistent when now showing what my file is named.

Kilo95

  • Sr. Member
  • ****
  • Posts: 327
  • Country: us
Re: PI gateway also sending data to wunderground.com
« Reply #16 on: October 17, 2017, 01:41:43 PM »
that what i thought you intended to do (keep the same gateway). ive been working on this on my smartphone. i'll wait a few days til i can look at it on my computer and will update then

Kilo95

  • Sr. Member
  • ****
  • Posts: 327
  • Country: us
Re: PI gateway also sending data to wunderground.com
« Reply #17 on: October 26, 2017, 11:24:25 AM »
Luka, just wanted to post what finally worked for me that you helped me work out off forum.

1. Made sure the permissions for the "WHATEVERNAME.sh" was set to 744 or 777.
2. Removed the conversions to metric
3. Changed the C in the script for the temperature to F (otherwise kept giving a syntax error)
4. Changed the print function from 2,3,4 ({print $2}, {print $3}, etc) to 3,4,5 ({print $3}, {print $4}, etc) since my output from the node shows the battery voltage in the #2 slot {print 2}
5. Set var [5] and removed the reference to var [40] since all 3 of my metrics comes from one node (#5).
6. One node i have outputs temp as 4 digits (ex 5895 but on the gateway page shows up as 58.95 deg) so i divided the temp by 100. that's on a Weathershield R1. on my WS R2, it comes out as 58.95 without the correction

many thanks to Luka for his advice and help. all the credit goes to him

Code: [Select]
#!/bin/bash
while :
do
var="$(less -FX /home/pi/gateway/NAME_YOUR_FILE | awk  '{print $1}' )"
echo $var
if [ "$var" == "[5]" ]
temp1="$(less -FX /home/pi/gateway/NAME_YOUR_FILE | awk  '{print $3}' | sed -e 's/F://')"
temp=$(echo $temp1/100 | bc)
humidity1="$(less -FX /home/pi/gateway/NAME_YOUR_FILE | awk  '{print $4}' | sed -e 's/H://')"
pressure1="$(less -FX /home/pi/gateway/NAME_YOUR_FILE | awk  '{print $5}' | sed -e 's/P://')"
humidity=$(echo $humidity)
baro=$(echo $pressure1)
fi
###########################################################################################################################################################################################################################################
echo $temp
echo $humidity
echo $baro
curl "https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=YOURSTATIONNAME&PASSWORD=YOURSTATIONKEY&dateutc=now&tempf=${temp%$cr}&baromin=${baro%$cr}&humidity=${humidity%$cr}&weather=&clouds=&softwaretype=Arduino-ESP8266&action=updateraw"
sleep 10
done
« Last Edit: October 26, 2017, 01:02:54 PM by Kilo95 »