I have a problem with the Ethernet shield.
This is the sketch I have wrote
void loop() {
wdt_reset ();
EthernetClient client = server.available();
if (client) {
wdt_reset();
if (client.available() > 0) {
char thisChar = client.read();
Serial.write(thisChar);
RXtext += thisChar;
// --------------------- this one repeat for few other strings ----
if (RXtext.indexOf("L1_On") >= 0) {
// do stuff
RXtext = GetStat(); // get system status and replay
server.print(RXtext);
Serial.println(RXtext);
RXtext = "";
wdt_reset();
}
// ---------- end of repeat -------
}
}
}
For some reason the arduino gets stuck after few times I connect to it
it does not reset the wtd and it gets reset and the it looses the IP and gets 255.255.255.255 IP.
Can someone tell me what is the problem?
You need to close the connection at the end of your loop:
Otherwise you’ll run out of connections and the thing will lock up and the watchdog timer will time out.
According to the Ethernet library docs: The library supports up to four concurrent connection (incoming or outgoing or a combination)