My SD card is being corrupted.

Greetings,

I'm using WaveShare's Micro SD storage board, and the SD library, and something appears to be corrupting my SD card.

After formatting the card on my laptop, and running the CardInfo sketch, I get:

Initializing SD card...Wiring is correct and a card is present.

Card type: SD2

Volume type is FAT32

Volume size (bytes): 1967448064
Volume size (Kbytes): 1921336
Volume size (Mbytes): 1876

Files found on the card (name, date and size in bytes):

Then I run the ReadWrite sketch and get:

Initializing SD card...initialization done.
Writing to test.txt...done.
test.txt:

which appears to have written nothing to test.txt

But if I run CardInfo again I get:

Initializing SD card...Wiring is correct and a card is present.

Card type: SD2

Volume type is FAT32

Volume size (bytes): 1967448064
Volume size (Kbytes): 1921336
Volume size (Mbytes): 1876

Files found on the card (name, date and size in bytes): 
TEST.TXT      1998-02-02 16:00:00 66052
?@.

The @. above is actually followed by a great deal of gobbeldygook that I am unable to cut and paste here.

Has anyone experienced anything similar?

Peter.

How are you powering the card? If you are using the 3.3v pin on the Arduino, that may not provide enough current for a read/write. According to the hardware datasheet, that pin is limited to 50ma, and the card could use more than that when writing. That could take 60-100ma, depending on the card.

edit: If you do not have a 3.3v regulated power supply, try powering the SD card with 2 new AA batteries in series. Keep the ground connected to the Arduino. That should provide enough voltage and current to test the theory about the power supply.

Make sure to keep it connected to ground. Secure your connections, too.