Connect SD card reader to 2 Arduinos

I need to connect an SD card reader to 2 arduinos - one for writing real-time data to a file and the other for reading that file and do further processing. I need to use 2 arduinos because I have a large amount of data that needs to be written for which I need to use a SD card to store data CONTINUOUSLY (the arduino SRAM is too small for this purpose) and process the read data (which is too slow thus intefering with the data reading process).

The SD card however fails to initialize when it is connected to BOTH arduinos. Both arduinos have their respective programs loaded. I know that the call to SD.begin(cs_pin) can be made only once and when there are 2 programs on 2 arduinos, it will be called twice. Hence it fails. Could somebody please tell a workaround for this? I badly need to get this working.

You should have posted this in Storage.

It would be difficult to access a SD card with two Arduinos. You would need to design some type of protocol and hardware to share the SD card's slave select line (edit: and MOSI line). You can't have both Arduinos trying to control those lines simultaneously. That will eventually damage one Arduino or the other.

edit: There are Arduinos with more program memory and SRAM that an Uno. I use a Mega 2560. And if you need more than that, there is the Due.

When the only tool you have is a hammer, all problems look like a nail.

You would need a setup like this, with a protocol where each side monitors the a Busy line. When one side is done accessing the card and closes out the files, it releases Busy. Then the other side can pull Busy low and open files on the card. Since there is some delay while the SD card does its own thing in the background, the side using the card can build in some delay as well before releasing Busy, especially after a write cycle, so the other side does not start too early.

Using 3 chips might be a little overkill, but I haven’t come across a good 5V to 3.3V converter with tri-state outputs. Having 74HC125 buffering MISO ensures good 5V levels coming back into the Arduino and also isolates the DataOut line from the SD card to allow 5V signals on each chip’s MISO pin while not damaging the SD card. (example, during ICSP programming).

Even if you solve the electrical/SPI problems, it still won't work since the SD libraries cache lots of info about the SD card. So if one Arduino writes the card, the other Arduino may use stale cached info to access the card.

Sharing devices this way was tried long ago but never worked very well. That's why files servers and network file system protocols were developed.