Rfid not reading mfrc522

VID ISSUE.zip (560.0 KB)

What are the possible reasons why the arduino slows down? When it slows down, the rfid mfrc522 can not read any more the card. you need to reset or restart the program?

Also I noticed that when you use a function void and run it in the void loop its slows down too.

Thanks for the help and reply

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

What is in the ZIP? On a cell phone at the moment so can't open it.
Code can (and should) be posted in a post; same for images). This makes it easier for people to assist; some even refuse to open zip files.

Noted and thank you. the zip file is a video showing the issue of slowing down.

It's pretty much useless. What would be a lot more useful is if you could post your code (in code tags).

#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Extended.h>
#include <require_cpp11.h>

#include <SPI.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
const int pinFive = 5;
const int pinSix = 6;
const int pinEight = 8;
const int pinSeven = 7;
int doorState = 0;
int scanState = 0;
String cardNum = "";
int intCard = 0;

void setup() {
  pinMode(pinEight,OUTPUT);                                            
  pinMode(pinSeven,OUTPUT);                                          
  pinMode(pinSix,INPUT);                                            
  pinMode(pinFive,INPUT); 
  Serial.begin(9600);                                          
  Serial.println(F("Serial Start"));  
  SPI.begin();                                               
  mfrc522.PCD_Init();                                       
}

void loop() {
if(doorState == 0)
   {
      //RFID 
      MFRC522::MIFARE_Key key;
      for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

      //some variables we need
      byte block;
      byte len;
      MFRC522::StatusCode status;
      // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
      // Select one of the cards
      
      // Look for new card
      if ( ! mfrc522.PICC_IsNewCardPresent()){ 
      Serial.println(F("\n**no new card**\n"));
      return;
      }
      // Verify if the NUID has been readed
      if (  !mfrc522.PICC_ReadCardSerial()){
      return;
      }
      
      delay(1500);
      Serial.println(F("**Card Detected:**"));
      //scanState = 0;
      //digitalWrite(pinSeven, scanState);
      mfrc522.PICC_DumpDetailsToSerial(&(mfrc522.uid)); //dump some details about the card

      len = 18;
      byte buffer2[18];
      block = 1;
  

      status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 1, &key, &(mfrc522.uid)); //line 834
      
      if (status != MFRC522::STATUS_OK) 
      {
        Serial.print(F("Authentication failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
      }

      status = mfrc522.MIFARE_Read(block, buffer2, &len);
      
      if (status != MFRC522::STATUS_OK) 
      {
        Serial.print(F("Reading failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
      }
      //check card level
      Serial.print(F("LEVEL: "));
  
      for (uint8_t i = 0; i < 1; i++)
      {
      if (buffer2[i] != 32)
        {
          //Serial.write(buffer2[i]);
          cardNum = buffer2[0];
          Serial.println(cardNum);
          
        }
      }//end for loop
      delay(1000);
      mfrc522.PICC_HaltA();// stop reading
      Serial.println(F("\n**Stop Reading**\n"));
      mfrc522.PCD_StopCrypto1(); 
      Serial.println(F("\n**Stop Encryption**\n"));
      
     }//end of door state = 0 for rfid
     
      intCard = cardNum.toInt();

      //card Z = Master Key;
      if(cardNum == "90")
      {
        doorState = 1;
        digitalWrite(pinSeven,doorState);
        Serial.println(F("Door Unlock"));
        Serial.println(doorState);
        delay(5000);
        doorState = 0;
        digitalWrite(pinSeven,doorState);
        String cardNum = "";
        Serial.println(doorState);
        delay(200);
      }
     
   
}//end of void loop

the code is this.. when I trigger the door to open and then close after a couple of seconds, the reader arduino slows down and does not read any more =(

What do you think these do?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.