Ethernet Shield and SD Shield Together?

Hello all, I was wondering if it was possible to have an Arduino Uno with an SD card shield on it (SeedStudio SD v4.2), and then put an Ethernet shield on top of that (Generic Ethernet Shield)and have it work with two SD cards and Ethernet? I do not know enough about the ICSP bus to answer this myself so I ask you guys. Any help is appreciated.

I do not know enough about the ICSP bus to answer this myself

So it is lucky that it is nothing to do with that bus.

They all use the SPI bus. Yes you can use them all at the same time just so long as you have a unique chip select pin for each device and modify the software and / or libiary to suit.

Note that once you deselect an SD card to read or write to another device, you loose the point in the SD file you are reading. Not sure if that is what you are seeing.

Ok, so I would just use a different CS and make two instances of the SD library. How do you think I should modify the library?

I haven't tried that, but if I was to try, I think I would use the SdFat library. You might be able to pull off the two instances.

SdFat SD;
SdFat SD2;

edit: You should bend the ethernet shield's D4 so it doesn't insert into the SD shield, then jumper D4 on the ethernet shield to D5. This snippet compiled in my test sketch, so it may work

SdFat SD;
SdFat SD2;

// then in setup
  if(!SD.begin(4)) {
    Serial.println(F("SD failed"));
  }
  else {
    Serial.println(F("ok"));
  }

  if(!SD2.begin(5)) {
    Serial.println(F("SD2 failed"));
  }
  else {
    Serial.println(F("ok"));
  }

One would have to wonder why you want to do this. May it's merely for the intellectual exercise but, if you have a real need rather than simply have two files on the one SD, it might be time to move on from Arduino into something more powerful.

Well, yes a decent portion of it was simply to not be bored, to have a challenge; and with the SD card shield between the Arduino and the Ethernet shield it stacks rather quite nicely.

Im trying to figure this out though, if the Ethernet shield has a CS on pin 10 and the SD shield has a CS on pin 4, why doesnt it work? The TwoCard example (below) that came with SDFat, with adjusted CS pin and settings in the header file, gives me this output from the serial monitor:

Serial Output:

FreeRam: 6494
type any character to start
sd2:
Can't access SD card. Do not reformat.
No Card, wrong CS pin, or SPI problem?
SD errorCode: 0X1, 0X0

sd2 should be the Ethernet shield with a CS on 10, and sd1 should be the SD shield but the serial output doesnt mention it.

The TwoCard example code:

/*
 * Example use of two SD cards.
 */
#include <SdFat.h>
#include <SdFatUtil.h>
#if !USE_MULTIPLE_CARDS
#error You must set USE_MULTIPLE_CARDS nonzero in SdFatConfig.h
#endif

SdFat sd1;
const uint8_t SD1_CS = 4;  // chip select for sd1

SdFat sd2;
const uint8_t SD2_CS = 10;   // chip select for sd2

const uint8_t BUF_DIM = 100;
uint8_t buf[BUF_DIM];

const uint32_t FILE_SIZE = 1000000;
const uint16_t NWRITE = FILE_SIZE/BUF_DIM;
//------------------------------------------------------------------------------
// print error msg, any SD error codes, and halt.
// store messages in flash
#define errorExit(msg) errorHalt_P(PSTR(msg))
#define initError(msg) initErrorHalt_P(PSTR(msg))
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo
  PgmPrint("FreeRam: ");

  Serial.println(FreeRam());
  
  // fill buffer with known data
  for (int i = 0; i < sizeof(buf); i++) buf[i] = i;
  
  PgmPrintln("type any character to start");
  while (Serial.read() <= 0) {}
  delay(400);  // catch Due reset problem

  // disable sd2 while initializing sd1
  pinMode(SD2_CS, OUTPUT);
  digitalWrite(SD2_CS, HIGH);
  
  // initialize the first card
  if (!sd1.begin(SD1_CS)) {
    sd1.initError("sd1:");
  }
  // create DIR1 on sd1 if it does not exist
  if (!sd1.exists("/DIR1")) {
    if (!sd1.mkdir("/DIR1")) sd1.errorExit("sd1.mkdir");
  }
  // initialize the second card
  if (!sd2.begin(SD2_CS)) {
    sd2.initError("sd2:");
  }
 // create DIR2 on sd2 if it does not exist
  if (!sd2.exists("/DIR2")) {
    if (!sd2.mkdir("/DIR2")) sd2.errorExit("sd2.mkdir");
  }
  // list root directory on both cards
  PgmPrintln("------sd1 root-------");
  sd1.ls();
  PgmPrintln("------sd2 root-------");
  sd2.ls();

  // make /DIR1 the default directory for sd1
  if (!sd1.chdir("/DIR1")) sd1.errorExit("sd1.chdir");
  
  // make /DIR2 the default directory for sd2
  if (!sd2.chdir("/DIR2")) sd2.errorExit("sd2.chdir");
  
  // list current directory on both cards
  PgmPrintln("------sd1 DIR1-------");
  sd1.ls();
  PgmPrintln("------sd2 DIR2-------");
  sd2.ls();
  PgmPrintln("---------------------");
  
  // remove RENAME.BIN from /DIR2 directory of sd2
  if (sd2.exists("RENAME.BIN")) {
    if (!sd2.remove("RENAME.BIN")) {
      sd2.errorExit("remove RENAME.BIN");
    }
  }
  // set the current working directory for open() to sd1
  sd1.chvol();
  
  // create or open /DIR1/TEST.BIN and truncate it to zero length
  SdFile file1;
  if (!file1.open("TEST.BIN", O_RDWR | O_CREAT | O_TRUNC)) {
    sd1.errorExit("file1");
  }
  PgmPrintln("Writing TEST.BIN to sd1");
  
  // write data to /DIR1/TEST.BIN on sd1
  for (int i = 0; i < NWRITE; i++) {
    if (file1.write(buf, sizeof(buf)) != sizeof(buf)) {
      sd1.errorExit("sd1.write");
    }
  }
  // set the current working directory for open() to sd2
  sd2.chvol();
  
  // create or open /DIR2/COPY.BIN and truncate it to zero length
  SdFile file2;
  if (!file2.open("COPY.BIN", O_WRITE | O_CREAT | O_TRUNC)) {
    sd2.errorExit("file2");
  }
  PgmPrintln("Copying TEST.BIN to COPY.BIN");
  
  // copy file1 to file2
  file1.rewind();
  uint32_t t = millis();

  while (1) {
    int n = file1.read(buf, sizeof(buf));
    if (n < 0) sd1.errorExit("read1");
    if (n == 0) break;
    if (file2.write(buf, n) != n) sd2.errorExit("write2");
  }
  t = millis() - t;
  PgmPrint("File size: ");
  Serial.println(file2.fileSize());
  PgmPrint("Copy time: ");
  Serial.print(t);
  PgmPrintln(" millis");
  
  // close TEST.BIN
  file1.close();
  
  // rename the copy
  file2.close();
  if (!sd2.rename("COPY.BIN", "RENAME.BIN")) {
    sd2.errorExit("sd2.rename");
  }
  PgmPrintln("Done");
}
//------------------------------------------------------------------------------
void loop() {}

The SeeedStudio SD card and the ethernet shield's SD card both use D4 as the slave select. D10 is the w5100 slave select.

Oh ok, that clears some things up. Recently I found out that by using two cards I use around 1000-1200 extra bytes of SRAM, which essentially makes this whole thing kind of useless as unless I use my 101 or my Due then it won't work with my sketches. I can't use the 101 or the Due much simply because of their operating voltage. On a side note, is it normal for the w5100 chip to get so very hot? It essentially burned me after prolonged contact; should I be using a sort of cooling like a fan or similar?

On a side note, is it normal for the w5100 chip to get so very hot? It essentially burned me after prolonged contact; should I be using a sort of cooling like a fan or similar?

No this is not normal and it implies some sort of fault or miss wiring.

Do you have any ideas on how to correct this fault (if possible)? I gave the board a good visual inspection and found nothing wrong, I would check things with my meter but that is currently broken

@Mike44449, please do not cross-post. Thread locked.