I'm creating a data-logger system which logs data in SD card at a high speed of about 20000-30000 bytes per second. But the SD library in arduino currently writes data at about 4500-5000 bytes per second which is too slow.

I've read this hack to improve the write speed, but I'm wondering if a more direct approach is possible, maybe by adjusting the SPISettings.

  • 1
    You might try the SdFat library - it's much more efficient than the default SD library.
    – Majenko
    Commented Aug 20, 2016 at 19:25
  • You might also want to make sure your SD card is of good quality, although 5000 bytes seems too low for any kind of SD card.
    – Len
    Commented Aug 22, 2016 at 9:10

3 Answers 3


OK. So, I tried the SDFat lib. This library is definitely better than the default SD library that comes with adruino. But that is not how I solved my problem of low data-rate.

I followed the instruction of the author of SDFat library from this post.

According to fat16lib, to increase the data rate we need to use flush() wisely. We would want to write() the data in each cycle, but we only need to flush() once every 100 cycles or so depending on how much data is being written in each cycle. Also, be sure to keep the flag in SD.open() as 'O_WRITE | O_CREAT' instead of 'FILE_WRITE'.

This sure increased the speed by a great factor. But I needed more!

Storing the data in binary (check out this blog) improved the performance even more.

My current speed is approximately 100-120 KBps (that's kilo bytes) with a class 4 SD card!

Finally, I want to thank you guys for your help.


Many factors would decide if you can reach this wanted speed. Only some of these.

1. Your Software

The SdFat Library is faster than the standard SD Library of the Arduino IDE. It also has an easy to use compatibility function with the standard SD Library. Try it out.

2. Your Hardware

You should use a high class SD Card. As you maybe know SD Cards are sorted into performance classes. Most people in the internet recommend a SanDisk SD Card.

  • I will try this in a few days and let you know the results. Thanks. Commented Aug 23, 2016 at 7:16

Avoid the handshake getting a buffer!

Use SD.write(buf,size);

Hi every one, I'm working in a project with the same issue. I was following the same steps of yours and got exactly the same numbers. I've just fixed it out. The problem is the handshake when you call the SD.write().


//for each loop, it is going to make a handshake


char buf[length];
    buf[index] = yourValue;
SD.write(buf,index);//only one handshake

In my project the first one I got 4100 bytes, and the second one using a buffer with 128 (buf[128]) I got 145408 bytes in my project. Good enough.

  • 1
    I don't know what you mean by handshake, because AFAIK SD uses a (512 kB) buffer internally anyway. But I also observed that writing individual bytes with File.write is extremely slow and the compiler doesn't seem to be able to optimize it (after all it's just copying one byte to the internal bufffer and checking if buffer is full and SPI transmission should start). Using my own buffer outside and File.write(buffer,size) brought extreme performance improvement also in my application.
    – oliver
    Commented Jun 7, 2018 at 8:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.