Seeeduino Stalker: Writing to the SD Card

After I managed to upload the first sketches to the Seeeduino Stalker last week, I was eager to try the special features offered by this special kind of Arduino platform. I decided to try writing to an SD card first and followed the example included in the Stalker’s documentation. Which turned out to not work at all.

A couple of hours later and looking for errors in all the wrong places, I finally managed to find out how to use the FileLogger library:

  1. The SD card needs to be FAT16 formatted.
  2. The file that the the Arduino is writing to must exist, the library does not create files.
  3. The file must not be empty, it must contain at least one byte of data.

If these conditions are met, the following tiny sketch will work just fine and append data to the file:

#include "FileLogger.h"

void setup(void)
{
 byte buffer[] = "Hello World!";
 FileLogger::append("data.txt", buffer, 12);
}

void loop(void) {}

Update 10/8/12: Please note that this example will work with version 1.0 of the Stalker, only. For newer versions of the board you should try sadfatlib.

6 thoughts on “Seeeduino Stalker: Writing to the SD Card

  1. Hi, I got new seeduino and try to run this piece of code and can not see data appended in SD card?
    I have data.txt file with 4 bytes in SD card.
    Any suggestion?
    Thanks

  2. I am using the first version of the Stalker and the example code might not work on newer versions without modifications to the library. If you are using the Stalker V2 check here for data logging examples.

  3. Hi there,

    I have just tried this example and it won’t even compile (Arduino 1.0.1 and Stalker V328). I get the following error:

    Any ideas? Thanks

  4. oh… sorry… forgot the error:

    In file included from E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:53,
    from E:\ardunio\arduino-1.0.1\libraries\FileLogger/FileLogger.h:22,
    from sketch_oct07a.cpp:1:
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/Spi.h:36: error: ‘byte’ has not been declared
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/Spi.h:37: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/Spi.h:38: error: ‘byte’ does not name a type
    In file included from E:\ardunio\arduino-1.0.1\libraries\FileLogger/FileLogger.h:22,
    from sketch_oct07a.cpp:1:
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:62: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:63: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:64: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:137: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:151: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/mmc.h:166: error: ‘byte’ does not name a type
    In file included from E:\ardunio\arduino-1.0.1\libraries\FileLogger/FileLogger.h:23,
    from sketch_oct07a.cpp:1:
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:39: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:40: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:41: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:42: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:51: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:54: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:56: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:59: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:66: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:67: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:68: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:72: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:73: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:78: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:79: error: ‘byte’ does not name a type
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:88: error: ‘byte’ was not declared in this scope
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:88: error: ‘buffer’ was not declared in this scope
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/nanofat.h:89: error: ‘byte’ has not been declared
    In file included from sketch_oct07a.cpp:1:
    E:\ardunio\arduino-1.0.1\libraries\FileLogger/FileLogger.h:32: error: ‘byte’ has not been declared
    sketch_oct07a.cpp: In function ‘void setup()’:
    sketch_oct07a:5: error: cannot convert ‘byte*’ to ‘int*’ for argument ‘2’ to ‘int FileLogger::append(const char*, int*, long unsigned int)’

    I’m using filelogger v0.6

  5. hi, i m using Seeeduino v2.3 board, i just trying to write data in SD, but its not working. Can anyone suggest library file which is good.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.