miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.75k stars 1.43k forks source link

[esp8266] No tag detection after long run time #309

Closed PudgeMa closed 7 years ago

PudgeMa commented 7 years ago

Hello. when I use your library in esp8266, it can work, but if it run a long time, it can't find card.

if I rest(soft rest) mfrc522 repeadly every 30 sec, it work well.

do you have any idea about this? Thanks.

Rotzbua commented 7 years ago

Please add information for people who want to reproduce your issue:

omersiar commented 7 years ago

I can confirm this, i believe this is something about polling SPI bus too much. Reducing

if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }

polling intervals not completely solves the problem but reduces soft resets. We need ESP SPI specifics.

omersiar commented 7 years ago
//If a new PICC placed to RFID reader continue
if ( ! mfrc522.PICC_IsNewCardPresent()) {
  delay(50);
  return;
}
//Since a PICC placed get Serial (UID) and continue
if ( ! mfrc522.PICC_ReadCardSerial()) {
  delay(50);
  return;
}

I made some testings, 50ms delay is enough. My esp never resetted for days.

PudgeMa commented 7 years ago

thanks for your help, I final find the reason is I use two power for esp and mfrc522, and not put thier GND together. the delay is also neccessary.