-
Notifications
You must be signed in to change notification settings - Fork 0
Under the hood: Arduino SD card library & CSV data managment
AJ edited this page Feb 7, 2024
·
5 revisions
Let's take a look at a typical line of CSV from an SD card write: (i0-5 are indexes, in markdown mode I have to put a header to make a table)
i0 | i1 | i2 | i3 | i4 | i5 |
---|---|---|---|---|---|
1 | 2 | 3 | A | B | C |
Let's read this data from the SD card with the Arduino. We'll do that by:
myFile = SD.open(fileName, FILE_READ);
int byteCount = 0;
while (myFile.available() > 0)
{
byteCount = myFile.readBytes(buff, MAXBYTES);
Serial.print("Number of Bytes Copied: ");
Serial.print(byteCount);
Serial.println();
}
myFile.close();
for (int i = 0; i < byteCount; i++)
{
Serial.print(buff[i]);
Serial.print(" ");
}
Serial.println();
Let's get a step by step breakdown.
myFile = SD.open(fileName, FILE_READ);
You'll notice here instead of seeing something like "Datafile.csv"
I simply have filename
. This is because in my defines, I