A bit difficult to write the description there.
I want to log at extremely low battery power about 250 bytes per second but using an nRF52840 which has 256k ram, so I am assuming I should have at least 128k available to me for a buffer. Meaning I can save my 250 bytes per second data and write a 128kb chunk of data every 800 seconds which I assume is more efficient battery wise.
Powered by a coin cell so as low power consumption as possible is essential, what I am wondering is whats the best way to deal with the file system? I would ideally like to be as 'data safe' as possible so that if I do unmount the file (like via a power cut even) I can recover as much data as possible.
I am thinking probably one single file is fine, there seems to be little advantage to splitting it up into one file per write, but is this right?
And can I just SD.open the file, and write to it, then sleep for a while (which also means sleeping the SD card), and then wake up 800 seconds later and wake the card up and write to it again? And if I can do this is it actually the best way to do it?
OTOH I could close() the file each time I go to sleep and sleep the SD (to be clear I'll be sleeping the nRF52 at 250Hz I guess between ADC conversions, but sleeping the SD for 800 seconds at a time while I refill the 128k buffer with ADC data).
I'm familiar with wear levelling, the large block erase that SDs perform, etc, so it seems to make sense to try to write some multiple of the erase block size each time so that it does not keep copying a block to each time I add to that block. So hopefully I can find an SD with a erase block 128k or less. Whether this is something i can detect programmatically IDK.
I'm hoping @fat16lib might comment as I think he wrote the library I am going to use and some of these questions I think concern the inner workings of that library.
But also if anyone knows what consumes the least power (like, does it take more power to keep opening and closing the file each time, or does it make no difference) I would really like to ask that too.
If the card is removed during the sleep period between writes while the file is still open does this mean the data is not recoverable or does it not make much difference? I am prepared to read the SD with a custom reader, even through the same nRF52840 device if necessary and send the data to a PC via cable or bluetooth. Its more a question of how the handling of files works and if they will be very broken if they are not closed etc.
I've looked into using a serial data chip BTW but I need about a GB or two of storage and it does not look that cost effective.
Tia, Pete