Having Trouble With RFID.h Library (please help :'( )

Hi

im a complete beginner to arduino stuff

im currently follow a tutorial

https://www.youtube.com/watchv=_9unR083OPY&ab_channel=MichaelKlements

to make a RFID door lock

using a RFID-RC522 and a Servo motor

im using an ELEGOO ARDUINO UNO R3

all the wiring is correct according to a given circuit diagram

the code im using is :-

`Use code tags to format code for the forum`//The DIY Life
//Michael Klements
//27 January 2020

#include <SPI.h> 
#include <RFID.h>
#include <Servo.h> 

RFID rfid(10, 9);       //D10:pin of tag reader SDA. D9:pin of tag reader RST 
unsigned char status; 
unsigned char str[MAX_LEN]; //MAX_LEN is 16: size of the array 

String accessGranted [2] = {"310988016", "19612012715"};  //RFID serial numbers to grant access to
int accessGrantedSize = 2;                                //The number of serial numbers

Servo lockServo;                //Servo for locking mechanism
int lockPos = 15;               //Locked position limit
int unlockPos = 75;             //Unlocked position limit
boolean locked = true;

int redLEDPin = 5;
int greenLEDPin = 6;

void setup() 
{ 
  Serial.begin(9600);     //Serial monitor is only required to get tag ID numbers and for troubleshooting
  SPI.begin();            //Start SPI communication with reader
  rfid.init();            //initialization 
  pinMode(redLEDPin, OUTPUT);     //LED startup sequence
  pinMode(greenLEDPin, OUTPUT);
  digitalWrite(redLEDPin, HIGH);
  delay(200);
  digitalWrite(greenLEDPin, HIGH);
  delay(200);
  digitalWrite(redLEDPin, LOW);
  delay(200);
  digitalWrite(greenLEDPin, LOW);
  lockServo.attach(3);
  lockServo.write(lockPos);         //Move servo into locked position
  Serial.println("Place card/tag near reader...");
} 

void loop() 
{ 
  if (rfid.findCard(PICC_REQIDL, str) == MI_OK)   //Wait for a tag to be placed near the reader
  { 
    Serial.println("Card found"); 
    String temp = "";                             //Temporary variable to store the read RFID number
    if (rfid.anticoll(str) == MI_OK)              //Anti-collision detection, read tag serial number 
    { 
      Serial.print("The card's ID number is : "); 
      for (int i = 0; i < 4; i++)                 //Record and display the tag serial number 
      { 
        temp = temp + (0x0F & (str[i] >> 4)); 
        temp = temp + (0x0F & str[i]); 
      } 
      Serial.println (temp);
      checkAccess (temp);     //Check if the identified tag is an allowed to open tag
    } 
    rfid.selectTag(str); //Lock card to prevent a redundant read, removing the line will make the sketch read cards continually
  }
  rfid.halt();
}

void checkAccess (String temp)    //Function to check if an identified tag is registered to allow access
{
  boolean granted = false;
  for (int i=0; i <= (accessGrantedSize-1); i++)    //Runs through all tag ID numbers registered in the array
  {
    if(accessGranted[i] == temp)            //If a tag is found then open/close the lock
    {
      Serial.println ("Access Granted");
      granted = true;
      if (locked == true)         //If the lock is closed then open it
      {
          lockServo.write(unlockPos);
          locked = false;
      }
      else if (locked == false)   //If the lock is open then close it
      {
          lockServo.write(lockPos);
          locked = true;
      }
      digitalWrite(greenLEDPin, HIGH);    //Green LED sequence
      delay(200);
      digitalWrite(greenLEDPin, LOW);
      delay(200);
      digitalWrite(greenLEDPin, HIGH);
      delay(200);
      digitalWrite(greenLEDPin, LOW);
      delay(200);
    }
  }
  if (granted == false)     //If the tag is not found
  {
    Serial.println ("Access Denied");
    digitalWrite(redLEDPin, HIGH);      //Red LED sequence
    delay(200);
    digitalWrite(redLEDPin, LOW);
    delay(200);
    digitalWrite(redLEDPin, HIGH);
    delay(200);
    digitalWrite(redLEDPin, LOW);
    delay(200);
  }
} 
`````````````````````````````
i dont know how to write code which is why im following a tutorial :'(

i think its an issue with the library which is giving me several errors like :-

Error: 13 INTERNAL: Library install failed: archive is not valid: multiple files found in zip file top level

Error: 13 INTERNAL: Library install failed: moving extracted archive to destination dir: library not valid


im sorry if im asking dumb questions i only started using arduino since december 2023

pls help if u can

You forgot to tell us what the problem is. :wink:

The link to the video is not correct.

Arduino Based RFID Door Lock - Make Your Own By Michael Klements

is the video idk why links are not working

its a problem with the RFID.h library i think

As @MaximoEsfuerzo said, you forgot to tell us what the problem is.

Please take the time to read How to get the best out of this forum. Once you have read and digested the information there, please come back and provide the detailed information needed for others to help you.

And please, use standard English in your replies. Abbreviations and punctuation free lower case word soup may be the norm in your immediate social circle, but here you are communicating with the wider world where standard English is still the lingua franca. Using standard English will widen the pool of people who might be willing to help you. Thank you in advance.

Salutations!
I doth find myself beset by a quandary, forsooth, in the realm of libraries. They doth presenteth unto me a multitude of vexatious error codes, and, alas, their functionality hath been rendered inert. Might thou deign to assist me in unraveling the enigma that shrouds their non-functionality?
I give thee thanks

And you still haven't said what the problem is. Good-bye.

(But don't worry; with your attitude I'm sure you'll have no shortage of people banging on your door to help you.)

Thats the problem , the libraries keep showing errors

bro the problem is with the libraries

Error: 13 INTERNAL: Library install failed: archive is not valid: multiple files found in zip file top level

Error: 13 INTERNAL: Library install failed: moving extracted archive to destination dir: library not valid

Its showing the following errors when inserting RFID.h library
what does that mean ?

Hi @ojasjangal2010. I'll provide instructions for installing the "RFID" library:

  1. Download the file from the "Download the code: RFID Sensor Sketch" link in the tutorial.
  2. Unzip the downloaded file.
    The unzipped folder has this structure:
    RFID/
    ├── RFID/
    │    └── RFID.ino
    └── RFID Library/
         └── RFID.zip
    
    :exclamation: Note that there is a file named RFID.zip inside the folder you unzipped from the downloaded file.
  3. Select Sketch > Include library > Add .ZIP Library from the Arduino IDE menus.
    The "Select the zip file containing the library you'd like to add" dialog will open.
  4. Select the file at the following path under the unzipped folder:
    RFID Library/RFID.zip
    
  5. Click the "Open" button.
    The dialog will close.
  6. Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:

    ⓘ Successfully installed library from ...

It means you attempted to install the ZIP file downloaded from the tutorial. That can't work because the file downloaded from the tutorial contains two different things:

  • The sketch
  • The library

Arduino IDE's "Add .ZIP Library" can only be used with ZIP files that contain a library alone. This is the reason why the procedure works once you point it to the ZIP file of the "RFID" library.

That's what you should have explained from the beginning.


They are answers that do not work because we do not have a crystal ball to know what the problem is that you have.

Keep that in mind for next time. :wink:

Sorry

Thanks ! I will inform if its working now!

Hi now its working , But the NFC tag and RFID card are not being recognized , I tried everything....

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