RFID Access control

I have been through numerous websites that all repetitively explain the same example over and over for this type of project (basically verbatim), but what I would like to do is a little different and much simpler.

Wanted- simple access granted by showing the right card to the reader. No serial monitors, no computer, no screens. I need to read the UID and compare it to the two cards that I have. I used the Dump example to find the UID’s of both of my cards.

Currently- Code for the project is attached. I have a simple “readDigital” stuck in the “KeycardCheck” function at the moment to take the place of the commands I am looking for.

The help I need- need someone to do a quick walk through of a quick and easy way to grab the uid, compare to the two I have, and set a flag value of “accepted” or “denied”.

Thanks for any help

Turret_Code_Edit1.ino (4.07 KB)

If you used the DumpInfo example, you basically have what you need. You test to see if a card is present, and if it is, you get the UID from it and compare it to the ones that are allowed.

All the code is on your PC for the MFRC522 library so you can look at it if you want to know more.

the commands that i see the dump example using (all three of them- this is part of the problem) all seem to do several things at once and im not sure how to integrate them into my program. one checks for a new card, and does... something. then the next one does something if there is a card present and puts the info on the screen, which i dont need.

is there a way to go look at the code that is called up when "if ( ! mfrc522.PICC_IsNewCardPresent())" is used? If I can see what it is doing I can probably figure out what I need from there.

OpFX:
the commands that i see the dump example using (all three of them- this is part of the problem) all seem to do several things at once and im not sure how to integrate them into my program. one checks for a new card, and does... something. then the next one does something if there is a card present and puts the info on the screen, which i dont need.

Isn't your requirement "if a new card is present, make sure it matches?"

If so, then you are doing about the same thing. I'm not sure why you continue to think you need to do something else...

it could very well do what i need, but if i dont understand how its being implemented, im not going to be very fast at making the code work.
if anyone can give me a quick run down on what that line actually does, or can tell me where to look at the code that gets called, I'd appreciate it.

or can tell me where to look at the code that gets called, I’d appreciate it.

The code is in the library .h and .cpp files on your PC

UKHeliBob:
The code is in the library .h and .cpp files on your PC

thanks! ill start there and come back if i have more questions

OpFX:
it could very well do what i need, but if i dont understand how its being implemented, im not going to be very fast at making the code work.

That is the beauty of using a library. I don't have to care how it is implemented. I just look at the example code which demonstrate the use and go from there.
I would think a function like 'mfrc522.PICC_IsNewCardPresent()' returns a true/false value to let you know if a new card is present (and it does!). How it does that is not really my concern.

some info i can use... "isnewcardpresent" returns a true/false value. ok, so i can use this in a loop waiting until a card is presented, then start reading. cool.

so... can i get an explanation on the same level of how to actually read the uid into an array or how to compare it to the two that i have? im looking through the data sheet, the header file, and the cpp. im looking for a list of commands that are written out so that i can understand them and how to type them in. im looking for something like THIS but for the 522 chip.

its been more than a year since i used c++, and we didnt do anything fancy like real world tech. it was all making programs that run in a text box.

You stated that you used the DumpInfo example sketch to get the UID of the two chips you have. That code has a perfectly good example of how to read the uid into an array.

Start with that sketch and slowly tailor it to do what you want

alright, listen. there's always one in a group who needs it spelled out. if i understood the code and which pieces i needed to use and how to implement them, I wouldn't be here, would I? So unless you understand what I'm looking for and can start explaining it, this is your stop.

Dumpinfo has three commands, all completely written out in the library, but not explained. If I understood what "mfrc522.PICC_ReadCardSerial()" did, then I would probably use it and move on.

Im looking at the AccessControl example, it has a function for "get uid". It uses the "read card serial" call, then outputs the uid in 4 characters.

the uids that got dumped from my two cards are D9EAA0A3 and 99AA4898. What is the difference between the uid coming from the card being outputted in 4 characters and what actually gets outputted on the screen (8 characters)?

That's because the data is being displayed as hexadecimal.

4 serial characters = 4 bytes.
1 byte = 2 hexadecimal characters i.e. 1 byte can have a value between 0 and 255 decimal or 0x00 to 0xFF hexadecimal.

Therefore 4 characters = 8 hexadecimal digits.

In your examples D9EAA0A3 and 99AA4898 they break down to 0xD9 0xEA 0xA0 0xA3
and 0x99 0xAA 0x48 0x98.

Ian

OpFX:
alright, listen. there's always one in a group who needs it spelled out. if i understood the code and which pieces i needed to use and how to implement them, I wouldn't be here, would I? So unless you understand what I'm looking for and can start explaining it, this is your stop.

Dumpinfo has three commands, all completely written out in the library, but not explained. If I understood what "mfrc522.PICC_ReadCardSerial()" did, then I would probably use it and move on.

You were pointed to an example. You were pointed to the library where the code exists on your PC.

If you don't understand C/C++ then start working through any of the tutorials on-line