SPI with multiple slave devices problem (Ehternet, SD, RFM69W)

Hi folks,

I have connected a Ethernet shield (with SD slot) to Arduino UNO through SPI bus. The ethernet has SS pin 10 and SD has SS pin 4 by default which works perfect. However, I need to connect another SPI device the RFM69W RF module which also using the SPI connection. I know the SPI.h library has set the SS on pin 10. Is there any way I can have another pin for the RF module? like pin 9 or pin 8? I have been research online for couple days, but I'm still confusing about the SPI connection with multiple slaves. Can I just connect the SS from the RF module to the Arduino pin 9 and do the following program? Do I need to modify any library files? thank you for time.

void setup()
{
Serial.begin( 115200 );
pinMode(10, OUTPUT);
pinMode(4, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(10, HIGH); //disable ethernet SS pin10
digitalWrite(4, HIGH); //disable SD SS pin4
digitalWrite(9, LOW); //enable RF SS pin9

RFM69W library files: GitHub - LowPowerLab/RFM69: RFM69 library for RFM69W, RFM69HW, RFM69CW, RFM69HCW (semtech SX1231, SX1231H)

All SPI devices share the MISO MOSI and CLK. The board has its own SS which is used to turn Arduino into an SPI slave, leave that at the default settings. you can use any unused pin for an external device SS.

On start up I set all SS pins to disable ( high ), then go from there, instantly enabling a device like you have on start up has always caused me problems. Also verify all devices can run at the same speed, otherwise in between using devices you may have to reconfigure the settings in the SPI library, the default speed should be more than compatible however its always something to check when the idea bucket is empty ( maybe they all support max speed, which isn't default )..

pYro_65:
All SPI devices share the MISO MOSI and CLK. The board has its own SS which is used to turn Arduino into an SPI slave, leave that at the default settings. you can use any unused pin for an external device SS.

So there is no need for any library modification? All I have to do just set any unused pin as OUTPUT which will acts like SS pin for other device?

They should work together ok. I use the w5100 and SD together. No need for library mods.

The only thing I have found that causes problems is the Ethernet.begin() function. It has a bug that leaves the w5100 SPI active (D10 LOW) after the call. You must set D10 HIGH after calling that function.

SurferTim:
They should work together ok. I use the w5100 and SD together. No need for library mods.

The only thing I have found that causes problems is the Ethernet.begin() function. It has a bug that leaves the w5100 SPI active (D10 LOW) after the call. You must set D10 HIGH after calling that function.

The w5100 and SD works fine together, but I want to add one more SPI device on top of that Ethernet shield using any pins for example pin 9 or pin 8. (since the w5100 and SD are using the pin 10 and 4). thanks

The only requirement is the ethernet shield needs the ICSP pins connected, so normally it must be first shield connected to the Uno. The second shield must use D11-D13 for SPI because the ethernet shield does not have the ICSP pins exposed on the top for a second shield if it also needs the ICSP pins.

SurferTim:
The only requirement is the ethernet shield needs the ICSP pins connected, so normally it must be first shield connected to the Uno. The second shield must use D11-D13 for SPI because the ethernet shield does not have the ICSP pins exposed on the top for a second shield if it also needs the ICSP pins.

I see, but what about the SS for my RFM69W? connect to the same SS pin (pin4 or pin10) as the Ethernet shield?

No it needs its own SS pin, the SPI control lines are also exposed in the uno pins d11-d13 if you cannot use the ICSP header (which the ethernet shield uses).

pYro_65:
No it needs its own SS pin, the SPI control lines are also exposed in the uno pins d11-d13 if you cannot use the ICSP header (which the ethernet shield uses).

Here is my problem. I have no idea how to make a SS pin for my RFM69W RF module.

Pick any unused standard digital pin. Set it to output and high, this is disabled. To use it set output value to low ( most SPI devices are active low, check the data sheet for verification ).

The Ethernet shield designers have also just picked random pins they thought looked good at the time ( 4, 10 ).

SS is just the name for slave select, which any output can do, if you have a pin that takes over the world you could label it WD for world domination. Its just more logical than using numbers ( differing layouts for different devices, however SS is always part of SPI terminology ).

Are you using a library for the RFM69HW?