M5Stack - Simple Applications for RFID- Arduino

  • HI,
    I would like to connect a RFID reader to a M5Stack, I have a RC522 sensor witch is connected like this SDA to SDA, SCK to SCK, MOSI to MO, MI to MI, Reset to 1. I have this code:

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

    #define RST_PIN 1 //Pin 1 para el reset del RC522
    #define SS_PIN 21 //Pin 21 para el SS (SDA) del RC522
    MFRC522 mfrc522(SS_PIN, RST_PIN); //Creamos el objeto para el RC522

    void setup() {
    Serial.begin(9600); //Iniciamos la comunicación serial
    SPI.begin(); //Iniciamos el Bus SPI
    mfrc522.PCD_Init(); // Iniciamos el MFRC522
    Serial.println("Lectura del UID");
    M5.Lcd.println("Lectura del UID");

    void loop() {
    // Revisamos si hay nuevas tarjetas presentes
    if ( mfrc522.PICC_IsNewCardPresent())
    //Seleccionamos una tarjeta
    if ( mfrc522.PICC_ReadCardSerial())
    // Enviamos serialemente su UID
    Serial.print("Card UID:");
    M5.Lcd.println("Card UID:");
    for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    M5.Lcd.print (mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    M5.Lcd.print (mfrc522.uid.uidByte[i], HEX);
    // Terminamos la lectura de la tarjeta actual
    Unfortunately does not work.
    Please, could somebody give me an advise, something simple...
    In the future I want to create a door access.
    Thank you in advance.

  • pin 1 is for serial0, maybe not good for this.

  • #define RST_PIN 1 //Pin 1 para el reset del RC522

    As @m5stack said, PIN 1 is used by Serial0. You should pick a GPIO that's not in use already.

  • @dda Are there any other solucions to connect RFID to M5Stack?

  • @ddaniel Read my answer again: don't use pin 1 for RST_PIN. Connect it to another pin that isn't used yet.

  • I am interested in a compact RFID reader with a feedback display.
    I am wondering whether you have managed to build the sensor into the stack or whether it needs to be put off to the side somewhere?

  • @dave Hi Dave,

    I have a RFID-RC522 module on order but hasn't arrived yet... Apparently the board dimensions are: 3.9 x 6 cm

    So unfortunately it seems the whole module won't fit inside the M5 case....

    Might be ok with just a little sticking out the side....

  • You could take a look at https://www.sparkfun.com/products/11828

    It is somewhat more expensive, but has a body type that may be able to fit just fine into a different stack, or even the protoboard. They have other models as well.

  • @jp128 @Dave @ddaniel

    Hi Jp128,
    Thanks for the tip..... could be very useful.... more reading required....