Interfacing RFID READER RFID-IDR-232N to Arduino

RFID reader, Reader/Writer, Tag.....

Interfacing RFID READER RFID-IDR-232N to Arduino

Postby chongkkmy » Mon May 16, 2011 2:51 am

Hi all, I'm new to arduino. Building a Security project for my Final Year Project. I had bought a RFID Reader RS232 from cytron, but i have no luck with the programming. I had try lot of example about interfacing RFID but i still could not succeed. I had successfully read the data from a RFID tag but i think it's in ASII code... This is what i get for the output

Image

This is the example for RFID ID-12 that modify for my RFID RS232.
CODE: SELECT_ALL_CODE
#include <NewSoftSerial.h>
 
NewSoftSerial rfidSerial(6, 7); // (RX, TX)
String myTag, myTagClean;
 
void setup(){
 Serial.begin(9600);
 Serial.println("Hello World : RFID reader, from hardware serial");
 
 // set the data rate for the NewSoftSerial port
 rfidSerial.begin(9600); // communication speed of ID-12 reader
 rfidSerial.println("Hello World : RFID reader, from software serial");
 
 // just some random println tests
 Serial.println("lorem");
 Serial.println(13, BYTE);
 Serial.println("lorem");
 
}
 
void loop(){
 
 // read serial if available
 if (rfidSerial.available()) {
 
  // read and cast to char incoming data
  char incoming = (char)rfidSerial.read();
 
  Serial.print("receiving " );
  Serial.print(incoming);
  Serial.print(" => ");
  Serial.print(incoming, DEC);
  Serial.println(' ');
 
  // packet structure, see ID-12 datasheet
  // STX A B C D E F G H I J CR LF ETX
  //  2 - - - - - - - - - - 13 10 3
 
  // if I read the final delimiter
  if(incoming == 0){
 
 Serial.println("Incoming Tag");
 Serial.println(myTag);
 Serial.println(myTag.length());
 
 // clean up String
 // we skip the first char, and take the following 12 chars
 myTagClean = myTag.substring(1, 11);
 
 // reset myTag
 myTag = "";
 
 Serial.println(myTagClean);
 Serial.println(myTagClean.length());
 
 // test and compare
 if(myTagClean == "0013080667"){
  Serial.println("White Card");
 }
 if(myTagClean == "0013631187"){
  Serial.println("Keychain");
 }
  }
  // standard char, we add it to the String
  else{
 myTag = String (myTag + incoming);
  }
 }
}


RFID RS232 User Manual
http://www.cytron.com.my/usr_attachment/RFID-IDR-232N_User%27s_Manual.pdf

Any idea how to convert it to a string or char which can compare and match with the ID of my RFID tag?

Thanks
chongkkmy
Fledgling
 
Posts: 1
Joined: Mon May 16, 2011 2:29 am

Re: Interfacing RFID READER RFID-IDR-232N to Arduino

Postby ober » Thu May 19, 2011 10:16 pm

hi, I am very new to Arduino too :)

I am trying to understand your problem. Sorry, but I am not familiar with Arduino library, so just a rough idea from the code you share:
1. You receive the RFID from software serial port and send it to computer to display on HyperTerminal and you din get what you want, correct?
2. In the main loop, you check whether you receive data from software serial port, if yes you will send some string, follow by the data, and translate it into Decimal further send to HyperTerminal, right?

My personal opinion, you might have lost some byte from the RFID reader because the arduino is sending string to HyperTerminal. I would suggest you to receive all 13 bytes and store it in array, further then only display it in what ever way you like.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to RFID

Who is online

Users browsing this forum: No registered users and 3 guests

cron