How to increase SD card write speed in arduino

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.


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().

Instead:

//for each loop, it is going to make a handshake
while(<yourCondition>){
    SD.write(<yourValue>);
}

Do:

char buf[length];
while(yourCondition){
    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.