SD Card fails every 5 or 6 minutes, help!

Hi all.

My sd card initializes fine in the beginnig. It finds the right file and opens it. However after 5 or 6 minutes of data logging, the error “file not found” appears on my lcd. Why would this be the case? I need this to work consistently for atleast an hour, this 5 to 6 minutes will not do. Also, in my code the “sv” and “cpm” data is not yet initialized, due to another problem incorporating a sensor. I left these in there, and the data is just logged as 0 for those variables.

I have attached the sketch as my code is too long to put in here.

Thanks in advance for your help!

_0909.ino (13.2 KB)

I see you use the String class => please check how much free memory you have. The String class is using dynamic memory and you might have a memory leak

check - -

where in my code do you recommend I put this function?

Please pardon me if you think I am asking very beginnerish questions. I am actually a beginner

So i ran the memory checker, and used the serial port to output the results every 0.5 seconds. The first value came out to 4580, the the values subsequently decreased by about 30 or so every 0.5 seconds. Right before my program crashed, the value was at 302. THen the error(file couldnt be opened) showed up on my lcd.

What is causing this memory leak? How do i fix this?

looks like you open the file "Data" multiple times without closing the file. This will cause a memory leak. You must close "Data" before opening it again since close frees memory.

You may other memory problems since you are losing 60 bytes per second.