Has anyone developed a CR1000 program to upload weather data to wunderground.com?
Do you know what their requirements are for submitting the data?
Has anyone developed a CR1000 program to upload weather data to wunderground.com?
Do you know what their requirements are for submitting the data?
Sorry, should have included that with the original question.
I know how to build the output string with the CR1000 just hot sure how to send it. I have NL115 and connected to the Internet.
Web Page with all the info:
http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
To upload a weather condition, you make a standard HTTP GET request with the ID, PASSWORD and weather conditions as GET parameters
Definitions:
action [action=updateraw]
ID [ID as registered by wunderground.com]
PASSWORD [PASSWORD registered with this ID]
dateutc - [YYYY-MM-DD HH:MM:SS (mysql format)]
winddir - [0-360]
windspeedmph - [mph]
windgustmph - [windgustmph ]
humidity - [%]
tempf - [temperature F]
rainin - [rain in]
dailyrainin - [daily rain in accumulated]
baromin - [barom in]
dewptf- [dewpoint F]
weather - [text] -- metar style (+RA)
clouds - [text] -- SKC, FEW, SCT, BKN, OVC
softwaretype - [text] ie: vws or weatherdisplay
Example String:
http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=KCASANFR5&PASSWORD=XXXXXX&dateutc=2000-01-01+10%3A32%3A35&winddir=230&windspeedmph=12&windgustmph=12&tempf=70&rainin=0&baromin=29.1&dewptf=68.2&humidity=90&weather=&clouds=&softwaretype=vws%20versionxx&action=updateraw
Their requirements can be found here
http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
I'll be posting a CRBasic example soon.
As promised, here's an example program (below). Unfortunately we can't add an attachment to a post yet. It's going to look pretty ugly in this post and leading white space will be stripped. Highlight the text of the program and copy it into your CRBasic Editor, rebuild indention (Edit menu - Rebuild Indention), and it will look much better.
Obviously some things will need to be adjusted in your own program. You'll have to supply your ID and password in the GET request. The size of the PWSGetRequest variable will probably have to be increased. If you want something other than 10 minute updates you'll need to change the scan interval in the slow sequence scan. And so on.
'CR1000 Series Datalogger
'Program example of publishing real-time data (public variables) to Weather Underground
'Note that the GET request parameter DateUTC is expected to be Coordinated Universal Time (UTC)
'so the datalogger clock should be set to Coordinated Universal Time.
'Declare Public Variables
Public PTemp_C
Public ATemp_F
Public PWSGetRequest As String * 200
Public PWSGetResponse As String * 200
Public Socket
Public RTime(9)
Alias RTime(1)=Year
Alias RTime(2)=Month
Alias RTime(3)=DayOfMonth
Alias RTime(4)=HourOfDay
Alias RTime(5)=Minutes
Alias RTime(6)=Seconds
Alias RTime(7)=Microseconds
Alias RTime(8)=DayOfWeak
Alias RTime(9)=DayOfYear
'Main Program
BeginProg
Scan(1,Sec,0,0)
'Wiring Panel Temperature measurement PTemp_C
PanelTemp(PTemp_C,_60Hz)
'Type T (copper-constantan) Thermocouple measurements ATemp_F
TCDiff(ATemp_F,1,mV2_5C,1,TypeT,PTemp_C,True,0,_60Hz,1.8,32)
NextScan
SlowSequence
Scan(10,Min,0,0)
'Track current time
RealTime(RTime())
'Refer to http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol for PWS upload protocol documentation
PWSGetRequest="GET /weatherstation/updateweatherstation.php?ID=YourID&PASSWORD=YourPassword&dateutc="+Year+"-"+Month+"-"+DayOfMonth+"+"+HourOfDay+":"+Minutes+":"+Seconds+"&tempf="+FormatFloat(ATemp_F,"%5.2f")+"&action=updateraw HTTP/1.1"+CHR(13)+CHR(10)
Socket=TCPOpen("weatherstation.wunderground.com",80,1024)
If Socket<>0 Then
'Transmit GET request
SerialOut(Socket,PWSGetRequest,"",0,0)
'Based on tests a legitimate User-Agent request-header field is required
SerialOut(Socket,"User-Agent: Mozilla/4.0"+CHR(13)+CHR(10),"",0,0)
'Based on tests a Host request-header field is not required
SerialOut(Socket,"Host: weatherstation.wunderground.com"+CHR(13)+CHR(10),"",0,0)
'Based on tests a final blank line (carriage return and line feed) is required
SerialOut(Socket,CHR(13)+CHR(10),"",0,0)
'Capture the GET request response for debugging purposes
SerialIn(PWSGetResponse,Socket,500,"",200)
EndIf
NextScan
EndProg
* Last updated by: ChipsNSalsa on 9/26/2008 @ 5:13 PM *
ChipsNSalsa,
Thanks for the help.
I'll post a message back here when it's up and running.
Thanks,
Dave
Glen,
Finally found some time to get that Wunderground upload running.
http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KNYKINGS9
Thanks again for the help.
Regards,
Dave
Modified Program a bit to Calculate UTC so logger can remain on local time.
'CR1000 Series Datalogger
'Program example of publishing real-time data (public variables) to Weather Underground
'Note that the GET request parameter DateUTC is expected to be Coordinated Universal Time (UTC)
'Program Calculates UTC so logger clock can remain on Local Time and still provide UTC for WunderGround
'Declare Public Variables
Public PTemp_C
Public ATemp_F
Public PWSGetRequest As String * 200
Public PWSGetResponse As String * 200
Public Socket
'UTC TIme Variables
Dim TimeLong As Long
Public UTCTime As String * 30
Const UTC_OFFSET = -5*3600 '- 5 Hours GMT (Adjust for your time zone)
Public Year$ As String * 4
Public Month$ As String * 2
Public DayOfMonth$ As String * 2
Public hhmmss$ As String * 8
DataTable(TimeTable,true,1)
TableHide
Sample(1,TimeLong,NSEC)
EndTable
'Main Program
BeginProg
Scan(1,Sec,0,0)
'Wiring Panel Temperature measurement PTemp_C
PanelTemp(PTemp_C,_60Hz)
'Type T (copper-constantan) Thermocouple measurements ATemp_F
TCDiff(ATemp_F,1,mV2_5C,1,TypeT,PTemp_C,True,0,_60Hz,1.8,32)
NextScan
SlowSequence
Scan(10,Min,0,0)
'Calculate UCT Time for Wunderground Output
TimeLong = Public.TimeStamp(1,1) - UTC_OFFSET
CallTable(TimeTable)
UTCTime(1) = TimeTable.TimeLong(1,4) 'mm/dd/yyyy hr:mm:ss
Month$ = Left(UTCTime(1),2)
DayOfMonth$ = Mid (UTCTime(1),4,2)
Year$ = Mid (UTCTime(1),7,4)
hhmmss$ = Mid (UTCTime(1),12,8)
'Refer to http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol for PWS upload protocol documentation
PWSGetRequest="GET /weatherstation/updateweatherstation.php?ID=YourID&PASSWORD=YourPassword&dateutc="+Year$+"-"+Month$+"-"+DayOfMonth$+"+"+hhmmss$+"&tempf="+FormatFloat(ATemp_F,"%5.2f")+"&action=updateraw HTTP/1.1"+CHR(13)+CHR(10)
Socket=TCPOpen("weatherstation.wunderground.com",80,1024)
If Socket<>0 Then
'Transmit GET request
SerialOut(Socket,PWSGetRequest,"",0,0)
'Based on tests a legitimate User-Agent request-header field is required
SerialOut(Socket,"User-Agent: Mozilla/4.0"+CHR(13)+CHR(10),"",0,0)
'Based on tests a Host request-header field is not required
SerialOut(Socket,"Host: weatherstation.wunderground.com"+CHR(13)+CHR(10),"",0,0)
'Based on tests a final blank line (carriage return and line feed) is required
SerialOut(Socket,CHR(13)+CHR(10),"",0,0)
'Capture the GET request response for debugging purposes
SerialIn(PWSGetResponse,Socket,500,"",200)
EndIf
NextScan
EndProg
* Last updated by: IslandMan on 11/13/2008 @ 3:40 AM *
新对话如下:Interesting info. I am trying to figure out how to do this same thing except over a cellular link. If I follow it, this program is uploading the wx station info every 10 minutes. It looks like it is what we are looking for. My confusion surrounds the network issues of static vs dynamic IP addresses from verizon for the cellular link. The station was up and running with a static IP, providing wx info on demand as it was polled directly by users. All good, then the account registration changed and now to get it back running, Verizon wants another $500 for a new static IP, so we plan to go dynamic and use Wunderground instead of direct polling. I am not 'pro', so asking the dumb question, this set up you have created looks like it would do just fine as long as we get the CR1000 back on the cellular link with no need of the static IP?? Sorry, that was a question! ;-) Hope this is understandable. Thanks.
新对话如下:It is easier now with the newer logger operating systems:
Const WUNDERGROUND_ID = "YOUR_STATION_ID"
Const WUNDERGROUND_PASSWORD = "YOUR_LOGON_PASSWORD"
Dim http_get_header As String * 100
Public http_get_response As String * 300
Dim http_get_uri As String * 300
Public time(9)
Alias time(1) = year 'assign the alias Year to Time(1)
Alias time(2) = month 'assign the alias Month to Time(2)
Alias time(3) = day_of_month 'assign the alias day_of_month to Time(3)
Alias time(4) = hour 'assign the alias Hour to Time(4)
Alias time(5) = minute 'assign the alias Minute to Time(5)
Alias time(6) = second 'assign the alias Second to Time(6)
Alias time(7) = usecond 'assign the alias uSecond to Time(7)
Alias time(8) = week_day 'assign the alias week_day to Time(8)
Alias time(9) = day_of_year 'assign the alias Day_of_Year to Time(9)
Scan(10, Min, 3, 0)
RealTime(time())
'HTTPGet information to wunderground.com
http_get_header = ""
http_get_response = ""
http_get_uri = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?"
http_get_uri = http_get_uri & "ID=" & WUNDERGROUND_ID & "&PASSWORD=" & WUNDERGROUND_PASSWORD
http_get_uri = http_get_uri & "&dateutc=" & year & "-" & month & "-" & day_of_month
http_get_uri = http_get_uri & " " & hour & ":" & minute & ":" & second
http_get_uri = http_get_uri & "&winddir=" & wind_direction
http_get_uri = http_get_uri & "&windspeedmph=" & wind_speed_mph
http_get_uri = http_get_uri & "&tempf=" & air_temperature_f
http_get_uri = http_get_uri & "&dewptf=" & dew_point
http_get_uri = http_get_uri & "&humidity=" & relative_humidity
http_get_uri = http_get_uri & "&solarradiation=" & slrw
http_get_uri = http_get_uri & "&baromin=" & pressure_inches
http_get_uri = http_get_uri & "&softwaretype=CRBasic-AG1T"
http_get_uri = http_get_uri & "&version=" & version
http_get_socket = HTTPGet(http_get_uri, http_get_response, http_get_header)
TCPClose(http_get_socket)
NextScan
* Last updated by: GaryTRoberts on 3/8/2013 @ 1:48 PM *
新对话如下:The same thing we really want to implement in our station, but currently our station is programmed to send consolidated hourly data on a daily basis in our ftp server.
Is it possible to to upload data of our station on wunderground at the same time the sending of data to our ftp server?
新对话如下:Yes. You would have a routine/code for sending data via FTP and then code for sending data to Weather Underground.
新对话如下:Sam,
How the routine/code will go? Will i just insert the sample code for the wundergound upload after the code for ftp sending?
新对话如下:ATTENTION:
As of late August 2013 Weather Underground required more stringent url escaping and the older code string output is no longer accepted.
See http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol for more details.
Please note that the UTCTime format is very specific and your code must match the code below in order to format the time stamp properly.
Additionally, the requirement is specific on how the data is formatted. Notice in the code that all the FormatFloat strings are set to "%0.2" which basically takes the outputted values and “rubber bands” them, so that as the variable value length changes, this string value will “stretch” and “contract” without using padding and leading zeros.
I also am not positive if it makes a difference, but the DNS name is changed to IP values, and the URL user agent spoof has increased from 4.0 to 5.0.
Here is some partial new code that should work:
SlowSequence
Scan(1,min,0,0)
'Track current time
'Calculate UTC Time for Wunderground Output
TimeLong = Public.TimeStamp(1,1) - UTC_OFFSET
CallTable(TimeTable)
UTCTime = TimeTable.TimeLong(4,4) 'yyyy/MM/dd hr:mm:ss
UTCTime$ = Replace (UTCTime," ","+"):UTCTime$$ = Replace (UTCTime$,":","%3A")
'Refer to http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol for PWS upload protocol documentation
'Change ID (yourid) and PASSWORD (yourpassword) to specific site settings
PWSGetRequest="GET /weatherstation/updateweatherstation.php?ID=yourid&PASSWORD=yourpassword&dateutc="+UTCTime$$ +"&winddir="+FormatFloat(WindDir,"%0.2f") _
+"&windspeedmph="+FormatFloat(WS_mph,"%0.2f")+"&humidity="+FormatFloat(RH,"%0.2f")+"&rainin="+FormatFloat(Rain_in,"%0.2f")+"&tempf=" _
+FormatFloat(AirTF,"%0.2f")+"&baromin="+FormatFloat(BP_inHg,"%0.2f")+"&dewptf="+FormatFloat(TdF,"%0.2f")+"&action=updateraw"+CHR(13)+CHR(10)
Socket=TCPOpen("38.102.137.157",80,1024)
If Socket<>0 Then
'Transmit GET request
SerialOut(Socket,PWSGetRequest,"",0,0)
'Based on tests a legitimate User-Agent request-header field is required
SerialOut(Socket,"User-Agent: Mozilla/5.0"+CHR(13)+CHR(10),"",0,0)
'Based on tests a Host request-header field is not required
SerialOut(Socket,"Host: 38.102.137.157"+CHR(13)+CHR(10),"",0,0)
'Based on tests a final blank line (carriage return and line feed) is required
SerialOut(Socket,CHR(13)+CHR(10),"",0,0)
'Capture the GET request response for debugging purposes
SerialIn(PWSGetResponse,Socket,500,"",200)
EndIf
NextScan
EndSequence
* Last updated by: wxdood on 10/24/2013 @ 10:33 AM *
新对话如下:This was extremely helpful but I am struggling:
'Declare Public Variables
Public PTemp_C
Public ATemp_F
Public wind_direction
Public wind_speed_mph
Public air_temperature_f
Public dew_point
Public relative_humidity
Public slrw
Public pressure_inches
Public version
Public HTTPGet (12,1,1)
Public http_get_socket
Public PWSGetRequest As String * 200
Public PWSGetResponse As String * 200
Public Socket
'UTC TIme Variables
Dim TimeLong As Long
Public UTCTime As String * 30
Const UTC_OFFSET = -5*3600 '- 5 Hours GMT (Adjust for your time zone)
Public Year$ As String * 4
Public Month$ As String * 2
Public DayOfMonth$ As String * 2
Public hhmmss$ As String * 8
Const WUNDERGROUND_ID = "KFLVEROB32"
Const WUNDERGROUND_PASSWORD = "$A4s5d6f"
Dim http_get_header As String * 100
Public http_get_response As String * 300
Dim http_get_uri As String * 300
Public time(9)
Alias time(1) = year 'assign the alias Year to Time(1)
Alias time(2) = month 'assign the alias Month to Time(2)
Alias time(3) = day_of_month 'assign the alias day_of_month to Time(3)
Alias time(4) = hour 'assign the alias Hour to Time(4)
Alias time(5) = minute 'assign the alias Minute to Time(5)
Alias time(6) = second 'assign the alias Second to Time(6)
Alias time(7) = usecond 'assign the alias uSecond to Time(7)
Alias time(8) = week_day 'assign the alias week_day to Time(8)
Alias time(9) = day_of_year 'assign the alias Day_of_Year to Time(9)
BeginProg
Scan(10, Min, 3, 0)
RealTime(time())
Socket=TCPOpen("weatherstation.wunderground.com",80,1024)
'HTTPGet information to wunderground.com
http_get_header = ""
http_get_response = ""
http_get_uri = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?"
http_get_uri = http_get_uri & "ID=" & WUNDERGROUND_ID & "&PASSWORD=" & WUNDERGROUND_PASSWORD
http_get_uri = http_get_uri & "&dateutc=" & year & "-" & month & "-" & day_of_month
http_get_uri = http_get_uri & " " & hour & ":" & minute & ":" & second
http_get_uri = http_get_uri & "&winddir=" & wind_direction
http_get_uri = http_get_uri & "&windspeedmph=" & wind_speed_mph
http_get_uri = http_get_uri & "&tempf=" & air_temperature_f
http_get_uri = http_get_uri & "&dewptf=" & dew_point
http_get_uri = http_get_uri & "&humidity=" & relative_humidity
http_get_uri = http_get_uri & "&solarradiation=" & slrw
http_get_uri = http_get_uri & "&baromin=" & pressure_inches
http_get_uri = http_get_uri & "&softwaretype=CRBasic-AG1T"
http_get_uri = http_get_uri & "&version=" & version
http_get_socket = HTTPGet(http_get_uri, http_get_response, http_get_header)
TCPClose(http_get_socket)
NextScan
EndProg
see wxwood's post above, specifically
"As of late August 2013 Weather Underground required more stringent url escaping and the older code string output is no longer accepted.
See http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol for more details.
Please note that the UTCTime format is very specific and your code must match the code below in order to format the time stamp properly."
so, try replacing
http_get_uri = http_get_uri & "&dateutc=" & year & "-" & month & "-" & day_of_month
http_get_uri = http_get_uri & " " & hour & ":" & minute & ":" & second
with
http_get_uri = http_get_uri & "&dateutc=" & year & "-" & month & "-" & day_of_month
http_get_uri = http_get_uri & "+" & hour & "%3A" & minute & "%3A" & second
Thank you, missed that, will check it.
新对话如下:Gone as far as I can. Read all the topics here and on the net. Tried all the various bits and complete code to upload the cr1000 data to Weatherunderground for a PWS.
My goals: Local Webpage (90% success)
Using RTMC Pro, build and publish an internal website
Page 1: will have current RH, BP, AirT, WindDir, Rain_Tot, Rain_in, Max Gust
Page 2: Display week history for RH, AirT, Rain, BP
Page 3: Table display of values from an hourly table
I have succeeded in Page #1,2,3 except Page 2 will not keep the history displayed when I refresh the browser.
Wunderground PWS upload from CR1000(0% Success)
Nothing I have tried works. Cannot use webserver or ftp due to IT constrains.
Obviously I need more knowledge than "cut & paste" - at this point are there any resources where I can send my rookie code for a fix? Regards all.
CR1000
05103-L35
CS215-L6
CS106
TE525-L35
RTMC Pro
LoggernetAdm
RTMC Webserver
page 2 will only show history after a refresh if you are putting the data into a datatable and using that collected tabledata as the source for your graph. the graph is going to reset if you are pointing to public table variables.
re below, you will only see updates if your values are believable. Wunderground does some QC/QA on data I think based on data from neighboring weather stations.
'Declare Public Variables
Public PTemp_C
Public ATemp_F
Public wind_direction
Public wind_speed_mph
Public air_temperature_f
Public dew_point
Public relative_humidity
Public slrw
Public pressure_inches
'Wunderground
Public http_get_socket
Public http_get_header As String * 23
Public http_get_response As String * 23
Dim http_get_uri As String * 500
'UTC TIme Variables
Dim SS1990 As Long
Public UTCTime As String * 30
Const UTC_OFFSET = -5*3600 '- 5 Hours GMT (Adjust for your time zone)
Const WUNDERGROUND_ID = "KFLVEROB32"
Const WUNDERGROUND_PASSWORD = "$A4s5d6f"
BeginProg
Scan(10, Min, 3, 0)
'create wunderground timestamp
SS1990 = Public.Timestamp(1,1)
SS1990 = SS1990 + UTC_OFFSET
UTCTime = SecsSince1990 (SS1990,4)
UTCTime = Left(UTCTime,19)
UTCTime = Replace(UTCTime," ","+")
UTCTime = Replace(UTCTime,":","%3A")
'HTTPGet information to wunderground.com
http_get_header = ""
http_get_response = ""
http_get_uri = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?action=updateraw"
http_get_uri = http_get_uri & "&ID=" & WUNDERGROUND_ID & "&PASSWORD=" & WUNDERGROUND_PASSWORD
http_get_uri = http_get_uri & "&dateutc=" & UTCTime
http_get_uri = http_get_uri & "&winddir=" & Round(wind_direction,0)
http_get_uri = http_get_uri & "&windspeedmph=" & Round(wind_speed_mph,1)
http_get_uri = http_get_uri & "&tempf=" & Round(air_temperature_f,1)
http_get_uri = http_get_uri & "&dewptf=" & Round(dew_point,1)
http_get_uri = http_get_uri & "&humidity=" & Round(relative_humidity,0)
http_get_uri = http_get_uri & "&solarradiation=" & Round(slrw,1)
http_get_uri = http_get_uri & "&baromin=" & Round(pressure_inches,1)
http_get_uri = http_get_uri & "&softwaretype=cr1000"
http_get_socket = HTTPGet(http_get_uri, http_get_response, http_get_header)
'TCPClose(http_get_socket)
NextScan
EndProg
That explains my questions, thank you!
新对话如下:Hello All,
Am not sure if any of you guys are still reading this thread. I am curious as to how you send the rain data to Weather Underground ?
I ask as at the moment it is something I am working on.
Regards.
新对话如下:There is a great blog post at https://www.campbellsci.com/blog/post-cr6-data-to-weather-underground that should get you the information you are looking for.
新对话如下:I have been trying to get our weather data posted, I followed the instructions on this post: https://www.campbellsci.com/blog/post-cr6-data-to-weather-underground
I am using a CR1000, and the value I get for result is: -2 which whe I look in the .dld file means connected but not successful, did not receive "200 OK" from server and no data appear on my PWS.
from previous posts it seems like there are problems with UTC time. Do I need to have a UTC offset configured in loggernet for the station in the Time Zone Offset in the "clock" tab in the station setup? Or do I need to change the time to UTC manually before sending to weather underground?
also, many people say to look at http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol but this doesn't seem to exist anymore, I wonder if they are no longer supporting this feature. Are people's Campbell logger to PWS still working?