Read data from sd card

20 Jul 2011

Is it possible to read the stored data from the SDcard.If it is possible please give me an example. Thanking you

20 Jul 2011

Have a look in the cookbook ;-) There are some examples ....

Regards kokisan

20 Jul 2011
21 Jul 2011

for reading just replace the "w" in the fopen command with "r" and use fgetc or fgets to read a single byte or a string from the file:

      // example of reading a file one byte at a time
      // and display it in hex format on the terminal

      unsigned char c;                          // a single byte buffer

      FILE *fp = fopen("/sd/myfile.txt", "r");  // open the file in 'read' mode

      while (!feof(fp)){                        // while not end of file
           c=fgetc(fp);                         // get a character/byte from the file
           printf("Read from file %02x\n\r",c); // and show it in hex format
      }
      fclose(fp);                               // close the file

If you want to read more data at once use fgets instead.

24 Oct 2016

how can I save and read integer values from sdcard. Do I have to write fgetd?