# RFID reader MFRC-522 - UID vs PICC

**URL:** <https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212>\
**Category:** Sensors\
**Created:** [October 3, 2014, 3:28pm UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212 "2014-10-03T15:28:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin159](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@martin159](https://forum.arduino.cc/u/martin159)\
**Post date:** [October 3, 2014, 3:28pm UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/1 "2014-10-03T15:28:30Z")

</div>

Hi I have cheap 13.56MHz RFID reader from eBay [http://www.ebay.com/itm/271425698949](http://www.ebay.com/itm/271425698949).

I have one chip and one card (supplied with reader). I need to read unique card id and send it to PC over Serial port.

I use these program from github:

```plaintext
/*
 * Dump block 0 of a MIFARE RFID card using a RFID-RC522 reader
 * Uses MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT. 
 ----------------------------------------------------------------------------- 
 * Pin layout should be as follows:
 * Signal    Pin              Pin              Pin
 *            Arduino Uno      Arduino Mega      MFRC522 board
 * ------------------------------------------------------------
 * Reset      9                5                RST
 * SPI SS    10              53                SDA
 * SPI MOSI  11              52                MOSI
 * SPI MISO  12              51                MISO
 * SPI SCK    13              50                SCK
 *
 * Hardware required:
 * Arduino
 * PCD (Proximity Coupling Device): NXP MFRC522 Contactless Reader IC
 * PICC (Proximity Integrated Circuit Card): A card or tag using the ISO 14443A interface, eg Mifare or NTAG203.
 * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on ebay.com. 
 */

#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("Print block 0 of 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("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(" PICC type: ");  // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        Serial.println(mfrc522.PICC_GetTypeName(piccType));
         
        byte buffer[18];  
        byte block  = 0;
        byte status;
        //Serial.println("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("PCD_Authenticate() failed: ");
          Serial.println(mfrc522.GetStatusCodeName(status));
          return;
        }
        
        // Read block
	byte byteCount = sizeof(buffer);
	status = mfrc522.MIFARE_Read(block, buffer, &byteCount);
	if (status != MFRC522::STATUS_OK) {
	    Serial.print("MIFARE_Read() failed: ");
	    Serial.println(mfrc522.GetStatusCodeName(status));
	}
        else  // Dump data
	for (byte index = 0; index < 16; index++) {
	    Serial.print(buffer[index] < 0x10 ? " 0" : " ");
	    Serial.print(buffer[index], HEX);
	    if ((index % 4) == 3) Serial.print(" ");
	}
        Serial.println(" ");
        mfrc522.PICC_HaltA(); // Halt PICC
        mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
       
}

```

After I put card and chip to reader I see in putty:

```plaintext
Print block 0 of a MIFARE PICC
Card UID: 05 88 72 45 PICC type: MIFARE 1KB
 05 88 72 45  BA 08 04 00  62 63 64 65  66 67 68 69
Card UID: 64 24 95 5B PICC type: MIFARE 1KB
 64 24 95 5B  8E 08 04 00  62 63 64 65  66 67 68 69

```

So there is my question. What is unique ID? UID, or PICC?

---

<div class="post-metadata">

**Author:** ![omersiar](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@omersiar](https://forum.arduino.cc/u/omersiar)\
**Post date:** [October 3, 2014, 7:46pm UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/2 "2014-10-03T19:46:24Z")

</div>

UID = Unique ID  
PICC = short for Proximity Integrated Circuit Card (RFID Tag itself) actually your code header explains this.

1 Kb Tags can hold data up to about 1 Kb exact usable space less because of UID. UID generally can be 4 byte or 7 byte, maybe more. If you just want print scanned tag's (PICC's) UID on serial you can use like this

```cpp
for (int i = 0; i < mfrc522.uid.size; i++) {  // for size of uid.size write uid.uidByte to readCard
    readCard[i] = mfrc522.uid.uidByte[i];
    Serial.print(readCard[i], HEX);
}

```

---

<div class="post-metadata">

**Author:** ![VeggieVampire](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/veggievampire/32/835358_2.png) [@VeggieVampire](https://forum.arduino.cc/u/VeggieVampire)\
**Post date:** [November 8, 2015, 1:41am UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/3 "2015-11-08T01:41:22Z")

</div>

Can you paste the whole code? please

---

<div class="post-metadata">

**Author:** ![dalmirdasilva](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@dalmirdasilva](https://forum.arduino.cc/u/dalmirdasilva)\
**Post date:** [November 14, 2016, 11:56pm UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/4 "2016-11-14T23:56:29Z")

</div>

Dear, omersiar

The tag's UID in your case is "05 88 72 45" for the 1st tag you read, and "64 24 95 5B" for the 2nd. That is because MIFARE 1KB has 4 bytes-long UIDs.

If you still are interested of this reader, I've done this library: [GitHub - dalmirdasilva/ArduinoRadioFrequencyIdentification: Arduino Radio-frequency identification](https://github.com/dalmirdasilva/ArduinoRadioFrequencyIdentification)

There are a bunch of examples you can use.

---

<div class="post-metadata">

**Author:** ![mehrdadshokohy](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@mehrdadshokohy](https://forum.arduino.cc/u/mehrdadshokohy)\
**Post date:** [January 26, 2017, 2:37pm UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/5 "2017-01-26T14:37:42Z")

</div>

hi  
i have two device for read ID from RFID tag  
1.Arduino Mega R3

2.RFID USB reader  
Detail Info:  
[https://www.aliexpress.com/item/New-Version-13-56MHz-RFID-Reader-USB-Proximity-Sensor-Smart-Card-NFC-Reader-Variety-Format-No/32613760414.html?spm=2114.40010208.4.36.oWtTdh](https://www.aliexpress.com/item/New-Version-13-56MHz-RFID-Reader-USB-Proximity-Sensor-Smart-Card-NFC-Reader-Variety-Format-No/32613760414.html?spm=2114.40010208.4.36.oWtTdh)  
(in This page has been said that it Read:First 10 digists of the RFID IC card (Factory original format)

Arduino detect tag and show uid: 193 207 40 13  
but usb RFID reader Show 0220778433  
how can edit Arduino code to show uid like usb reader?

---

<div class="post-metadata">

**Author:** ![anughosh975](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@anughosh975](https://forum.arduino.cc/u/anughosh975)\
**Post date:** [March 27, 2019, 5:50am UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/6 "2019-03-27T05:50:35Z")

</div>

Hello,

I have uno+wifi r3 atmega328p+esp8266 board  
RFID Reader MFRC522

And I am trying for below simple code but m getting no output of it

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

#define RST\_PIN 9 // Configurable, see typical pin layout above  
#define SS\_PIN 10 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS\_PIN, RST\_PIN); // Create MFRC522 instance

void setup() {  
Serial.begin(9600); // Initialize serial communications with the PC  
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)  
SPI.begin(); // Init SPI bus  
mfrc522.PCD\_Init(); // Init MFRC522  
mfrc522.PCD\_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details  
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));  
}

void loop() {  
// Look for new cards  
if ( ! mfrc522.PICC\_IsNewCardPresent()) {  
return;  
}

// Select one of the cards  
if ( ! mfrc522.PICC\_ReadCardSerial()) {  
return;  
}

// Dump debug info about the card; PICC\_HaltA() is automatically called  
mfrc522.PICC\_DumpToSerial(&(mfrc522.uid));  
}

wiring connection:

10 - SDA

13 - SCK

11 - MOSI

12 - MISO

UNUSED - IRQ  
GND - GND  
9 - RST  
3.3V - 3.3V

Please help me with this situation

---

<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 6, 2021, 10:06am UTC](https://forum.arduino.cc/t/rfid-reader-mfrc-522-uid-vs-picc/261212/7 "2021-05-06T10:06:37Z")

</div>


