Getting data from an Arduino SD card

We play a lot with Arduinos and write data to the excellent Adafruit MicroSD Card Breakout Board. However, if you have an arduino, a card, and a cable, how do you get your data off. Here is a way!

First, we need some code to read a file from the SD Breakout Board. We have a file called OUTPUT.txt that we append to, and so we want to read from that file.

Here is code from Adafruit to read from a file on the breakout board:

#include <SD.h>
File myFile;
void setup() {
    Serial.print("Initializing SD card...");
    pinMode(10, OUTPUT);
    if (!SD.begin(10)) {
       Serial.println("initialization failed!");
    Serial.println("initialization done.");

    // open the file for reading:
    myFile ="OUTPUT.txt");
    if (myFile) {
       // read from the file until there's nothing else in it:
       while (myFile.available()) {
       // close the file:
    } else {
       // if the file didn't open, print an error:
       Serial.println("error opening test.txt");
void loop() {
 // nothing happens after setup

Upload this to your arduino, but don’t open the serial monitor!

Next, on your linux laptop connected to the arduino via the USB cable, you can use screen to capture the file:

sudo screen -L /dev/ttyACM0 9600

The -L means store a log file called screenlog.x where x is a number that starts at 0 and is incremented. The /dev/ttyACM0 is the address of the board. Check that in the Arduino IDE. The 9600 is the baud rate which is described in the “Serial.begin(9600);” line in the code above.

You should now have the output!

Of course, next time don’t forget to bring your micro-SD card reader