RFID Giving this error RFID.h : No such file or directory

I am new to Arduino and trying to build an RFID lock but keep on getting this error even though i have all possible RIFD libraries.
Here is my code:
d LockArduino
#include <Servo.h>
#include <SPI.h>
#include <RFID.h>

RFID rfid(10, 9);

byte kart[5] = {208,74,76,37,243};
Servo myservo;
boolean card;

void setup()
{

Serial.begin(9600);
SPI.begin();
rfid.init();
myservo.attach(3);
myservo.write(100);

}

void loop()
{

if (rfid.isCard())
{

if (rfid.readCardSerial())
{
  Serial.print("Found ID: ");
  Serial.print(rfid.serNum[0]);
  Serial.print(",");
  Serial.print(rfid.serNum[1]);
  Serial.print(",");
  Serial.print(rfid.serNum[2]);
  Serial.print(",");
  Serial.print(rfid.serNum[3]);
  Serial.print(",");
  Serial.println(rfid.serNum[4]);

}
for (int i = 1; i < 5; i++)
{
  if (rfid.serNum[0] == kart[0] && rfid.serNum[1] == kart[1] && rfid.serNum[2] == kart[2] && rfid.serNum[3] == kart[3] && rfid.serNum[4] == kart[4])
  {
    card = true;
  }
  else {
    card = false;
  }
}
if (card == true)
{
  Serial.println("Correct Card");
  myservo.write(20);
  delay(15000);
  myservo.write(100);
}
else
{
  Serial.println("Wrong Card");

}
rfid.halt();

}

1 Like

What is the exact name of the libraries that you have installed?
There is a high chance that the name is not RFID.h

It is much more likely that the name is
MFRC522.h or something like that. The libraries are named after the Type of the chip that manages the reading. Because there are different chips that need different control-algorithms.

If you open the Arduino-library-manager and search for "RFID" which libraries did you install?

best regards Stefan

Thanks so much these are the names of the libraries i have installed:
MFRC225
adafruitmfrc630
adafruitpn532
rfiddb
and much more,but I couldn't find library called only RFID

So is there a question left?
You haven't yet described which exact hardware you were using. Please provide the exact type of the microcontroller-board and the components you are using.
Please provide links to product-descriptions and whenever possible provide download-links to datasheets or attach the datasheets to a posting

You are the one that wants help. So help yout potential helpers through making it easy to help you

best regards Stefan

I am using an arduino uno with a micro servo and a RC522 module

https://www.amazon.com/Arduino-A000066-ARDUINO-UNO-R3/dp/B008GRTSV6/ref=sr_1_3?dchild=1&keywords=arduino+uno&qid=1618747919&sr=8-3

https://www.amazon.com/Ybee-Micro-Helicopter-Airplane-controls/dp/B06WRS7PG8/ref=sr_1_1_sspa?dchild=1&keywords=micro+servo&qid=1618747832&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExOTYwU1M0WUlQVVBGJmVuY3J5cHRlZElkPUEwMjQ5NjA5RUFVUENZM0k4VlFFJmVuY3J5cHRlZEFkSWQ9QTA2ODIzMzkxSVMzME9GRlNPWVQyJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==

https://www.amazon.com/SunFounder-Mifare-Reader-Arduino-Raspberry/dp/B07KGBJ9VG/ref=sr_1_7?dchild=1&keywords=rc522+elegoo&qid=1618747775&sr=8-7

and what do you mean by data sheets

Most sensors and devices that are used with a microcontroller have integrated circuit-chip that does most of the details for sensoring or controlling something.

Your RFID-reader has its own special-purpose-"microcontroller"-Chip called MFRC522.
So do a google-search for Datasheet MFRC522
google will find multiple sources where the datasheet can be downloaded.
an MFRC522 is pretty common. But the really important information for every potential user here is the chip-type which ismentioned in the amazon-product-description.
Only with knowing your RFID-reader is based on the Chip-type MFRC522 makes it possible for helpers to give advice:
Use a library that is able to control a MFRC522-Chip.

GitHub is the most common place for libraries of al kinds.
So do a google-search with the keywords Github Arduino MFRC522 to find the documentation and example-codes for this chip.

take a look at the examples. If you have questions about which MFRC522-library to use or which example-code to use just post the links to the webistes you have been looking at and ask this questions here in the forum.

Working this way shows: You are investing own effort into learning and now you have questions. By providing the links to the websites you make it easy for other users to look up these websites. This sort of questions is very welcomed. For most users it is fun to answer this kind of questions.

best regards Stefan

Thank you I managed to find the library but now I am getting this error
'class RFID' has no member named init
here's the code:
#include <Servo.h>
#include <SPI.h>
#include <RFID.h>

RFID rfid(10, 9);

byte kart[5] = {208,74,76,37,243};
Servo myservo;
boolean card;

void setup()
{

Serial.begin(9600);
SPI.begin();
rfid.init();
myservo.attach(3);
myservo.write(100);

}

void loop()
{

if (rfid.isCard())
{

if (rfid.readCardSerial())
{
  Serial.print("Found ID: ");
  Serial.print(rfid.serNum[0]);
  Serial.print(",");
  Serial.print(rfid.serNum[1]);
  Serial.print(",");
  Serial.print(rfid.serNum[2]);
  Serial.print(",");
  Serial.print(rfid.serNum[3]);
  Serial.print(",");
  Serial.println(rfid.serNum[4]);

}
for (int i = 1; i < 5; i++)
{
  if (rfid.serNum[0] == kart[0] && rfid.serNum[1] == kart[1] && rfid.serNum[2] == kart[2] && rfid.serNum[3] == kart[3] && rfid.serNum[4] == kart[4])
  {
    card = true;
  }
  else {
    card = false;
  }
}
if (card == true)
{
  Serial.println("Correct Card");
  myservo.write(20);
  delay(15000);
  myservo.write(100);
}
else
{
  Serial.println("Wrong Card");

}
rfid.halt();

}
}

Why do you keep a faulty code?
take an examplecode from github.

I have no idea where you have the code from posted above.
best regards Stefan

I got it working thank you so much thank for all time and effort I really appreciate it

2 Likes

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