[SOLVED] Difficulty using SPI SDCard and SPI Ethernet (W5500) together

I have been trying to get an SPI Sdcard reader and an SPI Ethernet board working, and I just can’t get them working together.

I have IDE 1.8.10 installed. I’m using Visual Studio and Visual Micro as my dev environment. Same behavior using the Arduino IDE.

Either one by itself (other removed from breadboard) works fine. If both are connected, only the SDcard works. If both are connected, but there’s no power to the SD card reader, then Ethernet works.

I’ve tried two main boards (mega 2650 and UNO), and have tried replacing both the reader and the Ethernet (I have multiple of each).

For simplicity, I’ve been using the de facto standard CS pins - 10 for Ethernet, 4 for card reader. I’ve tried changing those as well, but no difference in behavior.

I’ve tried changing the Wire speed - no difference, no matter what I tried (10000, 100000, 400000, 1000000).

Both board descriptions say they work at either 5 volts or 3.3 volts.

Since both boards work when used alone, I’m pretty sure the wiring is OK.

At this point, I’m wondering if the SD reader is badly designed, and won’t play nice on the SPI bus with anything else.

Any suggestions for other things I can try?

Here’s the boards I’m using:
Ethernet
SD Card

Code I’m using (unrelated parts are IFDEF’d out):

#include <Arduino.h>

#define HARDWARE_TEST 1
#include <Wire.h>

#include <SPI.h>
#include <SDFat.h>
#include <Ethernet.h>

#ifndef HARDWARE_TEST
#include <DS3231.h>
#include <Time.h>
#include <Timezone.h>
#include <YAAWS.h>
#endif


constexpr byte SDCARD_CS = 4;
constexpr byte ETHERNET_CS = 10;
IPAddress ip(192, 168, 2, 90);

SdFat SD;

#ifndef HARDWARE_TEST
WebCallback callback;

WebServer web(80, SD);
#endif

// the setup function runs once when you press reset or power the board
void setup() 
{
	Serial.begin(115200);

	while (!Serial)
	{
	}

	//Wire.setClock(1000000);
	Wire.begin();
	
	Ethernet.init(ETHERNET_CS);

	if (!SD.begin(SDCARD_CS))
	{
		Serial.println(F("No SD card."));
	}
	else
	{
		Serial.print(F("Card Capacity: "));
		Serial.print(SD.card()->cardCapacity());
		Serial.println(F(" 512 byte clusters"));
	}
	byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};

	Ethernet.begin(mac, ip);

	switch (Ethernet.hardwareStatus())
	{
	case EthernetNoHardware:
		Serial.println(F("No Ethernet hardware"));
		break;

	case EthernetW5100:
		Serial.println(F("5100"));
		break;
	case EthernetW5200:
		Serial.println(F("5200"));
		break;
	case EthernetW5500:
		Serial.println(F("5500"));
		break;
	}


	switch (Ethernet.linkStatus())
	{
	case Unknown:
		Serial.println(F("Ethernet link unknown state"));
		break;

	case LinkON:
		Serial.println(F("Ethernet link ON"));
		break;

	case LinkOFF:
		Serial.println(F("Ethernet link OFF"));
		break;
	}

#ifndef HARDWARE_TEST
	if (!web.begin())
	{
		Serial.println(F("Can't start web server"));
	}
	else
	{
		Serial.println(F("Web server started"));
	}
#endif
}

// the loop function runs over and over again until power down or reset
void loop() 
{
#ifndef HARDWARE_TEST
	web.ServiceWebServer();
#endif

}

this SD card adapter doen't work with other SPI devices.

this SD card adapter doen't work with other SPI devices.

There are tutorials on the web about how to fix it if you're an experienced solderer. The components are OK, the PCB wiring is wrong.

Well, bummer. At least I know now to stop chasing this problem.

Any recommendations for an SD card reader that does work?

MHotchin:
Well, bummer. At least I know now to stop chasing this problem.

Any recommendations for an SD card reader that does work?

Adafruit

Here's a thread on the hardware mod to get these SD card readers to play nice with the other children:

SD Reader modification

Also, SdFat supports software SPI, so you do that for the SD reader, and use 'real' SPI for everything else.