Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By espforuandme
#91296 Hi,

i want to log approx. 100 sensor measurings per day.
At the moment i use a SD Card reader for logging but i wonder if it would work using the SPIFFS for this job?

I read that only 10000 writing cycles are possible which would mean that i would reach this limit after 100 days.
In another forum i read about 100000 possible cycles which would be much better but still worse.

What does this limit mean? if i reach the 10000 or 100000 cycles --> what exactly happens?
Will the ESP stop logging? Is the flash memory then unusable for all time or can it be "repaired" by flashing again?

Thanx for your reply

Daniel
User avatar
By QuickFix
#91309 Everything technical item (including solid state memory) has a so called "MBTF" (short for: "Mean Time Between Failures") value, which basically means that something may (and eventually will) break after a certain amount of uses (or time).

With memory, in this instance, this means that a single bit is "Guaranteed" (between quotation marks, because it is always an estimated value) to work for an X-number of read/write cycles (in this case 10.000 write cycles) after which it will eventually fail and may give unpredictable results (sometimes it works, sometimes it doesn't) in the mean time.

The MBTF of a component depends on a number of factors: quality of the component itself is one, but also the strategy used for writing to memory can be of influence.
"Intelligent" memory hardware/software will spread the usage of each bit of memory, so that not always the same piece of memory is used all the time, but memory allocations are used evenly.

Of course: if you have more memory at your disposal (say an SD card of 4GB), it's easier to lengthen the actual usage time of a component than when you have little (say SPIFFS of 4MB) available.

Another plus is that an SD card is cheap and easy to replace, when it starts to breaks: replacing the entire ESP (or only it's on-board flash memory) will be more of a hassle.
You cannot "Fix" failed memory by reflashing the code: you'll first also have to replace the memory chip. :idea:
User avatar
By btidey
#91317 You should use littleFS rather than SPIFFs (which is now deprecated).

Both use wear leveling methods that mean the wear is spread out over all the memory pages. The 10000 number applies to each page location not an overall limit so the total number of writes can be much higher if small amounts of data are being written relative to the overall flash size.

A 4MByte flash might be used for a 2MB Filing system so would have 8192 pages of 256 bytes. So there is 8192 x 10000 possible total writes if the wear was perfectly spread over the filing system.

Assuming that say 4 writes were needed by the FS per sensor reading then you could do 200 million writes and at 100 per day that is over 5000 years.

You can also help reduce the number of writes by buffering several readings in RAM before committing them to the filing system with 1 write.

Page size is 256 bytes I think so could probably hold quite a few sensor readings but you may want to commit more often to reduce the risk of data loss if say power failed.

Overall using FS in the on-board flash for this type of operation is fine providing wear levelling is used.