RFID-RC522 does not scan all Mifare S50 tags

Hello all,

This is my first post on this forum, because I have a problem that I can really not fix by myself.

I ordered a bunch of Mifare S50 tags from the internet. They were 1 euro a piece, and perfectly suit my needs for a NFC Tag. But something very strange is going on with those tags and my NFC Reader I ordered from AliExpress.

When I initially got the cards, they were all being scanned and their UID was recognized by the reader. After 1 day one of the S50 tags could not be read anymore; no matter how long I hold it to the reader or how often I take it off and put it back against it, it will not be scanned. It did not fall from a great height nor did I try to overwrite the tag, etc.

I've been looking on the internet for quite some time now but nobody has asked this before. Here is my code:

#include <SPI.h>
#include <MFRC522.h>  // Library for Mifare RC522 Devices
#define SS_PIN 10
#define RST_PIN 9

const int ledGND = 0;
const int buzzer = 2;
const int RED = 3;
const int relay = 4;
const int BLUE = 5;
const int GREEN = 6;
const int ledValue = 20;
const int keys = 12;

const byte keyArray[keys][4] = {}; // This array contains all the keys UID, but removed here for security purposes

byte readCard[4];
int sum = 0;
int allowed = 0;

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup() {
  pinMode(relay, OUTPUT);
  pinMode(buzzer, OUTPUT);

  digitalWrite(buzzer, LOW);
  digitalWrite(relay, LOW);

  allLEDOff();

  Serial.begin(9600);
  SPI.begin();

  mfrc522.PCD_Init();

  rgbLED(3, 500);
  buzz(10, 50);

  redLEDOff();
  greenLEDOff();
  blueLEDOn();
}

void loop() {
  if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
    return 0;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) {   //Since a PICC placed get Serial and continue
    return 0;
  }

      //Serial.print("{");
  for (int i = 0; i < 4; i++) {  
    readCard[i] = mfrc522.uid.uidByte[i];

    //Serial.print(readCard[i]);
    //Serial.print(", ");
  }
  //Serial.println("},");

  mfrc522.PICC_HaltA();
  checkNumber(readCard);
  
}

void allLEDOff() {
  redLEDOff();
  greenLEDOff();
  blueLEDOff();
}

void whiteLEDOn() {
  redLEDOn();
  greenLEDOn();
  blueLEDOn();
}

void rgbLED(int repeat, int ttw) {
  for( int i = 0 ; i < repeat ; i++ ) {
    redLEDOn();
    delay( ttw / 3);
    redLEDOff();
    greenLEDOn();
    delay( ttw / 3);
    greenLEDOff();
    blueLEDOn();
    delay( ttw / 3);
    blueLEDOff();   
  }
}

void checkNumber(byte readArray[4] ) {
  for(int i = 0; i < keys; i++) {
    for(int j = 0; j < 4; j++) {
      if ( readArray[j] == keyArray[i][j] ) {
        sum++;
      }
    }
    if(sum == 4) {
      allowAccess();
    }
    sum = 0;
  }
  
  if(!allowed)
    disallowAccess();

  allowed = 0;
}

void allowAccess() {
  allowed = 1;
  blueLEDOff();
  greenLEDOn();
  buzz(2, 100);
  openRelay( relay );
  delay(500);
  greenLEDOff();
  blueLEDOn();
}

void disallowAccess() {
  blueLEDOff();
  redLEDOn();
  buzz(1,650);
  redLEDOff();
  blueLEDOn();
}

void greenLEDOn() {
  analogWrite(GREEN, ledValue);
}

void greenLEDOff() {
  analogWrite(GREEN, ledGND);
}

void redLEDOn() {
analogWrite(RED, ledValue);
}

void redLEDOff() {
analogWrite(RED, ledGND);
}

void blueLEDOn() {
  analogWrite(BLUE, ledValue);
}

void blueLEDOff() {
  analogWrite(BLUE, ledGND);
}

void buzz(int repeat, int ttw) {
  for(int i = 0; i < repeat; i++) {
    digitalWrite(buzzer, HIGH);
    delay( ttw );
    digitalWrite(buzzer, LOW);
    delay(ttw);
  }
}

void openRelay( int output ) {
  digitalWrite(output, HIGH);
  delay(500);
  digitalWrite(output, LOW);
}

Basically the checkNumber function is the one that compairs the scanned UID to the known UIDs. The tag gets scanned in the loop function.

All other tags are working fine, just not that single one. Strange thing is, I can perfectly scan it with my phone, but not with the reader.

Has anyone else encountered this before and knows how to fix the tag? I'm using the MFRC522 Library from GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522.

Lukkie1998

There are several types of Mifare tags. What does your phone say what type these tags are?

Have you seen this comment in the PICC_IsNewCardPresent() method of the used library?

  • Only "new" cards in state IDLE are invited. Sleeping cards in state HALT are ignored.

Maybe a WakeUpA call is necessary to get the from the halt state?

I just scanned the card with my phone, this is what it gives me:
Manufacturer:
NXP Semiconductors

Technology Supported:
Tag ID: AB XX XX XX
Technology: NfcA

Tag Information:
Provide access to NFC-A
ISO 14443-3(Type A)
ATQA: 00 : 04
SAK: 8

pylon:
Have you seen this comment in the PICC_IsNewCardPresent() method of the used library?

Maybe a WakeUpA call is necessary to get the from the halt state?

How would I go about using this WakeUpA call? Just script it in a seperate program to get the tag out of its halt state for once, or is it possible to put it in my main program in the original post?

How would I go about using this WakeUpA call? Just script it in a seperate program to get the tag out of its halt state for once, or is it possible to put it in my main program in the original post?

Insert it into the main program, it doesn't hurt to have them activated at each round.

Alright, I added it to the program like this:

byte ATQA;
byte bufferSize[2];

void loop() {
  if ( ! mfrc522.PICC_WakeupA( ATQA, bufferSize[2] )) {
    return 0;
  }
  if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
    return 0;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) {   //Since a PICC placed get Serial and continue
    return 0;
  }

  for (int i = 0; i < 4; i++) {  
    readCard[i] = mfrc522.uid.uidByte[i];
  }
  mfrc522.PICC_HaltA();
  checkNumber(readCard);
  
}

But this doesn't make the single S50 chip work again; it still doesn't get recognized by the RC522 scanner. But actually I have two S50 chips that do not work. But if I hold them on eachother (like really making contact) the one closest to the reader gets read! I have no idea what this could be since I am not really familiar with the RFID/NFC technology so... Hopefully anyone else has an idea.

Lukkie1998