Arduino SD Transfer Speed Problem (Too Slow)


I’m using an Arduino Mega with an Ethernet shield on which the SD shield is included. I’m trying to copy an image to the SD (See code) but the transfer rate is too slow; it takes more than 30 seconds just to transfer 1KB :disappointed_relieved:

Here’s the code. Please check it and let me know what I’m doing wrong. I’ve checked other SD examples that use Serial.print/Serial.write inside a for loop to copy byte by byte and did the same but to no avail. I’m guessing the problem is with the code but I’m not sure. Any help?

  SD card read/write
 This example shows how to read and write data to and from an SD card file 	
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 created   Nov 2010
 by David A. Mellis
 updated 2 Dec 2010
 by Tom Igoe
 This example code is in the public domain.
#include <SD.h>
Sd2Card card;
SdVolume volume;
SdFile root;
File myFile;
File myFile2;
byte storage[1500];
void setup()
  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
   pinMode(53, OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile ="dog.jpg");
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("opening the img dog.jpg..");
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  // re-open the file for reading:
  if (myFile) {
    // read from the file until there's nothing else in it:
    myFile2 ="dog2.jpg", FILE_WRITE);
    int i = 0;
    while (myFile.available() && i < 1500) {
    	storage[i] =;
        Serial.print("Copying to the memory..... ");
      Serial.println("error opening Winter2.jpg");
    Serial.println("Done copying");
    int k = 0;
    while(k < i){
      Serial.print("Copying from the memory..... ");
    // close the file:
  } else {
  	// if the file didn't open, print an error:
    Serial.println("error opening winter.txt");

void loop()
	// nothing happens after setup

Pick up the pace, man. This isn't the stone age anymore.

use buffered reads, it will go a lot faster. search my old posts, I posted a sample before.

I've increased the baud rate and now it's working great. I don't think I'll need to use a buffer.

Thanks guys! Much appreciated.