Arduino writes file to SD but not content to file I'm using an Arduino UNO, the Extended Database Library (EDB), and an microSD Card to read/write 2 database tables. I've managed to create both ".db" files on the SD (they show up in Finder when I load the microSD directly onto my Mac).

I can also populate them with placeholder data, but this data does not seem to be actually written to the file (and thus doesn't survive reboot).

Also, trying dbFile = SD.open(db_name1, FILE_WRITE); returns false, even though the files do exist on the drive?

Here's my create code:

#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;
#define SD_PIN 10  //SD read/write pin
#define TABLE_SIZE 8192  //256*32
#include "Arduino.h"
#include &lt;EDB.h&gt;

char* db_name1 = "/DB/SENSOR1.db";
char* db_name2 = "/DB/SENSOR2.db";
File dbFile;

struct sensorLog1 {
  unsigned int id;
  float input;
  unsigned int timestamp;    
}
sensorLog1;
struct sensorLog2 {
  unsigned int id;
  float input;
  unsigned int timestamp;    
}
sensorLog2;

// Setting up EDB object
inline void writer (unsigned long address, const byte* data, unsigned int recsize) {
  dbFile.seek(address);
  dbFile.write(data,recsize);
  dbFile.flush();
}
inline void reader (unsigned long address, byte* data, unsigned int recsize) {
    dbFile.seek(address);
    dbFile.read(data,recsize);
}
// Create an EDB object with the appropriate write and read handlers
EDB db(&amp;writer, &amp;reader);


void setup() {

  Serial.begin(9600);

  createDB(db_name1, "sensorLog1");    
  createDB(db_name2, "sensorLog2");

  dbFile = SD.open(db_name1, FILE_WRITE);  // Doesn't work!
  if (!dbFile) { Serial.println("File does not exist"); }

}


void loop() {} 


void createDB(char* db_name, char* table_name) {

  // create file
  dbFile = SD.open(db_name, FILE_WRITE);
  db.create(0, TABLE_SIZE, (unsigned int)sizeof(table_name));

  // populate with placeholder data
  for (unsigned int i = 1; i &lt;= 20; i++) {
    table_name.id = i;
    table_name.input = 0;
    table_name.timestamp = 0;
    EDB_Status result = db.appendRec(EDB_REC table_name);
  }

  // check data
  Serial.println(db.count());  // returns '20'

  // close file to write
  dbFile.close();

}
db.create(0, TABLE_SIZE, (unsigned int)sizeof(table_name));


The third parameter is the record size! sizeof doesn't work on data, it works on types, so your getting the size of a char* instead of the size of your sensorlogN struct.

Your code as written shouldn't compile! a char* doesn't have a .id member.

table_name.id = i;
table_name.input = 0;
table_name.timestamp = 0;