I know there is a tons of this type of threeds, but i cant find solution to my problem...
I hawe made automatic garden watering controller with atmega2560 and ethernet shield.
Im running web server from SD card with 2 pages.
All is working fine but at some default time (1h or 1week...) web server stops responding (every time when im on page and im changing something). But program dont hangs - it works normaly (buttons, rellays...).
Because im a hobby programmer (at most copy paste ) i need your help.
You're probably running out of memory (RAM). You can easily save lots of memory by using the F macro. Another way to save a lot of memory is to get rid of the String class as it fragments the memory very fast.
pylon:
You're probably running out of memory (RAM). You can easily save lots of memory by using the F macro. Another way to save a lot of memory is to get rid of the String class as it fragments the memory very fast.
Thanks for helping me. If the program is running out of ram then the complete program stops and not just web server. Or im false?
SurferTim:
Also, move your Udp.begin() call from getTimeAndDate to the setup function. I haven't tested this, but repeatedly calling it may cause a socket fail.
Thanks for helping me. If the program is running out of ram then the complete program stops and not just web server. Or im false?
It may react in any way, it's simply not defined as the new data that doesn't fit into memory may be written over any other information. Sometimes this ends in a freeze, sometimes just in a misbehavior.
pylon:
It may react in any way, it's simply not defined as the new data that doesn't fit into memory may be written over any other information. Sometimes this ends in a freeze, sometimes just in a misbehavior.
Do you have idea how to solve this? Can it be because to much web requests?
SurferTim:
I use this code to check the socket status. You can call it any time you feel necessary.
#include <utility/w5100.h>
byte socketStat[MAX_SOCK_NUM];
void ShowSockStatus()
{
for (int i = 0; i < MAX_SOCK_NUM; i++) {
Serial.print(F("Socket#"));
Serial.print(i);
uint8_t s = W5100.readSnSR(i);
socketStat[i] = s;
Serial.print(F(":0x"));
Serial.print(s,16);
Serial.print(F(" "));
Serial.print(W5100.readSnPORT(i));
Serial.print(F(" D:"));
uint8_t dip[4];
W5100.readSnDIPR(i, dip);
for (int j=0; j<4; j++) {
Serial.print(dip[j],10);
if (j<3) Serial.print(".");
}
Serial.print(F("("));
Serial.print(W5100.readSnDPORT(i));
Serial.println(F(")"));
}
}
Here is a status code list.
0x0 = available
0x14 = waiting for a connection
0x17 = connected
0x1C = connected waiting for close
0x22 = UDP
Edit: If you are using server code, one socket should show 0x14. If not, you have a problem.