Arduino stops sending data after a while?

Hi all

Im experiensing som wierd issues. My arduino wifi Rev 2 stops after a while.
Im sending temperature data to a website for monitoring, every 10minutes, but after a while it stops.

It happens on both of my arduinos, what have i done wrong?

#include <SPI.h>
#include <WiFiNINA.h>
#include <DHT.h>

#include "arduino_secrets.h"
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS; // the Wifi radio's status
String SendData,ThisMAC,ThisIP;

//SendTemp,SendHumi

//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

//Variables
//int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
char server[] = "www.www.xx";

WiFiClient client;

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
dht.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}

String fv = WiFi.firmwareVersion();
if (fv != "1.2.3") {
Serial.println("Please upgrade the firmware");
}

// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);
}

// you're connected now, so print out the data:
printWifiData();

}

void loop() {
delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();

//Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
SendData = "GET http://xxx.xx/getData.php?data=" + ThisMAC + "|" + ThisIP + "|" + temp + "|" + hum + " HTTP/1.1";
client.println(SendData);
Serial.println(SendData);
client.println("Host: www.ioft.ws");
client.println("Connection: close");
client.println();
client.stop();
}
delay(600000); //Delay 10minutes.
}

void printWifiData() {
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
ThisIP = ip2Str(ip);

// print your MAC address:
byte mac[6];
WiFi.macAddress(mac);
ThisMAC = String(mac[5], HEX) + String(mac[4], HEX) + String(mac[3], HEX) + String(mac[2], HEX) + String(mac[1], HEX) + String(mac[0], HEX);

}

String ip2Str(IPAddress ip){
String s="";
for (int i=0; i<4; i++) {
s += i ? "." + String(ip_) : String(ip*);_
_
}_
_
return s;_
_
}*_
Hope anyone can help
Best regards
Erik_A

You are using String objects. Over time, they can cause heap fragmentation and eventual crashes. Use plain old C strings instead. How long does it take before the system fails?

There is a memory free library that will let you see whether you have a memory leak.

I've also seen large Ethernet packets crash an Arduino if the wifi library you're using doesn't defend against them. No idea if the library you're using does or not. I'd check for a memory leak first though.

You can use open source libraries for memory leak control, as suggested by wildbill. Probably because of a mistake here.