I am working on several datalogging applications with a Feather M0 Adalogger, using the SdFat library.
My application will involve a high likelihood of a power-cut to the MCU during logging, and I want to minimize data loss.
If I use a low scan rate, writing data with FatFile::write(), I can call sync() periodically to limit the maximum amount of possible data loss from a power-cut.
However, if I attempt to scan at a faster rate (basically using the LowLatencyLogger example from the SdFat library) it is not clear to me exactly when the data will be written to storage. Calling sync() returns a value of true, but I can cut the power immediately after and end up with nothing in the file. I'd also like to avoid just creating lots of small data files, though this would accomplish the goal.
I'm fairly new to all of this, so apologies if I'm talking nonsense here.