ljos/MFRC522

Arduino Leonardo Eth Problems

inu-web opened this issue · 7 comments

Hi, I already built successful solutions with unos and megas and your great library....
But now I got an arduino Leonardo ETH with integrated W5500 ethernet and I can not get it to work with the RC522 reader which Works fine with the UNO and the Standard-W5100 ethernetshield for example.
I also tried another board (http://tronixlabs.com/arduino/boards/ethernet/dfrobot-arduino-compatible-with-onboard-w5500-ethernet-and-poe-australia/) that seems to be somewhat similar.
Both boards Do Not recognize the RC522 reader during setup.
Even if I deactivate the CS from ethernet and SD, the reader can not be accessed.
There must be something general that Blocks the Icsp or so?
I have used the mosi, miso and sck from the 6 pin icsp header of the board because they do not have them on the GPIO Pins like the UNOs or Megas and also tried different Pins as the CS pin for the reader.
No success on getting the reader to respond.
Is there anything else I can try?
Thanks in advance and kind regards
Gerald

ljos commented

It says on the Leonardo ETH page that pin 10 is reserved for the Wiznet interface. I think you need to use a different SS pin.

Thanks for your reply
I already used the folllowing parts in my sketch to set SS to Pin 8 because of this fact, and also set Sd and Ethernet SS Pins to Output as I found in a topic in another place ...
But the "ReaderDetails" always shows "NFC Error" so it seems not to detect the reader via SPI (Version = FF or 00)

regards
Gerald

// SPI & RFID ----------
#include <SPI.h>
#include <MFRC522.h>
// ########## NFC Defs ##########
#define SS_PIN 8
#define RST_PIN 9

// NFC CREATE -------------
MFRC522 mfrc522(SS_PIN, RST_PIN); 

// setup
void setup() {
  // Open serial
  Serial.begin(9600);

  // CS-Lines for SD and Ethernet
   pinMode(4, OUTPUT);
   pinMode(10, OUTPUT);

    // RFID READER INIT -----
    SPI.begin();
    mfrc522.PCD_Init(); // Init RC522
    Serial.print(F("NFC:"));
    ShowReaderDetails(); // Show RC522 Card Reader details
}

// get details about RC522 hardware
void ShowReaderDetails() {
   // Get MFRC522 software version
   byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
   Serial.print(F("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("=v?.?"));
           Serial.println("");
          // When 0x00 or 0xFF is returned, communication probably failed
          if ((v == 0x00) || (v == 0xFF)) {
               Serial.println(F("NFC ERROR"));
      }
}
ljos commented

You don't seem to be using my library, but the miguelbalboa/rfid that mine is based on.

I am sorry, I used the library of miguelbalboa before and that doesnt work either
So i switched to your library ... why do you think I am using the other one?
Maybe I posted the wrong code ... I´ll try again by using your library when I am back at home ... so long
thanks for your help and sorry if I bothered you!
regards
Gerald

ljos commented

I didn't mean to be brash. It is no bother. The reason I think you are using miguelbalboas library is that you are calling mfrc522.PCD_Init(). PCD_Init is not a method in my library.

Also, for troubleshooting communication issues, a logic analyzer is a very helpful tool.
This one is relatively inexpensive and quite powerful. also the java software supports decoding of common protocols.
http://www.seeedstudio.com/depot/Open-Workbench-Logic-Sniffer-p-612.html

hook up any analyzer to your lines and verify you are getting the appropriate responses expected from the MFRC522 datasheet.

Thanks a lot for your suggestions, I have an arduino based logic analyzer and already did some SPI-sniffing, but got stuck because of my lack of understanding the protocol.
I have to investigate a little more and also I have to test again with your library - have scrambled up my tests al ittle bit.
Sorry again for opening the issue here! Your help is highly appreciated.
Gerald