miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.79k stars 1.45k forks source link

RC522 Mini Not Work vs RC522 Normal #603

Open ruielias opened 1 year ago

ruielias commented 1 year ago

Step 1: Describe your environment

Step 2:

Hello, I have a full size RC522 module and working 100% OK I paid for 3 "MW-ET LIVE MINI RFID-RC522" units, and none of them work, but they pass the "PCD_PerformSelfTest()". Are Minis different?

Affected file(s) or example(s):

self test

Steps to reproduce:

Observed Results:

MFRC522 Digital self test
Firmware Version: 0x92 = v2.0
Only known versions supported
Performing test...
Result: OK
MFRC522 Digital self test
Firmware Version: 0x92 = v2.0
Only known versions supported
Performing test...
Result: OK

Expected Results:

Relevant Code:

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

#define SS_PIN  16
#define RST_PIN 13

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(115200);
  while (!Serial);

  SPI.begin(5,19,27,16);
  rfid.PCD_Init(); // init MFRC522
  delay(10);
  Serial.println("Iniciou RFid");

  delay(100);

 Serial.println(F("*****************************"));
  Serial.println(F("MFRC522 Digital self test"));
  Serial.println(F("*****************************"));
  rfid.PCD_DumpVersionToSerial();  // Show version of PCD - MFRC522 Card Reader
  Serial.println(F("-----------------------------"));
  Serial.println(F("Only known versions supported"));
  Serial.println(F("-----------------------------"));
  Serial.println(F("Performing test..."));
  bool result = rfid.PCD_PerformSelfTest(); // perform the test
  Serial.println(F("-----------------------------"));
  Serial.print(F("Result: "));
  if (result)
    Serial.println(F("OK"));
  else
    Serial.println(F("DEFECT or UNKNOWN"));
  Serial.println();
}

void loop() {
  if (rfid.PICC_IsNewCardPresent()) { // new tag is available
    Serial.println("NEW...");
    if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
      MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
      Serial.print("RFID/NFC Tag Type: ");
      Serial.println(rfid.PICC_GetTypeName(piccType));
      // print UID in Serial Monitor in the hex format
      Serial.print("UID:");
      for (int i = 0; i < rfid.uid.size; i++) {
        Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
        Serial.print(rfid.uid.uidByte[i], HEX);
      }
      Serial.println();
      rfid.PICC_HaltA(); // halt PICC
      rfid.PCD_StopCrypto1(); // stop encryption on PCD
    }
  }
  delay(250);
}

image image

alex-eri commented 1 year ago

it works if pulldown RST pin. see #599

alastaira commented 1 year ago

Without seeing the schematic, it sounds like they may have omitted the pullup resistor and/or put an inverter on the RST line. Normally, this pin can be ignored - it's pulled HIGH by default, and you only need write a LOW signal to it to reset the reader. From the description given by @alex-eri , it sounds like you need to do the opposite for this board.

alex-eri commented 1 year ago

-

alex-eri commented 1 year ago

Not inverted. Pull down needed to make this line of code work https://github.com/miguelbalboa/rfid/blob/1e73cd34d977c5fe17fa5f2e2e8174650a572028/src/MFRC522.cpp#L210C2-L210C2

else RST pin stays in INPUT mode and FLOATING on many boards ( for example ESP32)

alex-eri commented 1 year ago

pulled HIGH by default only on board without FLOATING input (Arduinos).