Unsolved Can you help to check why data upload stopped working?
-
Hello.
Please forgive me if this is the wrong category for posting this. If it is, please let me know where should I post.
My stations publishes data to 4 other services. Some of them are updated every 30 seconds. So it is working, as you can see here:WU ISOJOS39 PWS
However, Windy.com stopped accepting my uploads for some unknown reason, a few months ago (I guess).
If I get the URL generated by my station and paste directly into the browser, the update occurs so It's not API KEY.
For some reason, the code sent by my PWS is not being accepted into Windy database (it is sent every 10 minutes).
Can someone please help?
Here is the code:
char server4 [] = "stations.windy.com"; char WINDYPAGE [] = "GET /pws/update/?"; ---------------------------------------- void windy(void) { if (counter == 16) { ledON(); Serial.print("Connecting to "); Serial.println(server4); WiFiClient client; if (client.connect(server4, 80)) { Serial.print("connected to "); Serial.println(client.remoteIP()); delay(100); } else { Serial.println("connection failed"); } client.print(WINDYPAGE); client.print("&temp="); client.print(tempc); client.print("&tempf="); client.print(temp_f); client.print("&humidity="); client.print(humidity); client.print("&wind="); client.print(windSpeed * 0.44704); client.print("&winddir="); client.print(CalDirection); client.print("&windgustmph="); client.print(windgustmph * 4.47); client.print("&gust="); client.print(windgustmph * 0.44704); client.print("&dewpoint="); client.print(dewpt_c); client.print("&mbar="); client.print(baromhpa); client.print("&rainin="); client.print(rain / 25.4); client.print("/ HTTP/1.1\r\nHost: stations.windy.com:80\r\nConnection: close\r\n\r\n"); Serial.println(" "); delay(1000);
-
I am seriously thinking in abandoning Windy.com because of this silly error. I can't find where is the problem. Can someone please shed some light here?
I tested the URL generation from the Serial console and it generates the full line like this:
GET /pws/update/MYKEYHERE?station=0&temp=14.08&tempf=57.34&humidity=86.82&wind=0.00&winddir=267&windgustmph=0.00&gust=0.00&dewpoint=11.93&mbar=1025.85&precip=0.00/ HTTP/1.1
-
@Korina I know you're very busy but if you could spare a bit of your time, I'd appreciate. Thanks.
-
@jf_moreira I'm guessing your're using something like WifiClient from arduino libraries. If so, what is the data you get back after sending the request? According to this example you could to something like this after the last delay() call:
// if there are incoming bytes available // from the server, read them and print them: while (client.available()) { char c = client.read(); Serial.write(c); }
That way you should be able to check the response from the server that might give you some hint
-
@Filip_K Thanks for pointing this. Yes, I am using ESP8266 on NodeMCU. I will have to remove the PWS from up high and connect via cable so I can read the console, though. Will do and report.
-
@Filip_K This is the message I received. If I get the assembled line and paste in my browser, the database gets updated.
Via my PWS, it won't.10:37:42.934 -> HTTP/1.1 308 unknown 10:37:42.934 -> Cache-Control: private 10:37:42.934 -> Location: https://stations.windy.com:443/pws/update/MYKEY?&temp=16.59&tempf=61.86&humidity=87.53&wind=0.00&winddir=241&windgustmph=0.00&gust=0.00&dewpoint=14.53&mbar=1029.24&rainin=0.00/ 10:37:42.934 -> Content-Length: 0 10:37:42.934 -> Date: Thu, 25 May 2023 13:37:44 GMT 10:37:42.934 -> Content-Type: text/html; charset=UTF-8 10:37:42.934 -> Connection: close
-
@jf_moreira Mmm...it seems an issue with the secure http, right? I'll try to change everything to 443 then...
-
@Filip_K , I still don't know what I should change from my side. I tried a couple different approaches for suggesting 443/https connections but nothing really changed. If I paste the formed URL in my browser, the DB gets updated right away.
Meanwhile, from the ESP I keep getting that "308 unknown".
Any other ideas?
I am mounting the station on its pole again...
Thanks.
-
So...I am getting this response when I try to use the standard protocol "A/ GET Parameters URL: https://stations.windy.com./pws/update/API-KEY".
10:37:42.934 -> HTTP/1.1 308 unknown 10:37:42.934 -> Cache-Control: private 10:37:42.934 -> Location: https://stations.windy.com:443/pws/update/MYKEY?&temp=16.59&tempf=61.86&humidity=87.53&wind=0.00&winddir=241&windgustmph=0.00&gust=0.00&dewpoint=14.53&mbar=1029.24&rainin=0.00/ 10:37:42.934 -> Content-Length: 0 10:37:42.934 -> Date: Thu, 25 May 2023 13:37:44 GMT 10:37:42.934 -> Content-Type: text/html; charset=UTF-8 10:37:42.934 -> Connection: close
Please, help me understand what type of correction to my code is needed? Any changes in connection method?
I did not find anything in the forums.All my other services are receiving the data fine, something must have changed on Windy side that I am not aware of.
Please help!
-
This post is deleted! -
@jf_moreira You are getting redirection (HTTP code 308) to https. I believe WifiClient can does not support HTTPS. Try using WifiClientSecure and port 443
-
@Filip_K So everybody is sending data through secure connections then? It's weird because the API manual does not mention anything about.
i will try to interpret this and make the change as soon as I get the time.
Thanks, Filip.
-
@Filip_K Hello, Filip.
I have to do so many modifications in my code, just to make one of data clients to accept my data that is is simply not worth it. All other providers are accepting my data (Weather Underground, PWS weather, Thingspeak, Weathercloud.net).From what I understood from the logic of this conversation, everyone must be using HTTPS, right? If someone could contribute with his code snippet for this connection, I'd appreciate. Otherwise I will stay without reporting any data to Windy.com.
Thanks for your help, Filip.
-
#include WiFiClientSecure.h
WiFiClientSecure wifiClient;
////////////////////////////////////////////////////////void windy(void)
{
if ( counter == 16)
{
Serial.print("Connecting to ");
Serial.println(server4);
WiFiClientSecure wifiClient;
if (wifiClient.connect(server4, 443)) {
Serial.print("connected to ");
Serial.println(wifiClient.remoteIP());
delay(100);
} else {
Serial.println("connection failed");
}
wifiClient.print(WINDYPAGE);
wifiClient.print("station=");
wifiClient.print("0");
wifiClient.print("temp=");
wifiClient.print(tempc);
wifiClient.print("&tempf=");
wifiClient.print(temp_f);
wifiClient.print("&humidity=");
wifiClient.print(humidity);
wifiClient.print("&wind=");
wifiClient.print(windSpeed * 0.44704);
wifiClient.print("&winddir=");
wifiClient.print(winddir);
wifiClient.print("&windgustmph=");
wifiClient.print(windgustmph * 4.47);
wifiClient.print("&gust=");
wifiClient.print(windgustmph * 0.44704);
wifiClient.print("&dewpoint=");
wifiClient.print(dewpt_c);
wifiClient.print("&mbar=");
wifiClient.print(baromhpa);
wifiClient.print("&precip=");
wifiClient.print(rain);
wifiClient.print("/ HTTP/1.1\r\nHost: stations.windy.com:443\r\nConnection: close\r\n\r\n");
wifiClient.println(" ");
delay(1000);
}
} -
@hardas999 Hey, Rimvydas! Nice to see you here and thank you so much for the code snippet, my station ( https://www.windy.com/station/pws-f052cfed?-25.516,-49.195,8 ) is already publishing again on Windy.
It's weird that in the API webpage for Windy there is not a single mention to Wifi Secure or HTTPS. I revised the official link for the API many times. Also, I could not find in the forum or in the API page any hints or marks of WHEN it transitioned to HTTPS, because it surely work in http before.
Changes to the code were so few, I'm ashamed. :)
Thanks again, Rimvydas.
Cheers. -
@jf_moreira I'm glad that I can help you.