# Beginner Problems RFID RC522

**URL:** <https://forum.arduino.cc/t/beginner-problems-rfid-rc522/292662>\
**Category:** Programming\
**Created:** [February 24, 2015, 4:41pm UTC](https://forum.arduino.cc/t/beginner-problems-rfid-rc522/292662 "2015-02-24T16:41:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 24, 2015, 4:41pm UTC](https://forum.arduino.cc/t/beginner-problems-rfid-rc522/292662/1 "2015-02-24T16:41:36Z")

</div>

Dear Forum Members,

I'm new with arduino and working with the RC522 and code of miguelbalboa form github. I was experimenting with the code and the last code before i was getting a error "PCD\_Authenticatie Failed..." was:

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

#define SS_PIN 10    //Arduino Uno
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.

void setup() {
        Serial.begin(9600);        // Initialize serial communications with the PC
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        Serial.println(F("Write personal data on a MIFARE PICC "));
}

void loop() {
        
        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;
        
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial())    return;
        
        Serial.print(F("Card UID:"));    //Dump 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.print(F(" PICC type: "));   // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        Serial.println(mfrc522.PICC_GetTypeName(piccType));
         
        byte buffer[34];  
        byte block;
        byte status, len;
        
        Serial.setTimeout(20000L) ;     // wait until 20 seconds for input from serial
        // Ask personal data: Family name
        Serial.println(F("Type Family name, ending with #"));
        len=Serial.readBytesUntil('#', (char *) buffer, 30) ; // read family name from serial
        for (byte i = len; i < 30; i++) buffer[i] = '\s';     // pad with spaces

        block = 2;
        //Serial.println(F("Authenticating using key A..."));
        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid));
        if (status != MFRC522::STATUS_OK) {
           Serial.print(F("PCD_Authenticate() failed: "));
           Serial.println(mfrc522.GetStatusCodeName(status));
           return;
        }
        
        // Write block
	status = mfrc522.MIFARE_Write(block, &buffer[16], 16);
	if (status != MFRC522::STATUS_OK) {
	    Serial.print(F("MIFARE_Write() failed: "));
	    Serial.println(mfrc522.GetStatusCodeName(status));
            return;
	}
        else Serial.println(F("MIFARE_Write() success: "));

     
        Serial.println(" ");
        mfrc522.PICC_HaltA(); // Halt PICC
        mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
       
}

```

My card won't able anymore to authenticate with any code or divice. I think i write block 0 because if i read the full card with dumpinfo the block 0 Failed. please help my to reset of fix the card. Thank you for helping!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 9:08pm UTC](https://forum.arduino.cc/t/beginner-problems-rfid-rc522/292662/2 "2021-05-05T21:08:50Z")

</div>

Closed on May 5, 2021, 9:08pm UTC


