I have a sketch (attached to post because it was too long to place inline with the message, sorry) that runs on an Arduino UNO R3 connected to my home network via a WIZ811MJ interface running the Wiznet5100 chip.
@brief: The communications seem to stop if the USB cable is not connected to the computer and the serial monitor is running.
The sketch takes a reading from 3 sensors every 4 minutes and stores the results into a local buffer called "P". Every 4 minutes when the sample is taken the sketch uses UDP to grab a timestamp for the data from a NTP server. After 15 samples have been taken (happens once an hour) the sketch connects to a server and uploads the data from "P" using a PHP script and the process repeats itself for the next hour.
The sketch also puts the board to sleep into SLEEP_MODE_PWR_DOWN mode while it waits to take samples. The watchdog timer is configured by the user to wake up the board so it can run the loop() and see if it is time to take a sample. If a sample is to be taken the watchdog timer is disabled to stop it from interrupting in the middle of taking samples and/or sending data to the server. The timer is enabled again after the I/O ends so the system can save power in between samples.
I have a lot of debug print statements since I am still developing this sketch. I started testing my sketch "on the field" by unplugging the USB cable and letting the board run from a wall power supply in a manner similar to how I expect it to eventually work. I noticed then that it would work for a few hours and then it would stop updating the server. You can see that in one of the attached pictures. One shows a clear gap before new data was sent again to the server after I did a hardware reset of the board by pressing the reset button on it.
Last night I looked again through the code and added some more debug functionality but could not find a clear issue. I decided to leave the board connected to the laptop running the serial monitor all night to see if I could capture the point at which it will lock up. Except it never did. It has been running for more than 12 hours now without locking up whereas before it would be about 2.5 to 3 hours or so before it stopped being able to send data to the server and it seemed only a hardware reset would allow it to start sending data again.
I have status LEDs that indicate the stage in which the sketch is at. When data stops showing up at the server I use these to confirm that the board is waking up and taking samples and running the sketch on schedule, which it continues to do. Also, when the connection is working the 811MJ replies to ping requests properly even when the UNO is sleeping (as expected). But the ping to the 811MJ fails when the communications are lost. When this happens I can still ping a device that is connected to the same switch the 811MJ is connected to, so I think this might indicate an issue caused either by hardware or software on the 811MJ.
I will add that the WIZ811MJ is connected with an ethernet cable to a switch which is on a wireless access point/extender which itself connects to the home wireless network. I thought maybe this was part of the problem but after last night's run and the results of the ping test I don't think it is.
Ultimately since I am not taking high resolution data I could work around this by resetting the software ethernet interface in the sketch and forcing it to acquire a new IP from the DHCP server. But I'd feel better if the problem was actually solved.
Thanks!
A snippet from the serial monitor showing a successful sequence of data gathering will look like this:
Taking sample
Seconds since Jan 1 1900 = 3624706865
Unix time = 1415718065
The UTC time is 15:01:05
Sample: 14, Time: 1415718065, Capacitance: 0.000000000105852, Temperature: 28.231, Light: 69.05%
Taking sample
Seconds since Jan 1 1900 = 3624707145
Unix time = 1415718345
The UTC time is 15:05:45
Sample: 15, Time: 1415718345, Capacitance: 0.000000000106777, Temperature: 28.032, Light: 68.23%
------------SENDING DATA-------------
Connecting to upload server
connected
time=1415714152&temp=28.082&&light=70.577&&capacitance=0.000000000109826&&unit=0Disconnecting from remote server.
Connecting to upload server
connected
time=1415714431&temp=28.231&&light=71.427&&capacitance=0.000000000106551&&unit=0Disconnecting from remote server.
------------DONE-------------
While an unsuccessful sequence will print out like this:
Taking sample
Failed to parse UDP packet
Sample: 14, Time: 0, Capacitance: 0.000000000105852, Temperature: 28.231, Light: 69.05%
Taking sample
Failed to parse UDP packet
Sample: 15, Time: 0, Capacitance: 0.000000000106777, Temperature: 28.032, Light: 68.23%
------------SENDING DATA-------------
Connecting to upload server
The connection failed
Disconnecting from remote server.
Connecting to upload server
The connection failed
Disconnecting from remote server.
------------DONE-------------
CapacitanceMeterEthernet.ino (23.4 KB)

