Multiple SPI Ethernet and SD card reader (not shield)

Hello,

I have a big problem with my project.
I'm trying to connect: Ethernet ENC28J60 and micro sd card reader to Arduino UNO R3 via SPI BUS. I already digged a lot in web about it, but still nothing works...

Here is my connection wires schemat:

The code i'm using in project

#include <SD.h>
#include <SPI.h>
#include <EtherCard.h>

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

#define ETHERNET_PIN 10
#define SD_READER_PIN 4 

//////////////////////

void setup(){
  Serial.begin(9600);
  pinMode(ETHERNET_PIN,OUTPUT);
  pinMode(SD_READER_PIN,OUTPUT);
  
  // disable ethernet while setting up SD
  digitalWrite(ETHERNET_PIN,HIGH);
  
  Serial.print("Starting SD..");
  
  if(!SD.begin(SD_READER_PIN)){
    Serial.println("failed");
  }else {
    Serial.println("ok");
  }

// disable SD while setting up Ethernet
  pinMode(SD_READER_PIN,OUTPUT);
  digitalWrite(SD_READER_PIN,HIGH);


   if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0){
      Serial.println( "Failed to access Ethernet controller");
   }else{
      Serial.println( "access to Ethernet gain");
   }

  Serial.println("Finish");
}

void loop(){

}

As you can see i'm using in project EtherCard.h library.

On run i'm getting in UART Serial.println resault

Starting SD.. OK
Failed to access Ethernet controller
Finish

It looks like sd card is starting, but ethernet module don't whant to wake up.
Separatly Ethernet with standard example BackSoon works fine, same sd card.

Could somebody help me solve the problem?

P.S
I don't whant to use arduino shield. :confused:

As you failed to provide links to the exact hardware you're using I assume you bought on ali or something similar. Many (if not most) SD card reader boards from such sources are not proper SPI devices as they don't tri-state the MISO pin if CS is pulled high. If you have such a device on your bus it will be the only one that works correctly although it is the reason for the problems.

Some of the readers can be fixed with good soldering skills but it's often cheaper to buy a proper SD card reader (p.e. from Sparkfun, Adafruit, etc.).

Thanks for replay:

Links for modules:
The ethernet module ENC28J60

The micro SD card reader For-Arduino-Micro-SD-Storage-Board-Mini-TF-Card-Memory-Reader-Shield-Module-SPI

So both of these models are wrong or only SD card reader should be replaced? Because as i posted i need this modules separated (not on 1 shield)

So both of these models are wrong or only SD card reader should be replaced? Because as i posted i need this modules separated (not on 1 shield)

The ethernet module probably works OK but the SD card module most likely is one that shows the mentioned problems. I guess this one could be fixed if you have good soldering skills.

Hi,

I have exactly the same problem. Did you solve this problem?

Regards,

I have exactly the same problem. Did you solve this problem?

And you use the same cheap Chinese SD card reader? Did you already fix the hardware you bought? Did you actually read the answers above?

Hı Pylon
I solved my problem with 220 ohm resistance which i connect between miso pin of my SD reader and digital pins.

I solved my problem with 220 ohm resistance which i connect between miso pin of my SD reader and digital pins.

Very ugly but may work in some setups.

1 Like