Hi Has any one experienced a Leonardo & ethernet shield intermittently not communicating with an SD card and causing a lock up? When I say intermittently it could be once a year or twice in quick succession.
I have a Temperature controller cum data logger cum web server running on a Leonardo using a standard ethernet shield and 8Gb Sd card. There is a lot of code and I don't need the boot loader or the serial interface so I've created a new board in 'boards.txt' to give the maximum space and i'm progamming the Leonardo with a USBasp and overwriting the bootloader. I've also turned off the ability for progamming to wipe the EEPROM and I preload that with temperature control points and IP addresses.
The code uses interrupts to set flags that set which bit of control code is used next in the loop. So every second the analogue inputs read a series of PT1000 sensors plus winks a led on/off and every 15 seconds the controls are turned on or off if needed. Then every 10 minutes data is written to a file on the SD card. Once a day we get UTP time from the web just to make sure the one second clock is not getting too far out of step and correct if needs be.
The Web server part can run on every loop and allows the current state of play to be viewed on a pc by reading and sending an HTMl file from the SD card and filling in the numbers. It also allows the break points for the temperatures to be adjusted and stored back in the EEPROM Likewise I can change the IP addresses if I really need to. It also allows me to down load the 'CSV' record files from the data logger part of the code.
When the unit hangs there are no more records written to the log file and the web pages will not down load.
This code has run continuously for years but!
At first I thought the problem was the mains power supply/ brown outs, but the system now includes a battery and it still happens.
I did postulate there might be an environmental temperature problem as the working unit is in a 25degC environment, but test units sat in the office at 19DegC have also exhibited the problem
I know its not memory conflicts as I have record the free RAM at various places in the code and the worst that that drops to is 640 bytes.
I've looked at all the 'while' loops including those in the SPI, ethernet and SDFat libraries etc and I don't think the problem is there as it would hang more often.
Given that pressing the reset button brings it all back to life the only other thing I can think of is how snugly the SD card fits in its holder. The problem happens with both the newer shields that have active level translation to the SD card and the older ones that use simlpe resistive dividers.
Unfortunately the system is supposed to run unattended and I've not been able to do that yet, any thoughts on how to find out where the code is stopping would be helpful.
I won't fill this message up with the source code as there is about 170k's worth of .ino/.h/.c/.html files but I'm happy to put them out if there are any specific suggestions