0

How advisable is data logging to CIRCUITPY?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How advisable is data logging to CIRCUITPY?

by kevinjwalters on Tue Feb 16, 2021 12:09 pm

I've been doing my first bit of data logging recently on a CLUE and CIRCUITPY was an obvious, easy choice for storage. I've realised I might be at risk of wearing out the flash. I've been writing 80 bytes at a time and using flush() to ensure they persist immediately. I've probably done this (see code below) every 10 seconds for about 6000 data lines. Am I at risk of trashing my CLUE?

Code: Select all | TOGGLE FULL SIZE
data_file.write(out_text.encode(encoding) + end)  # 80 bytes of data
data_file.flush()


Will the lifetime be extended without the flush()? Should I buffer data inside my app and write it in certain block sizes to maximise the life of flash?

kevinjwalters
 
Posts: 959
Joined: Sun Oct 01, 2017 3:15 pm

Re: How advisable is data logging to CIRCUITPY?

by danhalbert on Tue Feb 16, 2021 1:23 pm

The flush is going to happen after a few seconds or less in any case, probably before 10 seconds has elapsed.

The flash lifetime for that kind of flash is often quoted as > 100k cycles. So in 24 hours at 10 seconds/cycle, you would be writing 8640 times, which is a significant fraction of 100k. So buffering sounds like a good idea. Or consider using an SD card, which does wear leveling.

danhalbert
 
Posts: 2426
Joined: Tue Aug 08, 2017 12:37 pm

Please be positive and constructive with your questions and comments.