Go Down

Topic: GET format for Weather Underground (Read 327 times) previous topic - next topic

volare080

Is anyone out there successfully sending weather data to weather underground with the WiFi101 library?  I've been trying unsuccessfully to send a GET request with that library and using the Adafruit ATWINC1500 breakout.  The only good information I've been able to find on Weather underground GET requests has been in this thread:  https://forum.arduino.cc/index.php?topic=461649.0

I've tried every combination and permutation of every suggestion in the thread and the best I've been able to do (using the WiFiWebClient example sketch) is to get a "Bad Request" return:
   HTTP/1.1 400 Bad Request
   Server: nginx
   Date: Wed, 17 Apr 2019 04:33:36 GMT
   Content-Type: text/html
   Content-Length: 166
   Connection: close

The relevant code is here (with my weatherstation ID and password removed):
Code: [Select]
if (client.connect("http://weatherstation.wunderground.com", 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.print("GET /weatherstation/updateweatherstation.php?ID=XXXXX&PASSWORD=XXXXX&dateutc=now&tempf=48&action=updateraw/ HTTP/1.1/r/n");
    client.print("Host: http://weatherstation.wunderground.com:80/r/n");
    client.print("Connection: close/r/n");
    client.println();
  }


Based on the discussion in the earlier thread, and given that Weather Underground recently changed something with their servers, I'm thinking that their get format may have changed.  I did put the link into firefox and it processes the GET request just fine somehow and I get "success" returned.

Thank-you

PaulS

Code: [Select]
if (client.connect("http://weatherstation.wunderground.com", 80)) {
You connect to a server. The server name is NOT http://anything.

The server name is weatherstation.wunderground.com.

Code: [Select]
    client.print("GET /weatherstation/updateweatherstation.php?ID=XXXXX&PASSWORD=XXXXX&dateutc=now&tempf=48&action=updateraw/ HTTP/1.1/r/n");

The carriage return and line feed characters are \r and \n.
The art of getting good answers lies in asking good questions.

volare080

Code: [Select]
if (client.connect("http://weatherstation.wunderground.com", 80)) {
You connect to a server. The server name is NOT http://anything.

The server name is weatherstation.wunderground.com.

Code: [Select]
   client.print("GET /weatherstation/updateweatherstation.php?ID=XXXXX&PASSWORD=XXXXX&dateutc=now&tempf=48&action=updateraw/ HTTP/1.1/r/n");

The carriage return and line feed characters are \r and \n.
Thank-you!  I took out the "http:\\" from both the client.connect line and the host line as well, fixed the carriage return line feed characters.  Final code returns as successful and looks like this:

Code: [Select]
if (client.connect("weatherstation.wunderground.com", 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.print("GET /weatherstation/updateweatherstation.php?ID=XXXXX&PASSWORD=XXXXX&dateutc=now&tempf=71&action=updateraw/ HTTP/1.1\r\n");
    client.print("Host: weatherstation.wunderground.com\r\n");
    client.print("Connection: close\r\n");
    client.println();
  }


Now on to getting everything else with the project working!  Thanks again for your help.

Go Up