We all have that one day in our life, where our SD card suddenly dies on us. The author also had the same problem, but instead of throwing it in the trash, he end up recovering the data using an Arduino. SD cards can be accessed with two modes. The first is the SDIO mode, which is what cameras, laptops, and other card reader’s use. The second mode is SPI mode. SPI is slower, but much, much simpler. This is what we use when we have to connect the microcontroller to a SD card.
The SD card library in the Arduino IDE contains an example called CardInfo. It connects to the card, and gets information such as size, file system type, and a list of files on the card. The author used a few sketches to dump the data on the SD card to his computer. The first looked at the file system and grabbed a list of files contained on the card. The second iterated over the file system and output all the files in hex over the serial port. With a bit of Python, The author was able to reconstruct a few files that were previously lost forever.