user37357: I want to connect Ethernet board (W5100 HR911105A) to Arduino Leonardo with SPI and I also want to connect SD reader.
When I test these boards separately everything working. But when I connect them  on the same board the program fails at Ethernet.begin();
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

#define SS_SD_CARD  4
#define SS_ETHERNET 10

const char CONFIG_FILE[] = "system.cfg";

byte C_MAC[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress S_IP(192,168,0,19);
IPAddress C_IP(192, 168, 0, 177);
const uint16_t  S_PORT = 8090;

EthernetClient client;

void setup() {
  Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
    pinMode(SS_SD_CARD, OUTPUT);
    pinMode(SS_ETHERNET, OUTPUT);

    digitalWrite(SS_SD_CARD, HIGH);
    digitalWrite(SS_ETHERNET, HIGH);

    digitalWrite(SS_SD_CARD, LOW);
    SD.begin(SS_SD_CARD);
    digitalWrite(SS_SD_CARD, HIGH);

    Serial.println("Setup ethernet");
    digitalWrite(SS_ETHERNET, LOW);
    if (Ethernet.begin(C_MAC) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      Ethernet.begin(C_MAC, C_IP);
    }
    delay(100);
    Serial.println("connectin...");
    bool result = client.connect(S_IP, S_PORT);
    Serial.println("connected");
    digitalWrite(SS_ETHERNET, HIGH);
}

void loop() {
  Serial.println("loop...");
  delay(1000);
}

I tried on Leonardo and Mega 2560.

user18489: i suspect the reason is due to how the inputs/outputs are designed, the W5100 appears to be a 3v3 board with 5V compatible inputs, as does the link you posted to the SD reader, however depending on how these inputs/outputs are designed can mean they won't "play nice" with other boards on the same bus even though SPI is designed to do that.
depending on where the problem lies there are a few potential solutions, if (as i suspect) the problem is the output from the devices back to the arduino (ie you can write to them but not read from them) which you could confirm by connecting all lines in parallel, but only connecting one of the serial lines back to the arduino and check that it works, then swap the serial to the other device and check that. assuming that both devices work in this configuration you only need to fix the return signal. the simplest way of doing this would be to use two tri state buffers.
so the return signal is only connected to the arduino when that devices select line is active. and high impedance (disconnected) otherwise, programatically disconnecting one device from the bus.

user31105: If you have a similar SD card reader like below (or same but with micro SD card), than I had exactly the same problem.
It works as single device on SPI, but not together with another SPI device.
You can either use a SD recorder proto board, or use a microcontroller that has multiple SPIs.

An example of the SD recorder I used and works with another SPI device on one SPI port.
Cons: bigger, more expensive
Pro: has a RTC and proto space.


user37540: Some card reaaders (as well as display boards with built-in sd socket) use 10-kOhm resistors in series to the CS, DIN and CLK lines, to perform a cheap 5V to 3.3V level translation. This is really not the best solution, especially in terms of speed (we verified that typically this limits the maximum SPI speed to about 1 MHz).
Other cards readers (such as this one http://modtronix.com/mod-sdcard-l5.html), just use 10 k-Ohm resistors as pull-up to 3.3V. Therefore you're connecting all the SD card lines to the Leonardo board, which is 5V level. 
This will cause serious issues to the SD card or to the leonardo board. If your card reader falls in this second case, I suggest you to insert a resistor divider (1k + 1.5k) in series to each input lines of the SD card: DIN, CLK, CS. 
In the following schematics I just show for the CLK line, of course you have to repeat this three times. A much better idea would be a level translator IC.

simulate this circuit – Schematic created using CircuitLab

37357: <p>I want to connect Ethernet board <code>(W5100 HR911105A)</code> to <code>Arduino Leonardo</code> with SPI and I also want to connect SD reader.
When I test these boards separately everything working. But when I connect them  on the same board the program fails at <code>Ethernet.begin();</code></p>

<pre><code>#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;
#include &lt;SD.h&gt;

#define SS_SD_CARD  4
#define SS_ETHERNET 10

const char CONFIG_FILE[] = "system.cfg";

byte C_MAC[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress S_IP(192,168,0,19);
IPAddress C_IP(192, 168, 0, 177);
const uint16_t  S_PORT = 8090;

EthernetClient client;

void setup() {
  Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
    pinMode(SS_SD_CARD, OUTPUT);
    pinMode(SS_ETHERNET, OUTPUT);

    digitalWrite(SS_SD_CARD, HIGH);
    digitalWrite(SS_ETHERNET, HIGH);

    digitalWrite(SS_SD_CARD, LOW);
    SD.begin(SS_SD_CARD);
    digitalWrite(SS_SD_CARD, HIGH);

    Serial.println("Setup ethernet");
    digitalWrite(SS_ETHERNET, LOW);
    if (Ethernet.begin(C_MAC) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      Ethernet.begin(C_MAC, C_IP);
    }
    delay(100);
    Serial.println("connectin...");
    bool result = client.connect(S_IP, S_PORT);
    Serial.println("connected");
    digitalWrite(SS_ETHERNET, HIGH);
}

void loop() {
  Serial.println("loop...");
  delay(1000);
}
</code></pre>

<p>I tried on Leonardo and Mega 2560.</p>
 18489: <p>i suspect the reason is due to how the inputs/outputs are designed, the W5100 appears to be a 3v3 board with 5V compatible inputs, as does the link you posted to the SD reader, however depending on how these inputs/outputs are designed can mean they won't "play nice" with other boards on the same bus even though SPI is designed to do that.</p>

<p>depending on where the problem lies there are a few potential solutions, if (as i suspect) the problem is the output from the devices back to the arduino (ie you can write to them but not read from them) which you could confirm by connecting all lines in parallel, but only connecting one of the serial lines back to the arduino and check that it works, then swap the serial to the other device and check that. assuming that both devices work in this configuration you only need to fix the return signal. the simplest way of doing this would be to use two tri state buffers.</p>

<p>so the return signal is only connected to the arduino when that devices select line is active. and high impedance (disconnected) otherwise, programatically disconnecting one device from the bus.</p>
 31105: <p>If you have a similar SD card reader like below (or same but with micro SD card), than I had exactly the same problem.</p>

<p>It works as single device on SPI, but not together with another SPI device.</p>

<p>You can either use a SD recorder proto board, or use a microcontroller that has multiple SPIs.</p>

<p><a href="https://i.stack.imgur.com/SBM4Q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SBM4Q.jpg" alt="SD breakout"></a></p>

<p>An example of the SD recorder I used and works with another SPI device on one SPI port.</p>

<p>Cons: bigger, more expensive
Pro: has a RTC and proto space.</p>

<p><a href="https://i.stack.imgur.com/a85YY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a85YY.jpg" alt="SD Recorder"></a></p>
 37540: <p>Some card reaaders (as well as display boards with built-in sd socket) use 10-kOhm resistors in series to the CS, DIN and CLK lines, to perform a cheap 5V to 3.3V level translation. This is really not the best solution, especially in terms of speed (we verified that typically this limits the maximum SPI speed to about 1 MHz).</p>

<p>Other cards readers (such as this one <a href="http://modtronix.com/mod-sdcard-l5.html" rel="nofollow noreferrer">http://modtronix.com/mod-sdcard-l5.html</a>), just use 10 k-Ohm resistors as pull-up to 3.3V. Therefore you're connecting all the SD card lines to the Leonardo board, which is 5V level. 
This will cause serious issues to the SD card or to the leonardo board. If your card reader falls in this second case, I suggest you to insert a resistor divider (1k + 1.5k) in series to each input lines of the SD card: DIN, CLK, CS. 
In the following schematics I just show for the CLK line, of course you have to repeat this three times. A much better idea would be a level translator IC.</p>



<p><img src="https://i.stack.imgur.com/2qdRG.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f2qdRG.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
