Datasheet
2. UIFlow
After opening and burning this example using UIFlow, place the proximity card on the Unit surface and
the screen displays “True” and the UID number of the card.
/*
RFID.ino
*/
#include <Wire.h>
#include "MFRC522_I2C.h"
#include <M5Stack.h>
// 0x28 is i2c address on SDA. Check your address with i2cscanner if not match.
MFRC522 mfrc522(0x28); // Create MFRC522 instance.
// initialization
M5.begin(); Serial.begin(115200); Wire.begin();
/* Init MFRC522 */
mfrc522.PCD_Init();
/* Show details of PCD - MFRC522 Card Reader details */
ShowReaderDetails();
mfrc522.PICC_ReadCardSerial();// read data
// a new card is selected. The UID and SAK is saved at mfrc522.uid structor.
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
// other function
void ShowReaderDetails() {
/* Get the MFRC522 software version */
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
if (v == 0x91) Serial.print(F(" = v1.0"));
else if (v == 0x92) Serial.print(F(" = v2.0"));
else Serial.print(F(" (unknown)"));
}
M5Stack Docs
// get the uid of available card
mfrc522.PICC_IsNewCardPresent();// scan for a new card