RFID EXPLAINED: HOW TO READ DATA FROM RFID CARDS WITH ARDUINO #rfid #arduino #esp32

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is an RFID scanner and reader it allows us to give labels to things that might not have an electronic label for example when you go into the gym you have these little key tags you scan and the gym knows who's coming in and out or the same thing with key cards when you're going in and out of the office building RFID technology lets us do that and in today's video we're going to go over how it works how to set it up and how to write the code for it so that you can be using it in your own project RFID is like a high-tech way of identifying and tracking things using radio wave it all begins with these Nifty little tags or cards think of them like mini computers really really small computers and each tag has a special identification number just like your own name this identification number is unique to every one of these tags so nothing in this picture should have the same tags the first one the second one and the third one should all have unique tags to interact with these unique identification numbers you're going to need something to read off of these tags or off these cards and that's where our RFID reader and writer comes in when you bring out one of those tags or cards close to the RFID reader it's like waking up the tags mini computer how well the reader sends out those radio waves and that's intercepted by our key tag and since our key tag doesn't have any battery or any type of power source in it it's using those radio frequencies to power it then when our tags mini computer gets powered up by these radio waves it goes hey here I'm here my name is and then identification number and all that is being read by the reader so now because they're close to each other they can kind of communicate between the two like I said there's no power supply in these so this key card right here has nothing in it that supplies power same thing with this key tag all this collected info can then be sent to a computer database to check for matches or store any data relating to that identification number so if you're wondering in places where we would be using this technology it's like when you go to the gym you scan and then we keep track of who's coming in and out when they come in how many days they'll have left before their plan runs out all that information comes back from this tag and this tag is how we keep track of your movements in and out of certain spots a lot of the time with secure or government buildings you have these RFID cards with your name on them whatever and you scan them to get into parts of the building that's because we have an identification number on this card to figure out who's scanning it so that identification number kind of becomes your name in the system or at least a link to it and that's pretty much RFID technology in a nutshell we're giving these tags their own unique names and then using radio waves to have a chat with them and figure out who they are now we're just going to wire up our reader to our microcontroller we're using an Arduino board so we're just going to need a couple cables for all the pins on the back and then after that we can get started with the code to keep the wiring simple I'm going to put up a picture on the screen of the pin out which tells you which port to use on the microcontroller and where to plug that in on your sensor and vice versa if you're not using an Arduino just Google the pin out for your microcontroller but it's going to be the same type of code and everything just make sure you're using the right pins on your specific board so in our case in our case we go SDA SC in our case we go SDA sck mosy miso I think that one is irq then ground rst and 3.3 volt we're not going to be using irq so I'm just going to go in mind let's start with the easy ones we're going to go with 3.3 volts and that's going to go into the 3.3 volt port on the microcontroller after that we have rst which goes into digital 9 next up looks like we have our ground that's just going to go into the ground Port right next to the 3.3 volt Port after that we have irq which we're not using and then after that we have miso m i s o that's going into 12 so just going to grab the Miso plug it into number 12 after that we have M oi so I guess Moy miso I don't know so m o SII goes into 11 after that we have sck which is going to go into 13 and then we have one last to plug in which is our SDA and that's going to go into number 10 so just go over everything make sure you're using 3.3 volt that's what it's rated for that's what you need to use don't try and sneak around and use 5 volt that can fry your border or just make everything not work all right let's plug it into the computer and we can get started with the code to make this thing work to get started we're going to have to import two different libraries that we're going to have to go and download since I don't have them on my computer so we're just going to go into the library manager type in SBI and then I guess I have it installed already the Ada of fruit one then we need to go and get MFR I'll do in capitals mfrc 5 T2 and I'm pretty sure this is the one we have to install we'll see in a minute when we try the code so just install that and you should be good to go then we're just going to put three different things we're going to declare our pins that we had earlier so we have 10 n and then we're going to make our mfrc522 to instance then we can go straight into the setup and start with serial. begin to display things in the serial monitor SPI begin to initialize the SPI communication between Arduino and the reader and then to initialize the RFID reader itself then we just put a simple little message in the console here that says hold your card close to the reader this is just a good way of letting you know that the the the reader itself is actually starting to read and listen to what's happening so when you see that in the console you know okay the program has started this could be whatever you want then we go Direct directly into our Loop and we're going to put the first piece of code which is just a little bit of logic to see if a new card is being scanned this is a function within the instance of the new artif ID reader that we made up after that we can do another one and this time we're just going to check if we can read the information from the card if we can't read any information from the card maybe our scan wasn't good maybe our card isn't good something went wrong so we're just going to exit that now the next part is going to get a little bit complicated and it's okay if you don't understand everything that's happening in here this little piece of code all it's going to do is just just take our information from the card and write it out a bit cleaner and then also store it in a little local storage that we're going to make over here and because we do that we can then write the second piece of code which is going to uppercase our identification number then it's going to check if the new card ID that we just scanned up here if that's going to be equal to this example one right here now let's say that equals this so it's the right card let's say it's Mike's card and Mike scanned it and we know now Mike is scanning a card then we can do the first piece of code right here which is saying access granted welcome let's say I scan the card and it's not this one the identification number does not equal bd31 15 20 what is that 2B so if it doesn't equal that it's going to skip this part of the code because it's an LL statement and then it's going to go down here and just say access denied unauthorized card in here you can put whatever you want you can put a door lock and when someone scans if it's the right card it unlocks the door you can put a Beer Dispenser you can have literally anything you want that you want to restrict to some people and open to others you can use this kind of RFID technology with that code to make it work you can also just use it to identify people so if you want to know who's using something like sometimes I think schools do this they have a little card reader like this for the school printer and you just scan it on the school printer and then when you use the printer they know who printed 300 pictures of Elmo or whatever the now we could run this right here but none of the cards are going to be in the access granted welcome stage of the code because obviously this is a code that I just copied off of the internet so one thing we can do is we go up here to file examples and and then we got to look around until we see our I think it was what was it m MRC something the library that we this one mfrc522 we're going to go in there and we're just going to see which one here is for reading I think this one read ID so we're going to open up that example you can see this pre-written code this is for every project we've ever done if you go to file examples you can find pre-written code if you're having issues with yours and I'm pretty sure this one is just going to read out the card and print it to the console so we can give it a try just going to select my uino board I'm going to upload it to the board and I'm going to take this card right here and we'll see once it's done we can open up our serial Monitor and make sure it runs on the same thing using the following key okay now what if I put this card close is it not scanning nothing okay what if I put this close okay so maybe this isn't the right one okay so maybe we have a connection issue maybe that's why the previous one didn't work let's take a look so back to that picture we had at the start SDA goes into digital 10 in my case SDA is white and move this white is plugged into digital 10 sck in my case is black and that's plugged into Ah that's the problem that was not plugged into the right Port okay okay so I guess it's Human air in this case we're going to re-upload everything we're going to open up a fresh serial monitor let's see what happens okay now it seems to be working you see firmware version we're on V2 so we're going to scan our card boom and we can see here our card U ID is 8201 b951 so that's what this card is currently labeled as that's its name oops then we have our two Little Gym tags here we're going to try those those out so I'm just going to scroll down to the bottom one thing I'm going to do and you should definitely do is copy paste this so we're just going to copy that and we're going to go back into our original file that we wrote ourselves and just for now I'll just do it like this this is the card and then we'll read a gem card key tag so that's our card let's go back into here scroll down to the bottom or you could clear it and scan one of our gym tags dcfb 82 2f so now we're just going to copy paste this going to go into our original code that we wrote and we're going to paste it in there so now we have our card ID and our key tag ID and we're going to use those over here so we could go back over here we can close this program we don't need it anymore and let's say right now I'm not looking at the camera I'm going to mix up my two gym tags and we're going to use the RFID reader to figure out which one of these two tags is the one that we previously scanned so we're just going to grab our key tag right here now you can use multiple of them you just just make this longer and add more but I'm just going to use two so that's our gym key tag let's upload this to the board and open it up no upli Port provided maybe because of that and just go to serial monitor clearly console so I'm going to scan the first card that I picked randomly and we can see that's the right one now if I scan the other one access denied if I scan another one access denied and you can just keep going and you know I'm not even getting too close I'm probably like an inch away and it's still working now if I take the original one access granted welcome so that's how an RFID reader works it uses radio waves to activate the little tiny computer inside of your key tags and then by reading that information we can use it to identify let's say in this case three different individuals I'm going to turn this video into two parts because it's very long the first part is this one where we read off of these tags and then part two is going to be how do we write information to them so what if someone has a key card and you don't want them to use it anymore and you want to change its name you want to burn that ID and use a new one that's what we're going to go over in part two which is going to be the next video if you enjoy this type of stuff just do me a favor and give the video a like And subscribe to the channel because unfortunately that's the only way that you can support it if you have any questions anything that didn't make sense anything that I maybe did wrong in this video please let me know in the comments and if you need help with your specific projects we do have a Discord Channel with some people in there that can help you out with your stuff I guess I'll see you in part two
Info
Channel: Mikael Abehsera
Views: 2,433
Rating: undefined out of 5
Keywords: RFID, Arduino, ESP32, RFID cards, RFID technology, Arduino tutorial, ESP32 projects, Electronics, RFID reader, DIY, IoT, NFC, Programming, Electronics projects, RFID tags, RFID sensor, Embedded systems, Internet of Things, RFID basics, RFID programming, RFID applications, Arduino RFID, ESP32 RFID, RFID card reader, RFID security, RFID authentication, RFID project, RFID technology tutorial, RFID card, RFID DIY, RFID system, rfid card
Id: stVjWUsFJkA
Channel Id: undefined
Length: 11min 28sec (688 seconds)
Published: Fri Dec 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.