I have a problem with a project of mine. I use a Mega2560 to read temperature and light sensors with 1 second frequency. The readings are sent on the network to a server where is processed.
My problem is that, after a while (couple minutes) the arduino no longer respond to the server requests. If I activate the serial monitor from the laptop (now the board is powered and connected on USB) I see that the setup() method is called again and the board start responding again. But only for couple of minutes. Probably the board is entering in sleep mode but I didn't find a method to disable this permanently (I need the board to work always because he needs to read sensors and communicate with the server continuously).
I need some help with this, any suggestion would be appreciated.
Thank you.
Are you using UDP or TCP? Either way, calling an ethernet function from an interrupt is not a good idea. Many functions count on the time for delays, and it isn't working right in an interrupt.
I cannot put a delay because I also need (in loop) to read the status of some inputs (sensors and command buttons) but it seems that, if I move the send to server logic from the interrupt and added to the loop method works. I set a variable on the interrupt method when it's called and then, in loop, if this is set, the I read the sensors and send to server (also reset the variable). Seems that this works ok.
Thank you very much for your help.