I have ESP8266 module, the module is connected with a temperature sensor and the values are store in SPIFFS.
i planned to erase the old data one by one with new data when SPIIFS memory is full.
could you please help me to code that way?
this is the portion of code i am tied
OK, then you will need to implement it yourself and keep a list of files in some kind of FIFO structure, such as an array, or maybe make the filenames sequential numbers or dates/times so that you can search for and delete the earliest one
Will all of the files be of the same size ? If not then there is a danger of deleting a small one and replacing it with a larger one that there is not space for
How will you recognise that you are running out of space ?
assuming each temperature record (say 2 bytes) is timestamped with 4 bytes in your spiff file = 6 bytes
assuming you record t° every 10 minutes (6 per hour).
assuming you configured your ESP8086 4 Megs storage as 1 megabyte for the program and 3 for the spiff you can record more than 524k samples - roughly 10 years worth of samples...
whilst it's good to think about space usage, do you think it will be necessary ?
(if you store in ASCII of course duration will be shorter)
don't use SPIFFS, use an SD Card, you'll get Gigs of storage instead of Megs and the limit is really far away
if you want to shrink a file, that won't do, file system does not let you do so. You would need to duplicate from one point to the end in another file but as you are short in memory, that will be a challenge (or need to do so when you reach half the space)
easier option is to not use just one file, create one per month and when storage starts to be full, get rid of the oldest month files.