Uploading data to WU from raspberry pi (newbie)

  • 1
  • Question
  • Updated 3 weeks ago
Hi All
I am very new to all this and just wanted someone to say it is or is not possible. I have a raspberry pi weather station and I am trying to upload my data to WU using python. I keep getting "401 unauthorized" errors, however my station ID and password are correct. I then read that the WU API has been retired. Is this my problem?

In WU, I can see my device status is OFFLINE. Is this normal?

Thanks in advance.
Tom
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes

Posted 2 months ago

  • 1
Photo of John Renyard

John Renyard

  • 10 Posts
  • 0 Reply Likes
I use Meteohub and another family member does too
https://wiki.meteohub.de/Buy_Software Download there.  It is very configurable for several sites
(Edited)
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
I am using a very old and possibly no longer supported c++ program called OWW that still uses the original upload API.  OWW doesn't handle errors very well so I periodically have to restart which I just had to do but it is uploading correctly right now and I am now seeing my PWS on the wunderground website as well as CWOP, MesoWest and FindU.
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
I did a google search for "wunderground upload protocol" and it looks like the first hit leads to a valid URL

https://feedback.weather.com/customer/en/portal/articles/2924682-pws-upload-protocol?b_id=17298

Looks like a 401 means your ID and PASSWORD don't match.  

Other useful links:

https://www.wunderground.com/pws/hardware-software

Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Thanks guys, however the question still remains, is what I am trying to do possible ? Thanks
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
Hi Tom, as I mentioned in my first reply the upload API is working using a C program that has not been modified in years.  I misspoke when I said OWW was written in C++, it's actually written in regular C. I use C++ at work so it must have been muscle memory when I typed that.  It should not matter if you use Python or any other prgramming language.  

I do plan to redo my PWS system probably using an old RaspPi I have lying around and will probably use Python unless I can find another package that already does most of what I want to do.  

What has changed is the download API is no longer valid.  I was able to find an update for my Logitech Media Server that just worked but my ElectricImp program stopped working and I haven't had time to fix it.

If you are getting a 401 while trying to do an upload, then either your ID is wrong or your PASSWORD is incorrect.  

Claude
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Thanks Claude, I got it to work !
My misunderstand, the password is not my login password, it is the "key" in the devices section. My bad. Thanks to ALL !
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
Great.  So, is this a COTS PWS or DIY?  What kind of sensors?
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
DIY. Pretty basic setup using sparkfun weather meter  SEN-08942 (rainfall, wind speed & direction) and adafruit BME280 (temp, pressure, humidity). Thanks again !
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Hi All, I am successfully uploading from my raspberry pi and I can see the data in my "Station Summary". The data looks 100% ok. The only annoying thing is the units of pressure. It is shown in hPa, however I would prefer mBar. I have searched, is it possible to change. It is easy to change from deg F to deg C, but cant see a pressure unit setting. Thanks alot
Photo of Detmar Berg

Detmar Berg

  • 21 Posts
  • 0 Reply Likes
I am lockink för the comopleate sckill
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
Hi Tom, I'm looking at rebuilding my weather station.  What software are you using with your Raspberry Pi?
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Hi Claude, I use python. Here is a link to what i followed to build it. Software instructions are included. 
https://projects.raspberrypi.org/en/projects/build-your-own-weather-station
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
Hi Tom,  Yes I started looking at that website last night. I have a lot of 1-wire sensors and I wasn't sure if this program would support my sensors without a lot of mods.  It looks like they make use of Initial State for a dashboard but I believe is not normally free and Oracle Cloud whereas I'd prefer to store my data locally using something like MySQL.  I have a Purple Air sensor which I believe uses a BME280 as well.  I'm also thinking of using MQTT to with one or more ESP8266 which have built-in WiFi.
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Hi Claude, I am no python expert, but i think you could use the examples on that webpage to help implement your stuff. My weather station is up and going but is 100% finished. I need to reset the rain every 24 hrs etc and calculate hourly rain fall. Here is another page which is useful. It is how i upload my info to weatherunderground. I then use a free app called "PWS monitor" to view my info.

Note: In section “Using Python to upload your data”, there is a mistake in the python. Command should be request.post, not requests.get.

https://projects.raspberrypi.org/en/projects/uploading-weather-data-to-weather-underground/4
Photo of Paul Hutch

Paul Hutch

  • 18 Posts
  • 7 Reply Likes
The official documentation says it should be a GET request, not a POST request and it works when I've tried it.
https://support.weather.com/s/article/PWS-Upload-Protocol?language=en_US
Here is how to create a Personal Weather Station update to wunderground.com:
Background
To upload a weather condition, you make a standard HTTP GET request with the ID, PASSWORD and weather conditions as GET parameters


(Edited)
Photo of Tom

Tom

  • 9 Posts
  • 4 Reply Likes
Thanks Paul, I tried the 'GET' and it works!
Photo of Paul Hutch

Paul Hutch

  • 18 Posts
  • 7 Reply Likes
I still don't fully understand why CGI GET works for uploading or why it would ever be used instead a CGI POST.

When I saw the instructions I vaguely remembered learning last century that this was a common weirdness to CGI. I then looked for a good modern explanation but never did find one. I only found confirmation that both GET and POST can be used to provide data to a CGI server.
Photo of Claude Felizardo

Claude Felizardo

  • 39 Posts
  • 9 Reply Likes
When developing a web service it is very easy to use the GET command because you can just append the data to the URI whereas a POST requires that the data be put into the body of the request which requires more code to create which is easy if you using a library.  With a GET command you can test fom a command line program like WGET or CURL.
(Edited)
Photo of Paul Hutch

Paul Hutch

  • 18 Posts
  • 7 Reply Likes
Thanks for the info Claude!
Photo of Bruce Brownlee

Bruce Brownlee

  • 4 Posts
  • 3 Reply Likes
Dont know if this it solved or not.
I posted a port I did of an old Davis Stations python app.
https://github.com/brownleeb/RPi-Station-Davis

I have since updated to use Python Requests instead of the supplied fhttplib.  
On my long list of things to do is to go through that code and clean out/update to current python libs.