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...
#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.
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.).
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.