Instructables

RFID Reader! Identify anything with RFID from credit cards to license plates

Picture of RFID Reader! Identify anything with RFID from credit cards to license plates
Hey guys today I just got an RFID Reader module from Parallax! I tried it out and made this program which identifies cards and other RFID products! All you need is a computer, an Arduino, a breadboard, and the Parallax RFID Reader Module! Please share your experiences, I am in wonder of what may have happened to you while building it or something like that! Thanks.
 
Remove these adsRemove these ads by Signing Up

Step 1: The circuit!

Picture of The circuit!
This is a very simple circuit which only needs four wires! (besides the usb) Down below is a diagram!

Step 2: The Code and Have fun scanning Cards and getting their IDs

Picture of The Code and Have fun scanning Cards and getting their IDs
//RFID Reader Module Read and indentify by simonfrfr
#define RFID_ENABLE 2 //to RFID ENABLE (connect pin 2 to the /Enable)
#define CODE_LEN 10 //Max length of RFID tag
#define VALIDATE_TAG 1 //should we validate tag?
#define VALIDATE_LENGTH 200 //maximum reads b/w tag read and validate
#define ITERATION_LENGTH 2000 //time, in ms, given to the user to move hand away
#define START_BYTE 0x0A
#define STOP_BYTE 0x0D

char tag[CODE_LEN];

void setup() {
Serial.begin(2400); //fequency needed becuase the used frequency on the RFID Reader Module
pinMode(RFID_ENABLE,OUTPUT);
}

void loop() {
enableRFID();
getRFIDTag();
if(isCodeValid()) {
disableRFID();
sendCode();
delay(ITERATION_LENGTH);
} else {
disableRFID();
Serial.println("Error: Unable to complete process!");
}
Serial.flush();
clearCode();
}

/*
Clears out the memory space for the tag to 0s.
*/
void clearCode() {
for(int i=0; i<CODE_LEN; i++) {
tag[i] = 0;
}
}

/*
Sends the tag to the computer.
*/
void sendCode() {
Serial.print("TAG:");
for(int i=0; i<CODE_LEN; i++) {
Serial.print(tag[i]);
}
}

/*

RFID Functions
*/

void enableRFID() {
digitalWrite(RFID_ENABLE, LOW);
}

void disableRFID() {
digitalWrite(RFID_ENABLE, HIGH);
}

/*
Blocking function, waits for and gets the RFID tag.
*/
void getRFIDTag() {
byte next_byte;
while(Serial.available() <= 0) {}
if((next_byte = Serial.read()) == START_BYTE) {
byte bytesread = 0;
while(bytesread < CODE_LEN) {
if(Serial.available() > 0) { //wait for the next byte
if((next_byte = Serial.read()) == STOP_BYTE) break;
tag[bytesread++] = next_byte;
}
}
}
}

/*
Waits for the next incoming tag to see if it matches
the current tag.
*/
boolean isCodeValid() {
byte next_byte;
int count = 0;
while (Serial.available() < 2) { //there is already a STOP_BYTE in buffer
delay(1); //probably not a very pure millisecond
if(count++ > VALIDATE_LENGTH) return false;
}
Serial.read(); //throw away extra STOP_BYTE
if ((next_byte = Serial.read()) == START_BYTE) {
byte bytes_read = 0;
while (bytes_read < CODE_LEN) {
if (Serial.available() > 0) { //wait for the next byte
if ((next_byte = Serial.read()) == STOP_BYTE) break;
if (tag[bytes_read++] != next_byte) return false;
}
}
}
return true;




Have fun scanning all of your objects! I had fun too! It is a very cool module! When the reader is waiting for a RFID Tag then the LED is RED. Look at some of my other projects at http://www.instructables.com/id/Candy-Drop-dispenser/
http://www.instructables.com/id/Password-protected-Secret-Telling-Arduino/
http://www.instructables.com/id/Arduinik-The-HumanoidBiped-Robot/
simonfrfr (author) 2 years ago
Hey guys I made a second version feel free to check it out :D and thanks for your comments :D
hi i got the rfid going on my arduino uno. but i cant figure out how to make a led on pin 13 turn on when a specific card is read.also how wold i Chang the name of the card so when it reads a2r128 a1r120 a0r-1 a0r-1 a0r-1 a0r-1 a0r-1 a0r-1 a0r-1 a1r248 a4r128 a6r128 a10r120 a13r0 a17r120 a19r128 a18r0 a17r128 a16r128 a15r0 a14r120 a13r120 a12r120 a11r248 a10r128 a11r120 a16r128 a19r248 a23r0 a26r120 TAG: and change that to: joe hudy. and with that name "joe hudy" i cold put it on my lcd.
simonfrfr (author)  lookwhatjoeysmaking2 years ago
I'm publishing a newer version of this instructable soon, it is going to incorporate the card code comparing.
simonfrfr (author)  lookwhatjoeysmaking2 years ago
You cannot change the name of the card because this is only a reader, but you can assign a name and value for the card. For Example lets say you want to have a vending Machine account, you can enable a card on the system when you buy it. You could set the name and when you scan it it goes into the system. Under the Name there could be a value which could be changed like subtracted when you spend money or added when you put money in the account.
zer0nerz2 years ago
i was wondering how can you add a display to this code? maybe one of the touch screen LCD's? i have one of those i wanted to view on that. and my
C++ is at a beginners hello world basically...
simonfrfr (author)  zer0nerz2 years ago
Well can you please specify which LCD you are talking about?
it says HY-tft320_262k under, it has a SD card slot also.
2011816141222948319.jpg
simonfrfr (author)  zer0nerz2 years ago
can you give me the product page, then I should be able to help you, Thanks Simon
http://www.ebay.com/itm/Arduino-Compatible-3-2-TFT-LCD-module-SD-card-/280724961864?pt=LH_DefaultDomain_0&hash=item415c82fa48
simonfrfr (author)  zer0nerz2 years ago
DB0-DB16 to pin D0-D13, pin A0-A1 of Arduino
RESET to A2
CS to A3
WR to A4
RS to A
this should take up most of the pins on the Arduino UNO, so you would need an Arduino Mega for this to function.
i have uno and mega
simonfrfr (author)  zer0nerz2 years ago
Ok then, you will need to edit the code then. You will need to use multi-serial on the mega and change the Enable port to 50. Or something like it.
Then programming the LCD is necessary. I will try to make a sample code for you of the RFID and everything when I get a chance. That should be soon
thank you so much =)
simonfrfr (author)  zer0nerz2 years ago
did you already buy this? I have something similar but I like it better.
what did you have by the way?
simonfrfr (author)  zer0nerz2 years ago
well I bought a few products for 4D systems and they work well with Arduino. I love their products. I am trying during my free time from school to work on your problem.
I yes i have it in possession now. Was so curious what i can do with this thing.
simonfrfr (author)  zer0nerz2 years ago
np
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!