OSSLibraries / Arduino_MFRC522v2

Home Page:https://osslibraries.github.io/Arduino_MFRC522v2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Communication failure with MFRC522v2, but the original MFRC522 had no such issues

arseni-mourzenko opened this issue · comments

I'm trying to read Mifare Classic 1K cards using Seeeduino Lotus. It works with the original https://github.com/miguelbalboa/rfid library, detecting the card and showing its UID.

However, when I try MFRC522v2 version 2.0.4 and use the sample code from the documentation, it shows:

= (unknown)
WARNING: Communication failure, is the MFRC522 properly connected?
Scan PICC to see UID, SAK, type, and data blocks...

Note that the wiring is exactly the same in both cases, with the default pins being used, as specified in the documentation. If I upload back the original sketch, it works.

I noticed that the example from the original MFRC522 library specifies both the SPI SS pin and the reset pin like this:

#define RST_PIN 9
#define SS_PIN 10

however the example from has only the SS pin specified:

MFRC522DriverPinSimple ss_pin(10);

Is this the issue? How do I tell what's the reset pin?

Hi,

it seems that using hardware reset line appears useless to devs as you can read in the source comments:

// So far just using software based reset had no disadvantage so skip any reset pin related code.

From my own experience, there should be a hardware reset line management for 2 main reasons :

  • give the ability to place the chip in low power mode (a must have in battery powered project)
  • soft reset is sometime useless when the micro-controller have been restarted without power-loss. (the chip seems to be stuck in an incorrect state)
    I.e :
    -> watchdog timeout
    -> program failure
    -> on purpose restart with ESP.restart()
    -> board reset button pressed

I strongly suggest you to implement this on your own as it's just a matter of pulling reset pin down then up with a short delay in between.

byte _resetPowerDownPin = GPIO_NUM_XXX

void setup()
{
...
pinMode(_resetPowerDownPin, OUTPUT);
...
}

void PCD_Powerdown()
{
	digitalWrite(_resetPowerDownPin, LOW);
}

void PCD_PowerUp()
{
	digitalWrite(_resetPowerDownPin, HIGH);
}

void PCD_HardReset()
{
 	digitalWrite(_resetPowerDownPin, LOW);
 	delayMicroseconds(2);   //In order to perform a reset, the signal must be LOW for at least 100 ns => 2us is more than enough
	digitalWrite(_resetPowerDownPin, HIGH);
 	delay(50);
}

I personnally trigger a hardreset every time the microcontroller starts to ensure the chip is always properly working.

Few things to keep in mind after sending a hard reset :

  • all configuration is cleared so you'll have to redo the Init procedure
  • as stated in the documentation:
      During a hard power-down (using pin NRSTPD), the 25 bytes in the internal buffer remain
      unchanged and are only lost if the power supply is removed from the MFRC522.

I didn't do much research on that but it might be a good idea to check how to clear the internal buffer.

Regards

P.S. I hope I'm clear (sorry for my English ;) )