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