httpwwwbethedevcom
324329524619168
Loading...

Reading CSV files from a SD Card with An Arduino

Writing CSV files to an SD card is a fairly easy matter, build a string, adding a comma between each number and send that string to the ...


Writing CSV files to an SD card is a fairly easy matter, build a string, adding a comma between each number and send that string to the SD card. However, getting that data off the card and loaded back into use is not such an easy matter.

Here is a simple sketch that reads a CSV file with four numbers and two strings on each line.  It doesn't use the dangerous String class.

gps.csv

The following sketch successfully loads numbers and strings from an SD Card and is completely print values in serial (Serial Monitor).

Change the "gps.csv" file name according to your file name.

Arduino sd read CSV file.

If you have any questions please post your comments below.

Thank you!

Dev 4940884141221014460

Post a Comment Default Comments Disqus Comments

  1. I have used the csv file to store latitudes and longitudes coming from adafruit gps. I want to use the data to make distance calculations. Can you please help me on how to get the last two entries in the csv file to make calculations. so that all the time i want to make a calculation i just need to get the last two entries of the cordinates.

    ReplyDelete
    Replies
    1. Sorry! I could not able to make at the time little work around. try to answer as possible. if you have any other question ! Thanks

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Could you explain how does the program read the line by line? Where is the line counter number?
    Thx David

    ReplyDelete
  4. Thanks for the example. I'm trying to do something similar, but with three strings. Would you be able to explain what these lines do? I am not sure about ptr and scr as well as the significance of * and &.

    char line[200], *ptr, *str;

    String a = strtok_r(ptr, ",", &str);
    String first(str);
    *loc = first;
    String let(a);
    *loc2 = let;

    ReplyDelete

emo-but-icon

Home item

Popular Posts

Random Posts