I'm trying to write a code for nodeMCU (esp8266 based board) to continuously calculate distance between GPS location and geographical coordinates written in a CSV file in SD. Originally I thought the best way to do it was to parse the file, save the longitudes and latitudes in two arrays at startup and, then, calculate continuously distances between arrays and coordinates taken from GPS. If distance is less than a value, an output warns me. There is only a "little" problem: the file contains 5500 coordinates and, so, it is impossible to allocate two arrays containing 5500 floats inside ram memory. Now I have thought two alternatives: 1) save the two arrays in flash memory that is, I know, a lot slower but also bigger 2) parse and calculate distance line by line continuously: in a loop I'll take the first line from SD, parse it, calculate distance between it and GPS location and, then do the same thing for second, third,... line. It requires the continuous access to SD and parsing but I don't have to use flash memory. What is the best option in your opinion? Have you got alternatives or suggestions? Thank you!!

  • I vote for 1). Is SD card faster then flash? Why not use file with SPIFFS?
    – Juraj
    Mar 16, 2018 at 8:55
  • I don't know if SD is faster than flash; probably it is. I have never used spiffs so I am a little bit scared on how to use it. Have you got suggestions?
    – Leonardo
    Mar 16, 2018 at 9:19
  • Can I only save .txt files inside SPIFFS or also arrays? If I save, for example, a .txt file with coordinates, I need to reopen it and parse it again, will it be convenient? Maybe I can use option 2 with SPIFFS instead of with SD
    – Leonardo
    Mar 16, 2018 at 9:26
  • I moved the comments to an answer
    – Juraj
    Mar 16, 2018 at 12:27
  • use an ESP32 instead: ~6X the usable RAM of the 8266
    – dandavis
    Mar 16, 2018 at 23:09

1 Answer 1


Instead od the SD card you can use the esp8266 file system SPIFFS. It uses the flash of the esp8266, which is connected at 40MHz as Quad I/O on newer systems.

To use SPIFFS you create a folder named data in your esp8266 sketch folder. You put the files in that folder and then you use the SPIFFS upload plugin.

In runtime use the SPIFFS library. It is similar to SD library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.