miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.79k stars 1.45k forks source link

RC522 reader not reading all RFID cards #496

Closed sslohara closed 4 years ago

sslohara commented 5 years ago

Step 1: Describe your environment

Step 2: Describe the problem

Unable to read all cards. Only one card is working. Rest I purchased 10 cards, none of these working

Relevant Code:

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

#define SS_PIN   D4
#define RST_PIN  D2
#define GREEN_LED D0
#define BUZZER    D1

MFRC522 mfrc522(SS_PIN, RST_PIN); // Instance of the class
void setup() {
   Serial.begin(9600);
   SPI.begin();       // Init SPI bus
   mfrc522.PCD_Init(); // Init MFRC522
   Serial.println("RFID reading UID");
   pinMode(GREEN_LED, OUTPUT);
   pinMode(BUZZER, OUTPUT);
}
void loop() {
if ( mfrc522.PICC_IsNewCardPresent())
    {
        if ( mfrc522.PICC_ReadCardSerial())
        {
           Serial.print("Tag 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.println();
            digitalWrite(GREEN_LED, HIGH);
            tone(BUZZER, 2000);
            delay(800);
            noTone(BUZZER);
            digitalWrite(GREEN_LED, LOW);
            mfrc522.PICC_HaltA();
        }
}
}

Wiring: 3.3 V -> 3.3 V RST -> 9 GND -> GND

MISO -> 12 MOSI -> 11 SCK -> 13 SDA -> 10

Rotzbua commented 4 years ago

@sslohara Any update? Otherwise I close this.

omersavas26 commented 4 years ago

https://www.eluke.nl/2018/03/08/fixed-rc522-rfid-reader-not-reading-some-cards-part-1/