How can I write to a SD card asynchronously?

I'm using an Arduino Due with Ethernet Shield v2 to to have access to a SD card. If I write to the SD card with the Arduino SD library this is done synchronously/blocking, right? The write operation does take a long time. I'd like to run it in the background, not in the superloop. I know that I could run the SD card writing in the background by introducing a RTOS and run it in a thread separate from the superloop. Is there another way? E.g. an alternative implementation of the SD card library which supports asynchronous writing?

Your writes are going to a 512 byte buffer which gets flushed once in a while (when it gets full, when you call flush or close the file).

Since SD and Ethernet both use the SPI interface they can't be used simultaneously even in separate threads.

@johnwasser :+1:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.