Ethernet-Shield with SD-Slot

Hy... I try to make a Webserver with my Ethernet-Shield.

This one -->

If i write my HTML Code in the development environment everything works fine.

And when i try to read from the SD-card without ethernet Code,

I´m only use the code for the sd card, that also works.

But I got a problem when I save my HTML Code on the SD-Card.

When I include the Sketch for the sd-card, the ethernet client is not available.

Could it be that is not possible to use the SD Card and the ethernet connecten in the same Sketch.

I watched a few Videos on Youtube and the all used the small ethernet shield.

This one -->

I hope someone can help me


Sorry for my bad english

The first one uses the W5100 chip, and that is the same chip as on the official Ethernet Shield. The Arduino Ethernet libraries are written for that chip.

The second one uses the ENC28J60, which is not official supported by Arduino. There are two libraries for it, the UIPEthernet (compatible with the Arduino Ethernet library) and the EtherCard. I suggest to stay with the W5100.

When you buy a cheap clone with bad quality components, buy a 'R3' version. It is best when the Arduino Uno or the Arduino Mega 2560 and the Ethernet Shield are all 'R3' version. Why did you pay so much money. If you are willing to buy a cheap and unreliable clone, then at least don't spent too much money. They are below 6 dollars on Ebay:

The SD card and the Ethernet will work together of course. Could you show your sketch ?


#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(10, 0, 0, 20); // IP address, may need to change depending on network

EthernetServer server(80); // create a server at port 80

File webFile;

void setup()
Ethernet.begin(mac, ip); // initialize Ethernet device

server.begin(); // start to listen for clients

Serial.begin(9600); // for debugging

// initialize SD card
Serial.println(“Initializing SD card…”);

if (!SD.begin(4)) {
Serial.println(“ERROR - SD card initialization failed!”);
return; // init failed
Serial.println(“SUCCESS - SD card initialized.”);
// check for index.htm file

if (!SD.exists(“index.htm”)) {
Serial.println(“ERROR - Can’t find index.htm file!”);
return; // can’t find index file
Serial.println(“SUCCESS - Found index.htm file.”);

void loop()
EthernetClient client = server.available(); // try to get client

if (client) { // got client?
boolean currentLineIsBlank = true;

while (client.connected()) {

if (client.available()) { // client data available to read
char c =; // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: html”);
client.println(“Connection: close”);
// send web page
webFile =“index.htm”); // open web page file
if (webFile) {
while(webFile.available()) {
client.write(; // send web page to client
// every line of text received from the client ends with \r\n
if (c == ‘\n’) {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
else if (c != ‘\r’) {
// a text character was received from client
currentLineIsBlank = false;
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)

When I open the serial montior I see “SUCCESS - Found index.htm file.”

But If I open my browser and conntect to the arduino nothing happens ;(

I don't see the problem, but I noticed a few things you need to fix.

First of all, use code tags for your sketch. It is number 7 on this page :,148850.0.html

Please use indents and spaces and brackets always in the same way. Try the command in the menu : Tools / Auto Format

Add a check for webFile. Print to the serial monitor if opening that file was successful or not.

Split this : client.write ( ) ; Use a char or byte. That makes it possible to print it also to the serial monitor. It also prevents that a .read() is turned into an integer and a integer is printed.

The SPI bus could be confused. When the Ethernet starts, the digital pin 4 is not initialized. And it is the enable for the SD card. You could set pin 10 and pin 4 as output, and make them high and wait a few milliseconds. After that the Ethernet.begin().


Thank you for your tip, next time I´ll use the Code tag.

No it works :)

I changed the SD-Card, I suppose this was the problem.


Well done, I didn't think of that. Could you still fix the things that I mentioned ? Have you read this : I use it for all my sd cards that are used with Arduino.

I changed the SD-Card, I suppose this was the problem.

I think it may be possible for an arduino to mess up the format on an SD card. I always put the SD card in the pc for loading stuff on it. Try the card in a pc and see if it works. If not, try to reformat the card.