Questions about using data pattern command values defined in RFID RC522

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Questions about using data pattern command values defined in RFID RC522

Jump to solution
1,405 Views
hhh_hy
Contributor II

A question arose in the process of reading card information by applying the RFID RC522 module to a beaglebone board, not an Arduino.

First, codes such as initializing the RFID RC522 module, checking whether a taggable card exists, and reading card UID information were written.

At this time, each data was read into tx_data using the unique data pattern values (0x0F, 0x52, 0x93) of RFID RC522.

Can you get the information you want using the data pattern command values mentioned above?

 

// MFRC522 initialize
void MFRC522Init() {
uint8_t tx_data[] = {0x0F}; // Data value for sending softreset command to MFRC522
uint8_t rx_data[sizeof(tx_data)];
if (SpiTransfer(tx_data, rx_data, sizeof(tx_data)) < 0) {
printf("Failed to send SPI message\n");
return;
}
usleep(5000); // wait a while
}

 

// Check if the card exists
int PiccIsNewCardPresent() {
uint8_t tx_data[] = {0x52}; // Data pattern value for transmitting the corresponding function to MFRC522, 0x52 : find all the cards antenna area
uint8_t rx_data[sizeof(tx_data)];
memset(rx_data, 0, sizeof(rx_data));
if (SpiTransfer(tx_data, rx_data, sizeof(tx_data)) < 0) { // To determine whether card existence cannot be confirmed when SPI communication fails.
printf("Failed to transfer data\n");
return -1;
}
return rx_data[1];
}

 

// Read card UID information
int PiccReadCardSerial(uint8_t* uid) {
uint8_t tx_data[] = {0x93}; // Data pattern value for transmitting the corresponding function to MFRC522, 0x93 : election card
uint8_t rx_data[sizeof(tx_data)];
memset(rx_data, 0, sizeof(rx_data));
if (SpiTransfer(tx_data, rx_data, sizeof(tx_data)) < 0) {
printf("Failed to transfer data\n");
return -1;
}
memcpy(uid, &rx_data[1], 4);
return 0;
}

Tags (2)
0 Kudos
Reply
1 Solution
1,397 Views
giraffe508
Contributor IV

Hi @hhh_hy Yes, you can get the information you want using the data pattern command values mentioned above. The data pattern values (0x0F, 0x52, 0x93) are used to send specific commands to the RFID RC522 module. Here's a brief explanation of each command:

  • 0x0F (Soft Reset): This command is used to reset the MFRC522 module. It initializes the module and prepares it for further communication.
  • 0x52 (Find All Cards): This command is used to check if there are any cards present in the antenna area. If a card is detected, the module will return a response indicating the presence of the card.
  • 0x93 (Election Card): This command is used to read the UID (Unique Identifier) of the detected card. The module will return the UID of the card in the response.

The code snippets you provided are using these data pattern command values correctly. The functions MFRC522Init(), PiccIsNewCardPresent(), and PiccReadCardSerial() are sending the respective commands to the RFID RC522 module and processing the responses accordingly.

As long as the SPI communication between the BeagleBone board and the RFID RC522 module is working correctly, you should be able to get the desired information (card presence and UID) using these data pattern command values.

Kind Regards, 

View solution in original post

3 Replies
1,375 Views
sotajoh552
Contributor I

This project interfaces the MFRC522 RC522 RFID reader with Arduino and reads NUIDs of MIFARE-compatible cards and key fobs. We also demonstrate a simple ... New Subway Menu and its prices

0 Kudos
Reply
1,398 Views
giraffe508
Contributor IV

Hi @hhh_hy Yes, you can get the information you want using the data pattern command values mentioned above. The data pattern values (0x0F, 0x52, 0x93) are used to send specific commands to the RFID RC522 module. Here's a brief explanation of each command:

  • 0x0F (Soft Reset): This command is used to reset the MFRC522 module. It initializes the module and prepares it for further communication.
  • 0x52 (Find All Cards): This command is used to check if there are any cards present in the antenna area. If a card is detected, the module will return a response indicating the presence of the card.
  • 0x93 (Election Card): This command is used to read the UID (Unique Identifier) of the detected card. The module will return the UID of the card in the response.

The code snippets you provided are using these data pattern command values correctly. The functions MFRC522Init(), PiccIsNewCardPresent(), and PiccReadCardSerial() are sending the respective commands to the RFID RC522 module and processing the responses accordingly.

As long as the SPI communication between the BeagleBone board and the RFID RC522 module is working correctly, you should be able to get the desired information (card presence and UID) using these data pattern command values.

Kind Regards, 

1,327 Views
hhh_hy
Contributor II
Thank you very much.
0 Kudos
Reply