Ethernet + 2 SPI devices


I have a problem with my Arduino uno R3.I want put one Ethernet shield and 2 RC522 ( )

When I put one RC522 without Ethernet, it works perfectly but when I connect the Ethernet, the both doen't work. How can I connect another SPI devices when I have the Ehernet shield conected? Thank's!

You must insure that only one SPI device is active at a time. The way I get them to work is connect the hardware and test each device with the other device disabled.

If you have each device on its own slave select, then try this with the working RC522 code and the ethernet shield connected. I disabled the SD SPI also so if you have a card in the SD slot, it won't interfere with the RC522.

void setup() {

    // disable SD SPI
    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);

    // disable w5100 SPI
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);

    // rest of your setup

Does your RC522 work with this setup?

it works but I want to read a card and after send it via Ethernet.How can I do this?

adilutan: it works but I want to read a card and after send it via Ethernet.How can I do this?

Not a problem. I am doing this now with the w5100 and the SD, but the theory is the same. What pins are you using for the RC522 slave selects?

I resolved the problem.Thank you! I use 7 for SS.

Hello my friend!

I’m currently at the same boat you were before the solution. My problem is that I have just one SPI device ( 1 RC522) and I need to send it through ethernet shield. How did you resolved this issue ? I would really appreciate your help! Tks in Advance,

Same as above. Use a slave select for the RC522 that is not D10 or D4. The solution for adilutan was using D7.


I have a similar problem with the same configuration.
After reading this and similar threads, it was quite obvious that pins 4 and 10 can not be used.
Therefore I used pin 8 as SS pin for my RFID-RC522.

The problem is that if the memory card is inside, I would see any response on Serial monitor when RFID device is scanned, or there would be error message: “MIFARE_Read() failed: The CRC_A does not match.”

The code is following:

 * Dump block 0 of a MIFARE RFID card using a RFID-RC522 reader
 * Pin layout should be as follows:
 * Signal     Pin              Pin               Pin
 *            Arduino Uno      Arduino Mega      MFRC522 board
 * ------------------------------------------------------------
 * Reset      9                5                 RST
 * SPI SS     10               53                SDA
 * SPI MOSI   11               52                MOSI
 * SPI MISO   12               51                MISO
 * SPI SCK    13               50                SCK
 * Hardware required:
 * Arduino
 * PCD (Proximity Coupling Device): NXP MFRC522 Contactless Reader IC
 * PICC (Proximity Integrated Circuit Card): A card or tag using the ISO 14443A interface, eg Mifare or NTAG203.
 * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on 

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.

void setup() {
        Serial.begin(9600);        // Initialize serial communications with the PC
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        Serial.println("Print block 0 of a MIFARE PICC ");

void loop() {
        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial())    return;
        Serial.print("Card UID:");    //Dump UID
        for (byte i = 0; i < mfrc522.uid.size; i++) {
          Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
          Serial.print(mfrc522.uid.uidByte[i], HEX);
        Serial.print(" PICC type: ");   // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        byte buffer[18];  
        byte block  = 0;
        byte status;
        //Serial.println("Authenticating using key A...");
        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid));
        if (status != MFRC522::STATUS_OK) {
           Serial.print("PCD_Authenticate() failed: ");
        // Read block
 byte byteCount = sizeof(buffer);
 status = mfrc522.MIFARE_Read(block, buffer, &byteCount);
 if (status != MFRC522::STATUS_OK) {
    Serial.print("MIFARE_Read() failed: ");
        else  // Dump data
 for (byte index = 0; index < 16; index++) {
    Serial.print(buffer[index] < 0x10 ? " 0" : " ");
    Serial.print(buffer[index], HEX);
    if ((index % 4) == 3) Serial.print(" ");
        Serial.println(" ");
        mfrc522.PICC_HaltA(); // Halt PICC
        mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD

I have tried using other pins, but with no success. Without memory card everything works perfectly.

If SD SPI disabled, as SurferTim suggested, everything works…

If you have a SD card in the slot, you must disable it in setup before calling SPI.begin().


You will also need to make two minor mods to the SD library. I'll try to find those for you. Otherwise the SD card does not release the MISO line.

Will I be able to use SD card if I disable it first? Please do try to find the mods...

My plans are to make a RFID lock which logs users and allows access according to data on a website. :)

Yes, you can use the SD card. Just insure that all other SPI devices are initialized or the SPI slave select line is HIGH when you call SD.begin(). Calling SPI.begin() on an Uno will disable the w5100 (sets D10 as OUTPUT and HIGH) on the ethernet shield, so you don't have to do that one.

Here is a link to the fix that releases the MISO line on a SD card. I just modified the two files with the one line change each.

Hi , i've same problem , a wiz5200 and c522 in same device , but i understand that i must put one in d10 and one in d7 but other ? all same d11 d12 d13 ? both device has same pin , can someone explain a clear method , if not this posts can not useful .

thanks alex

All devices use the SPI data lines in common. On an Uno, those are D11, D12, and D13. All must have separate slave select lines. The wiznet w5200 slave select should be on D10. That library is the most difficult to change the slave select on, but it can be done. Use D8 and D9 for the others. If the w5200 has a SD card on it, that uses D4 for the slave select.

but my problem is on mfrc522 rfid and wiz5200 , is not possible put rc522 slave ? i think is more simple than network

my lan card :


has not sd

You have some pins on there that must be connected somewhere. The reset line must be HIGH and the pwdn line must be LOW.

Almost everything on the Arduinos is simpler than the w5200 and networks.

yes of course ;D ;D ;D

ok , i connect as usual w5200 and i will put in slave rid , with his library i can select this pin

/* Define the DIO used for the SDA (SS) and RST (reset) pins. */
#define SDA_DIO 10
#define RESET_DIO 9

/* Create an instance of the RFID library */

therefore i can not select other pin or not

Don't use D10 for the 522. That is the slave select for the w5200. It is difficult to change that.

ok and what can i do ? .. sorry but i ask a solution , 1 pin on 7 pins ? I don't know what i can do ...

there is an example ? ok i use for w5200 d10 d11 d12 d13 d09 , therefore with rc522 ??

Use D8 and D9.

/* Define the DIO used for the SDA (SS) and RST (reset) pins. */
#define SDA_DIO 8
#define RESET_DIO 9

Insure you set D8 (522 SS) as OUTPUT and HIGH before initializing the w5200.

my scheme now is this :

NANO | RC522 | W5200

3.3 3.3 3.3 (only 1 ) GND GND gnd (only 1) D12 - MISO D11 - MOSI D10 - NSS D13 - SCK RST - RST D9 RST - D8 SDA -