Autonomo SD Card

Simpel Example to save data to your sd card. The file is semicollumn delimited ( ; )

#include <SPI.h>
#include <SD.h>

//#define CS_SD 4
#define seperator ";"                                                         //Seperator of the collumns
#define HEADERSTRING "Collumn1;Collumn2;Collumn3"                             //First line of the file showing headers

//Initializing the sd card reader
bool storeMemoryCardinit()
{
  if (SD.begin(SS_2)) {
    SerialUSB.println("Card ok");
    return true;
  }
  else{
    SerialUSB.println("Card failed, or not present");
    return false;
  }
}
//Store data on the sd card, first operator is the data to be saved, second operator is the name of the file to be writen to.
void storeSD(String dataString, String DataFileName)
{  
  File dataFile;
  dataFile = SD.open(DataFileName, FILE_WRITE);                                 //Try opening the file
  if(!dataFile){                                                                //If it cant find or create de file
    SerialUSB.println("couldn't open SD-card...trying to reinitialize");                                
    if(storeMemoryCardinit())                                                   //trying to reinitialize the cd card
    {
      dataFile = SD.open(DataFileName, FILE_WRITE);                             //trying to create or open the file again
    }
    else
    {
      SerialUSB.println("Something is going wrong");
       return;
    }
  }
  if (dataFile.size() < 10)                                                       //If it is the first line writen
  {
    //dataFile.println(String(HEADERSTRING));
    dataFile.println("\"sep="+(String)seperator+"\"");                                                //Write Seperator for excel
    dataFile.println(HEADERSTRING);                                               //Write the Collumn names
    SerialUSB.println("Writing the headers");
  }
    dataFile.println(dataString);                                                 //Writing the data                                           
    SerialUSB.println("Stored:" + String(dataString));
    dataFile.close();                                                             //Closing the file   
}

void setup() {
  // put your setup code here, to run once:
  delay(1000);
  SerialUSB.println("Starting Serial");
  SerialUSB.begin(9600);
  delay(10000);
  SerialUSB.println("Initializing Card");
  storeMemoryCardinit();
  SerialUSB.println("Beginning loop");
}

void loop() {
    storeSD("Data1;Data2;Data3", "Test7.csv");
    delay(5000);
}

hi

is there anyone would like to help me?

Hello Jen,

The device shown is connected through usb, or rxtx / two wire. It should work but you do need to know the instructions to read / write.

If you can find an datasheet of it, it should be posible.

Goodluck,
Erik

No, the USB port on the Autonomo can only be used as slave. To connect something like a card reader you would need support for USB master (which the Autonomo hasn’t)

hi

i can know it should be connected with a card reader.

so it would be better worked.

am i right?

I meant the device is usb, which is rx/tx.
Not to connect the usb on the autonomo on the sd card.

Why are you not using the onboard micro sd card if i might ask Jenbakel?