-->
Page 1 of 1

save 5 large arrays to flash using SPIFFS

PostPosted: Fri Apr 13, 2018 10:55 am
by atticus
I am trying to save 5 large arrays to flash as i do not have enough SRAM. The arrays are char array[30000]. The array gets filled with sensor data really fast so i need to fill it up, dump to flash, fill it up, dump to flash about 5 times. The data dumped to the flash will be retrieved afterwards for displaying on a graph format via a web page.

I have tested SPIFFS to write the a char array[2048] to flash. If i am correct, i understand that the flash has 4096 byte sectors that must be written to. This means i will need to write +- 75 sectors to save my 5 large arrays.

The way i think i should do this is as follows:

Code: Select all// open file for writing
  File f = SPIFFS.open("/f.txt", "w");
  if (!f) {
      Serial.println("file open failed");
  }
  Serial.println("====== Writing to SPIFFS file =========");
  // write 10 strings to file
  for (int i=1; i<=2048; i++){
    f.println(sensor_byte);
  }



My Question/Confusion

How do i write the large array to the file? Do I need to manage writing the data at 4096 byte chunks? Should I loop 75 times and append the file? I fail to write 4096 bytes as the esp wdt forces a reset. I am not sure if this is because of the serial display.