I have a sketch that runs on an Arduino Ethernet (that comes with an SD card reader and, of course, an Ethernet interface).
There is a unique place in this sketch where I write to a file on the SD card, which basically looks like this:
char dpath[13]; // File path
char logline[30]; // String to be stored in
/* ... */
File dataFile;
if (dataFile = SD.open(dpath, FILE_WRITE)) {
dataFile.println(logline);
}
dataFile.close();
I didn't experience any problem for a few months having a couple of Arduinos running this sketch.
Recently, I put to work another one that is behaving weirdly. In particular, I see that on the SD card it generated a somewhat corrupted file.
The file size appears to be 4.0 GB, altough the total size of the SD card is 3.7 GB, and if I try to read it with a hex editor it appears empty:
$ du -h 20130206.DAT_
4,0G 20130206.DAT_
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 3,7G 58M 3,6G 2% /media/B045-FE58
$ hexdump 20130206.DAT_
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
fd000000
What could be happening to the microcontroller?
I'm asking this here, because I can't notice any programming problems, and the sketch is running fine on other boards. Should I be aware of some electric known problems? Could for example a not-stabilized power supply or some electromagnetic radiation be leading to this behaviour? I would appreciate any suggestion about electronic issues I should check.