I am working on a project using an Arduino as a web server.


webFile = SD.open("index.htm");
if (webFile) {
  while(webFile.available()) {

This sends data line by line, leading to a long time to load the webpage. Is there a faster way to load this page?

  • Yes, reading in a full sector at a time and writing in large pieces which a TCP stack can chop into full packets which can be left outstanding awaiting later acks would be preferable - but likely requires more buffer memory than you have. This is why hanging a network interface on an Arduino is not only an unecessarily costly way to solve a problem, but also a generally unwise one. Jan 24, 2015 at 1:35
  • @ChrisStratton plz give me more information about how can do this Jan 24, 2015 at 8:57
  • Switch to a platform with more memory. Many of them are substantially cheaper anyway. Jan 24, 2015 at 14:19
  • Take a look at the libraries produced by www.pjrc.com (teensy) Nov 8, 2016 at 13:36

2 Answers 2


Well I have two ideas on the SD card side, though neither really seem great to me they could still help you. I read on the Arduino forum that the SD card R/W speeds generally come out to 600kB/s, I'm not really sure why, the Arduino SPI can go up to 8 MB/s and I didn't think there would be that much protocol/data-handling in SD.

  1. Sector R/W - As Chris Stratton said, this is an obvious method, it's probably much faster to do sector reads. You may have to greatly change your code to implement it, but I imagine you'd see performance increase in the end. Apparently there's an unofficial library for it, though it seems to impart some potentially serious limitations.
  2. RAM - This is the second thing that came to mind when thinking about the problem is that you could use external RAM, when not handling network transfers (Idling, should be most of the time) the Arduino transfers data to external SRAM which you add. SPI RAM is most likely the easiest to implement, but not likely to be any faster than an SD card. Parallel RAM is going to be difficult to implement, you'll likely need to write your own class/library, but it could be much faster than SPI RAM or an SD card.

I'm not actually sure if either of these would be any faster, it's all just theory and I hope others will share their thoughts. If you have trouble finding the download link for the SD Card library, it's right here. In that ZIP folder there's a file called SDCARD, just move that folder into your Arduino libraries folder on your computer.

  • how can get this library ? i can't found it in google ? @Unit_One Jan 24, 2015 at 10:15
  • 1
    Adding external RAM to an ATmega is absurdly inefficient. If you need more memory, use a processor which has that from the start. Jan 24, 2015 at 14:20
  • When I said RAM, I meant SRAM specifically. Which I did mention. Of course DRAM is practically unusable on Arduino, but SRAM is practical.
    – Unit_One
    Jan 25, 2015 at 2:45
  • Keeping in mind that I do not mean the use of external RAM to supplement the MCU's RAM, which is of course a terrible idea. But only to serve as a buffer for the data in the SD card.
    – Unit_One
    Jan 25, 2015 at 2:59
  • No, adding external SRAM to an ATmega for buffering reads from an sdcard is an absurdly slow and expensive solution to a problem correctly solved by selecting an MCU with sufficient on-board buffer memory (and in the case of this need, on-board or inexpensively added network interface). Jan 25, 2015 at 20:20

maybe you should use SdFat library; a library which is almost the same as the standard SD library, but also it can support Long Filenames.

I did some tests with read and write; it is most of the times > 60% faster!! https://github.com/greiman/SdFat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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