I purchased the RC522 RFID reader from Amazon. I connected the pins as per the table given. I used the dumpinfo example. It does not read the tag information and the output got is shown here. I used the RFID tags supplied along with the reader. Why is it not working?
#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
delay(4); // Optional delay. Some board do need more time after init to be ready, see Readme
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
//mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
}
void loop() {
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
//Serial.println("A");
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
Serial.println("B");
return;
}
// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
When I traced the program, I came to know that the if condition for "Select one of the cards" is not all executed even if the tag is brought near to the reader.
I get the output in the serial monitor as
Firmware Version: 0x92 = v2.0
Scan PICC to see UID, SAK, type, and data blocks...
So, I think the reader reads something.
I think pins 9, 10 are used properly.
How to know that MISO & MOSI and other pins are properly configured in the code given? The code is available in the dumpinfo example .