Hi,
I m trying to test this rfid card.
So i follow this tuto : Arduino Playground - ParallaxRFIDreadwritemodule
The led is red. But i can t read my tags Parallax 125khz 50mm circle.
Is the good tag?
Thks for the help
regards
Hi,
I m trying to test this rfid card.
So i follow this tuto : Arduino Playground - ParallaxRFIDreadwritemodule
The led is red. But i can t read my tags Parallax 125khz 50mm circle.
Is the good tag?
Thks for the help
regards
http://www.parallax.com/Portals/0/Downloads/docs/prod/rf/28440-RFIDReadWrite-v1.0.pdf
To read the 40-bit serial number of a legacy read-only tag you have to use the "RFID_ReadLegacy" command.
Ok, i change to use RFID_ReadLegacy
But it s not working fine.
On exit i got 255 when there is no tags and 10 when i approach a tag.
Any idea?
#include <NewSoftSerial.h>
#define RFID_READ 0x01
#define RFID_ReadLegacy 0x0F
#define txPin 6
#define rxPin 8
#define whichSpace 4
NewSoftSerial mySerial(rxPin, txPin);
int val;
int runs = 0;
void setup()
{
Serial.begin(9600);
Serial.println("RFID Read Test");
mySerial.begin(9600);
pinMode(txPin, OUTPUT);
pinMode(rxPin, INPUT);
}
void suppressAll() //suppresses the "null result" from being printed if no RFID tag is present
{
if(mySerial.available() > 0)
{ mySerial.read();
suppressAll();
}
}
void loop()
{
int val;
//Serial.print("test");
mySerial.print("!RW");
mySerial.print(RFID_ReadLegacy, BYTE);
//mySerial.print(whichSpace, BYTE);
if(mySerial.available() > 0)
{
val = mySerial.read(); //The mySerial.read() procedure is called, but the result is not printed because I don't want the "error message: 1" cluttering up the serial monitor
Serial.print("Donne : ");
Serial.println(val, DEC);
if (val != 1) //If the error code is not 1, then there has been an error and the RFID tag was not read correctly.In this case we don't really care about the resultant values, so they can be suppressed
{suppressAll();}
}
if(mySerial.available() > 0) {
val = mySerial.read();
Serial.print("1st:");
Serial.println(val, DEC);
}
if(mySerial.available() > 0) {
val = mySerial.read();
Serial.print("2nd:");
Serial.println(val, DEC);
}
if(mySerial.available() > 0) {
val = mySerial.read();
Serial.print("3rd:");
Serial.println(val, DEC);
}
if(mySerial.available() > 0) {
val = mySerial.read();
Serial.print("4th:");
Serial.println(val, DEC);
Serial.println("-----------------");
}
delay(750);
}
Unlike the RFID_Read command the RFID_ReadLegacy command returns:
0x0A, 10 characters, 0x0D
Thanks.
Here my working code.
The card wait to have all the data to print it.
#include <NewSoftSerial.h>
#define RFID_READ 0x01
#define RFID_ReadLegacy 0x0F
#define txPin 6
#define rxPin 8
#define whichSpace 4
NewSoftSerial mySerial(rxPin, txPin);
int val;
int runs = 0;
void setup()
{
Serial.begin(9600);
Serial.println("RFID Read Test");
mySerial.begin(9600);
pinMode(txPin, OUTPUT);
pinMode(rxPin, INPUT);
}
void readMe() {
int a = 0;
while( mySerial.available() >0 && a<10) {
if(a==0) Serial.print(" INFO: ");
val = mySerial.read();
Serial.print(":");
Serial.print(val, DEC);
a++;
}
Serial.println();
}
void loop()
{
//mySerial.print(whichSpace, BYTE);
int total = mySerial.available();
if(total > 0)
{
val = mySerial.read();
if(int(val)==255) {
// Serial.print("RIEN ");
mySerial.flush();
mySerial.print("!RW");
mySerial.print(RFID_ReadLegacy, BYTE);
} else {
readMe();
}
} else {
mySerial.print("!RW");
mySerial.print(RFID_ReadLegacy, BYTE);
}
delay(850);
}
void suppressAll() //suppresses the "null result" from being printed if no RFID tag is present
{
if(mySerial.available() > 0)
{ mySerial.read();
suppressAll();
}
}
Why is this function recursive? A while loop would be better, or a simple call to mySerial.flush() which empties the serial buffer.
i didn t use it in the new code
it come from the original tuto