RFID-Card: Print only Card-UID

Hello guys,

I've got a problem I can't solve. :confused:

I connected a RFID-reader with Arduino Nano, so I can read the Cards UID with the Serial Monitor.

My code:

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

#define SS_PIN 10
#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("Scan PICC to see UID and type...");
}

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));
}

The output on the serial monitor with the code above looks like:

Scan PICC to see UID and type...
Card UID: 1B F0 76 41
Card SAK: 08
PICC type: MIFARE 1KB
Sector Block 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 AccessBits
15 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
14 59 PCD_Authenticate() failed: Timeout in communication.
13 55 PCD_Authenticate() failed: Timeout in communication.
12 51 PCD_Authenticate() failed: Timeout in communication.
etc.

The problem now is, that I only need the Card UID to be outputed. I thought about string-functions, but I don't know how exactly they work or if the problem can even be solved using them.
Moreover it would be very good if the problem got solved today. :frowning:

P.S.:
There are more cards, so I can't output a given code. I need to take the code which the RFID-card has.

I would really appreciate it if anyone could help me.

Thx a lot! :slight_smile:

The problem now is, that I only need the Card UID to be outputed.

Why is that a problem?

Some function is printing the output that you see. It isn't rocket science to figure out which one, and stop calling it.

Once you've done that, it is not difficult to examine the MFRC522 header file, and see how the data that you want is stored in the mfrc522 instance - in particular the uid value that is passed to the function that currently does the printing.

It is then not at all difficult to print the uid value. Hell, you could just copy the code from the PICC_DumpToSerial() method, and be done in 3 minutes.