Avoid waiting server response with Wunderground (arduino)


To start, I’m not an expert, just learning while doing a wunderground weather station.

I had no problem setting up my W5500 as we can find plenty of examples on the web. While tuning my sketch, I found that sending data to Weather Underground takes around 250ms which is good. Receiving the “success” answer from the Wunderground server takes at least 800ms and sometimes up to 3000 ms … With my current sketch, arduino is idle and I cannot read my weather sensors.

I’m wondering if I could use the W5500 buffer to wait by itself for server answer and continue doing regular tasks with the arduino. 3 sec. after sending data, I Imagine I could check if “success” answer came and then close client. By the way, I do not use the “success” answer, w5500 is solid enough, but to accept data, Wunderground server has to send this answer.

As I’m not using answer, there may be another easier way to do it …

To start, I send data to wunderground with a “get”.
(client.print(WEBPAGE); // (“GET /weatherstation/updateweatherstation.php?”)

As sending my data is OK, I provide you with the complete code used to wait the server answer.

 unsigned long lastRead = millis();
 while (client.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) 
    {while (client.available()) 
        { char c = client.read();
          lastRead = millis();

Thanks in advance

J Guy

You assume that we know your environment, and what Wunderground is. Please make explanation simple - there’re two devices, and one does something in the direction of the other. One of them is W5500.

W5500 is socket implementation (if you do not use it in RAW mode) thus whatever data it will receive in background this data will remain in its buffer until controlling unit tells W5500 that data is not needed anymore (except cases when data buffer overflows, then latest data is lost).

Thus, if you know timing of your data exchange, you should not be in idle state waiting for data to come, as you say Arduino can do whatever it needs and regularly check for incoming data, and as soon as data arrives, process it properly.

Sorry for that …

Weather Wunderground is a server service that stores weather station data (humidity, temp, wind speed, wind dir, etc…) that can be uploaded every XX sec/min. Many people use the arduino and W5500 to do that.

sending data to Weather Underground takes around 250ms

Receiving the “success” answer from the Wunderground server takes at least 800ms and sometimes up to 3000 ms

Part of the problem is that I don’t know when Wunderground server will send it’s answer.

Meanwhile, I think I may have found how to do it and it’s the solution you proposed at the end of your message. I was missing some basic knowledge, To be clear for less knowledgeable people like me : " client.connected" will return true until rx buffer was emptied from the final packet. “client.available” returns true if there’s data in the rx buffer.

I should be OK with that.

Thanks J Guy

P. S. no need to be angry. You finally understood the problem and gave the solution. Being angry shortens the life !