SPI multiple slaves - SD Card and another Arduino

Hi! I am using an Arduino Mega 2560 as a master device. Its SPI bus is connected to 2 slaves; an SD Card and an Arduino Nano v3.0.

Basically, Arduino Nano takes measurements of sensors and send them to Arduino Mega. Then, Arduino Mega sends the data to SD Card to be logged in.

If I connect each slave seperately to Arduino Mega, they work properly. However, when I connect them together, sharing the same bus, the data received from Arduino Nano is corrupted (I dispay the data on Hyper Terminal from Arduino Mega). SD Card still works properly, since the received corrupted data is logged there.

When I played with some cables, I realized that if I disconnect the MISO pin of SD Card, the data is received from Nano correctly. MISO pin of SD Card is the only pin that is connected to SPI directly. The other lines are connected via resistors to divide the voltage from 5V to 3.3V.

I would appreciate any help that will solve the problem. Do I need to connect something to MISO pin of SD Card (maybe a buffer?)?

I am using regular SS pin (53) to chip select Arduino Nano and pin 24 to chip select SD Card. I am quite sure that the SS pins are correct. (chip select -> LOW; Otherwise -> High).


I would prefer to see your code, and your circuit. We have seen before people who are "quite certain" their circuit (or code) is correct when it isn't. No offence.

Which SD library are you using?

The Arduino SD.h library is a wrapper for a very old version of SdFat that I designed years ago. It has a lot of bugs and I have totally rewritten the low level SPI/SD part.

SD cards are tricky on the SPI bus. They require extra clocks after chip select is high to release MISO to tri-state.