RFID read/write module beginner help. Not reading anything.
johnone
Posts: 9
Hello ...
I just bought this:
http://parallax.com/product/28440 - RFID Read/Write Module
http://parallax.com/product/32399 - RFID R/W 30 mm round tag
I'm trying to read the tags unique ID using this sample code:
I've connected:
VCC to 5V
SIN to DIGITAL 2
SOUT to DIGITAL 5
GND to GND
1. What is:
2. Does this read the unique ID or the data I write to the tag? (and is there any data on it by default? Is that the reason it does not print any tag data?)
3. Why this no work ((
I just bought this:
http://parallax.com/product/28440 - RFID Read/Write Module
http://parallax.com/product/32399 - RFID R/W 30 mm round tag
I'm trying to read the tags unique ID using this sample code:
//Code to read data from Parallax RFID reader/writer 28440 via Arduino//Program reads data from the old EM4100-based tags and prints their value in the serial monitor. //Writen by vgrhcp, uberdude, sebflippers and sixeyes #include <SoftwareSerial.h> #define txPin 2 #define rxPin 5 #define RFID_LEGACY 0x0F SoftwareSerial mySerial(rxPin, txPin); int val = 0; char code[11]; //Note this is 11 for the extra null char? int bytesread = 0; void setup() { Serial.begin(9600); mySerial.begin(9600); pinMode(2, OUTPUT); pinMode(4, OUTPUT); pinMode(txPin, OUTPUT); //pin 2 pinMode(rxPin, INPUT); //pin 5 Serial.println("RFID Read/Write Test"); } void loop() { mySerial.print("!RW"); mySerial.write(byte(RFID_LEGACY)); //mySerial.print(32, BYTE); if(mySerial.available() > 0) { // if data available from reader if((val = mySerial.read()) == 10) { // check for header bytesread = 0; while(bytesread<10) { // read 10 digit code if( mySerial.available() > 0) { val = mySerial.read(); if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading break; // stop reading } code[bytesread] = val; // add the digit bytesread++; // ready to read next digit } } if(bytesread == 10) { // if 10 digit read is complete Serial.print("TAG code is: "); // possibly a good TAG Serial.println(code); // print the TAG code } bytesread = 0; delay(500); // wait for a 1/2 second } } }
I've connected:
VCC to 5V
SIN to DIGITAL 2
SOUT to DIGITAL 5
GND to GND
1. What is:
pinMode(2, OUTPUT);pinMode(4, OUTPUT);Used for?
2. Does this read the unique ID or the data I write to the tag? (and is there any data on it by default? Is that the reason it does not print any tag data?)
3. Why this no work ((
Comments
One device's tx is the other devices rx.
I'm guessing pin 4 is used as an indicator LED.
Edit: Never mind. It looks like you have it correct.
2) The RFID reader responds to commands sent, in your case, from your Arduino via pin 2 to SIN. The responses get sent from SOUT into pin 5. Read the documentation for the RFID reader/writer for details.
3) The above sample program doesn't work with read/write tags. It only works with read-only tags. Again, read the documentation for details, but note that the above program commands the RFID reader/writer to read a "legacy" tag. You want to read a read/write tag. The documentation has a sample program for Parallax's Stamp. I don't know know where you could find a similar example for an Arduino. You might ask at the Arduino websites.
Parallax is relatively new to the Arduino support business and they have Arduino sample programs for only a few of their sensors / devices. Check on their <learn.parallax.com> website. There's not an example yet for the RFID reader/writer, but there are some examples for the Board of Education Shield for robotics.
http://playground.arduino.cc/Learning/ParallaxRFIDreadwritemodule
But found this:
http://www.cooking-hacks.com/documentation/tutorials/arduino-rfid#step4
Will read....
EDIT: there's more..
http://www.engineerallthethings.com/electronics/RFID/RFID.html
http://www.youtube.com/watch?v=aImAsXPOHZA
http://prototypeit.blogspot.dk/
http://www.youtube.com/watch?v=jkWvA_uguRI
Is there a reason you changed the pin numbers?
It seems like it would be a good idea to try the code as is without making changes.
I found this quote:
While on the topic of Arduino, I recently worked with some Arduino code for the inexpensive MFRC522 readers. You might want to compare the 125 kHz device with the 13.56 MHz readers. I know the 13.56 MHz readers can be had for a few dollars (and a few weeks) from ebay. I posted a link to some Arduino code to use with these readers on Let's Make Robots recently. There's also a link to the Propeller version.
While the MFRC522 readers can be interfaced via SPI or I2C. I've only seen SPI code for it.
http://playground.arduino.cc/Learning/ParallaxRFIDreadwritemodule
Works with an arbitrary DIGITAL pins on arduino.
All i need now is adding my servo motor and im ready 4 googlesciencefair.
Thanks 4 your help.