I’m having problems with a Hanrun W5500 running with ethernet3 library (both ethernet and ethernet2 gave the same problem). This module is driven by a Mega 2560 R3 and uploads data to Wunderground.com (weather data site) every impair minute at 55 seconds. The problem makes the Arduino freezing only and only if I heavily use internet with my desktop hardwired to the router or wifi portable in downloading a huge file. Listening youtube video HD is also freezing the w5500 and the Arduino. If I don’t use internet at all with my PC’s, the system works perfectly for days. So I imagine slow internet and unexpected delays impact the W5500. I imagine library may not be able to handle such delays but I may be wrong.
Right now it looks like it's freezing in checking if connected, just before sending data. Is this a known problem with internet module ? Should these delays be managed by the sketch ? How do we do that ?
As my sketch is over 1100 lines, as problem is closely related to ethernet communications, I trimmed the sketch in removing all non related data. I finally had to include just a little part as the ethernet related lines were over 9000 characters.
I’m not an expert coder so forgive my possible stupid code ... Enhancements are welcomed !
void sendWundgData() {
if (!client.connect(SERVER, 80)) {
if (debug) Serial.println(F("Connection failed"));
initEther();
}
else { // client is connected
if (debug) Serial.println(F("client connected - start sending data -> "));
client.print(WEBPAGE);
client.print(F("ID=xxxxx"));
client.print(F("&PASSWORD=xxxx"));
client.print(F("&dateutc=now"));
// I removed many lines
client.print(F("&softwaretype=Arduino%20MEGA&action=updateraw&realtime=1&rtfreq=120")); //Using Rapid Fire, sending data 1time every 120sec
client.println(F("/ HTTP/1.1\r\nHost: host:port\r\nConnection: close\r\n\r\n"));
client.print("\r\n\r\n\r\n");
client.println();
client.println();
client.println();
w5500DataToRead = true ;
if (debug) Serial.println(F("data sent"));
else {
if (debug) Serial.println(F("no server connection no data sent"));
}
}
}