Ethernet Shield and MFRC522 RFID - sharing pins causing error?

Hi all, I have an Ethernet shield and RFID reader connected to my UNO. My plan is to read the tags and send this information to a server. Currently I am facing the issue where one or the other component fails. When both are connected, the Ethernet shield will not connect and my code prints out this to the Serial Monitor:

Failed to configure Ethernet using DHCP
connecting…
connection failed

From my understanding this is likely because the pins 10-13 are shared by both components. How do I work around this? I’ve included below a link to the RFID library I’m using. The SPI and Ethernet libraries are the default Arduino ones. I’ve also included a circuit diagram and my sketch. Let me know if any other details are needed.

Library

#include <SPI.h>
#include <MFRC522.h>
#include <Ethernet.h>
 
#define SS_PIN 10
#define RST_PIN 9
#define BLUE 3
#define GREEN 5
#define RED 6
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.google.com";
IPAddress ip(86, 184, 148, 1);
EthernetClient client;
 
void setup() {
  // LED Setup
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  lightYellow();
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println();

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void lightRed() {
  analogWrite(RED, 255);
  analogWrite(GREEN, 0);
  analogWrite(BLUE, 0);
}

void lightGreen() {
  analogWrite(RED, 0);
  analogWrite(GREEN, 255);
  analogWrite(BLUE, 0);
}

void lightYellow() {
  analogWrite(RED, 225);
  analogWrite(GREEN, 180);
  analogWrite(BLUE, 0);
}

void loop() {
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }

  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "CA A6 CB 73") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
    lightGreen();
    delay(3000);
    lightYellow();
  }
 
 else   {
    Serial.println(" Access denied");
    lightRed();
    delay(3000);
    lightYellow();
  }
}

Zakoth: From my understanding this is likely because the pins 10-13 are shared by both components.

Close. Pins 11-13 on the Uno are the SPI bus. You can connect many devices to the SPI bus. The limitation is that each SPI device must have a separate SS pin. You are using pin 10 as the SS pin of both the MRRC522 and the Ethernet shield. That won't work. Since it would be difficult to change the SS pin of the Ethernet shield, I recommend you to connect the SS pin of the MFRC522 to any other unused pin, then change this line of your sketch accordingly:

#define SS_PIN 10

pert:
Close. Pins 11-13 on the Uno are the SPI bus. You can connect many devices to the SPI bus. The limitation is that each SPI device must have a separate SS pin. You are using pin 10 as the SS pin of both the MRRC522 and the Ethernet shield. That won’t work. Since it would be difficult to change the SS pin of the Ethernet shield, I recommend you to connect the SS pin of the MFRC522 to any other unused pin, then change this line of your sketch accordingly:

#define SS_PIN 10

Thank you! Can’t believe the solution was so simple.

You're welcome. I'm glad if I was able to be of assistance. Enjoy! Per