wiz W5100 + RFID-RC522

Hi!!!

I am trying connect wiz w5100 and RFID-RC522. But I have conflict with spi. My rfid doesn't work with ethernet. Problem with MISO.

wiz w5100 i use something like this http://www.wiznet.co.kr/product-item/wiz810mj/
i connected w5100 to icsp on arduino

i tried turn off ss, but it doesn't work((( Or maybe i need buy just ethernet shield and i will happy?)

Please please help me)))

my part of code:

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

#define RST_PIN        5           // Configurable, see typical pin layout above
#define SS_1_PIN        33          // Configurable, see typical pin layout above
#define SS_2_PIN        41          // Configurable, see typical pin layout above
#define SS_3_PIN        10

#define NR_OF_READERS   2
uint8_t nummerR1 = 0;
uint8_t nummerR2 = 1;

byte ssPins[] = {SS_1_PIN, SS_2_PIN};

MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.

IPAddress ip(10,0,77,55);
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // RESERVED MAC ADDRESS
//byte ip[] = { 10, 0, 77, 55 };
byte server[] = { 10, 0, 77, 2 };
String data;
EthernetClient client;
/**
 * Initialize.
 */
void setup() {
   // disable w5100 SPI
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  
  delay(1000);
  
  Serial.begin(9600);
   // Initialize serial communications with the PC
   while (!Serial);

  SPI.begin();      // Init SPI bus

   rfidvinnii();
  
 // start the Ethernet connection:
  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);
    Serial.println("GOOOD");
  }

  // Imprime la direccion IP de la tarjeta
  Serial.print("Direccion IP: ");
  Serial.println(Ethernet.localIP());
  
  
}


void loop() {

 
   if(!client.connected()) {
   
    for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    
    // Look for new cards
     
    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
      Serial.print(F("Reader: "));
      Serial.print(reader);
      // Show some details of the PICC (that is: the tag/card)
      Serial.print(F(" Card UID:"));
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();
      Serial.print(F("PICC type: "));
      MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
      Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();

      //selectEthernet();
     // ethernetmy("vfftg");
      //rfidvinnii();
    } 
  } 
   }

}

void rfidvinnii(){

  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {

    selectRC522(reader);
    //delay(1000);

    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
  // Get the MFRC522 software version
  delay(100);
  byte v = mfrc522[reader].PCD_ReadRegister(mfrc522[reader].VersionReg);
  Serial.print(reader);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
  else
    Serial.print(F(" (unknown)"));
  Serial.println("");
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
    
  }

  }
  
}

Anybody?)

But I have conflict with spi.

What conflict?

My rfid doesn't work with ethernet. Problem with MISO.

What problem?

The code you posted does something. You expect it to do something. All we can tell, so far, is that the two somethings are not the same thing.

Doi you have a SD card in the shield's slot? That will interfere with the MISO line if not disabled. Just a thought...

There may also be a conflict with the SPI settings. There are 4 SPI modes and a few different speeds and bit order settings.

PaulS,

Conflict is w5100 and RFID-RC522 don't work together((( When i connect rfids(miso 50, sck 52, mosi 51, ss1 33, ss2 41, rst 5) and wz5100 (miso 50, sck 52, mosi 51, ss 10).

But when i disconnect miso from wz5100, my rfids works.

Maybe i said something wrong. Sorry, i'm new in arduino. I saw many prints where people connect rfid + ethernet schield together and they work. ethrnet shield has same chip w5100.

SurferTim,

in library ethernet i found

#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)

rfid

SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));

or i need something different look?

what i need write in google?))))

Before you initialize the ethernet, you should disable the slave select pin on the nRF24 RC522 by setting its SS as OUTPUT and HIGH, or it could affect the Ethernet.begin() call.

I always recommend disabling all SPI devices by setting ALL the SS pins as OUTPUT (except the Due) and HIGH .

SurferTim:
Before you initialize the ethernet, you should disable the slave select pin on the nRF24 RC522 by setting its SS as OUTPUT and HIGH, or it could affect the Ethernet.begin() call.

I always recommend disabling all SPI devices by setting ALL the SS pins as OUTPUT (except the Due) and HIGH .

I made mistake, i can turn on w5100 with rc255, but rcc255 with w5100 i can't

Yes, i did it))) but it's not work(((
In one moment i can see my rc522. I turned off pin 10 and it's work until when i start CLIENT. client. stop + turn off pin 10 after. but then i can't initialize my rc522 again. This moment was when my w5100 was connected to 3.3v.

After i saw icsp in my arduino mega. I thought maybe i have to different miso on board. on icsp and pin 50. but i was wrong(((

Now i returned all spi of w5100 to 50, 51, 52. But i don't change power. Now it's work on 5v.

Thank you guys for your answers. I appreciated this.

SurferTim wrote

"There may also be a conflict with the SPI settings. There are 4 SPI modes and a few different speeds and bit order settings."

Can i something make with it???

P.S. i don't have a SD card.

example i connected two rc255 and w5100.

this cod don't work. But when i disconnected miso from ethernet it works

/**
 * ----------------------------------------------------------------------------
 * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
 * for further details and other examples.
 *
 * NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
 *
 * Released into the public domain.
 * ----------------------------------------------------------------------------
 * This sample shows how to read and write data blocks on a MIFARE Classic PICC
 * (= card/tag).
 *
 * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7).
 *
 *
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS 1    SDA(SS)      10            53        D10        10               10
 * SPI SS 2    SDA(SS)      2             53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 *
 */

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



#define RST_PIN        5           // Configurable, see typical pin layout above
#define SS_1_PIN        33          // Configurable, see typical pin layout above
#define SS_2_PIN        41          // Configurable, see typical pin layout above
#define SS_3_PIN        10

#define NR_OF_READERS   2

byte ssPins[] = {SS_1_PIN, SS_2_PIN};

MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.

/**
 * Initialize.
 */
void setup() {

// disable w5100 SPI
  pinMode(10, OUTPUT);
 digitalWrite(10, HIGH);
  Serial.begin(9600); // Initialize serial communications with the PC
  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

  SPI.begin();        // Init SPI bus

  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
  }
}

/**
 * Main loop.
 */
void loop() {

    for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    // Look for new cards

    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
      Serial.print(F("Reader: "));
      Serial.print(reader);
      // Show some details of the PICC (that is: the tag/card)
      Serial.print(F(" Card UID:"));
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();
      Serial.print(F("PICC type: "));
      MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
      Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}

/**
 * Helper routine to dump a byte array as hex values to Serial.
 */
void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

Are you certain you have the w5100 module SS connected to D10?

100% it's 10. and in library wrote 10)

Have you tried just the w5100 module by itself? Does it work?

Yes it works perfect. and it works with rc522. But rc522 don't work with w5100((( i can't program turn off w5100

held:
Yes it works perfect. and it works with rc522. But rc522 don't work with w5100((( i can't program turn off w5100

Has this been sorted as I am having the same problem.
Noted on the internet that w5100 keeps its MISO pin high and this is the problem connecting the 2 devices rc522 and w5100

Problem is quite simple, W5100 module is talking in MISO line even if his CS is HIGH. It can be solved using 3 state buffer in MISO line, idealy for each SPI device. I use 74HC125 (4 chanel 3 state buffer) and than work RC522 and W5100 module perfect. See this link: https://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps
Enjoy