I have the 13.56MHz RFID reader hooked to an arduino. I can succesfully read MIFARE tags using the MF_GET_SNR command. However, I need to read ISO 15693 tags.
When I try to send the example data from the documentation: AA 00 04 10 06 00 00 12 BB
I always get this response: AA 00 02 01 85 86 BB
- status = 01 = Command FAILURE
- error = 85 = The parameter of the command or the Format of the command Erro)
I worked through the ISO 15693 specification documents and I think that the data send is correct. Am not sure about the last 0x00 byte though, that looks like its too much (no mask!) but I get the same response when i leave it out (obviously with changed data length to 3 and correct checksum).
Any help/hints are much appreciated! cheers
I attached a sample sketch, had to zip it so the board would allow me to upload it.
here is the code anyway:
/* Using Arduino Mega, if you don't have a Mega, use Software Serial library */
byte FLAG_SUB_CARRIER = 0b00000001;
byte FLAG_DATA_RATE = 0b00000010;
byte FLAG_INVENTORY = 0b00000100;
byte FLAG_PROTOCOL_EXTENSION = 0b00001000;
byte FLAG_AFI = 0b00010000;
byte FLAG_NB_SLOTS = 0b00100000;
byte FLAG_OPTION = 0b01000000;
byte FLAG_RFU = 0b10000000;
byte STX=0xAA; //header
byte ETX=0xBB; //footer
byte STATION=0x00;
byte DATA[255] = {};
byte RESPONSE[255] = {};
boolean statusOK() {
return RESPONSE[3] == 0;
}
void sendData(byte data[], int length) {
for ( int n = 0; n < length; n++ )
Serial1.print(data[n],BYTE);
}
/*
* problems with this command
*
*/
void ISO_15693_INVENTORY() {
byte FLAGS = FLAG_DATA_RATE | FLAG_INVENTORY;
byte MASK_LENGTH = 0x00;
byte DATA_LENGTH = 3;
byte CMD = 0x10;
byte CRC = STATION ^ DATA_LENGTH ^ CMD ^ FLAGS ^ MASK_LENGTH;
byte d[] = {STX, STATION, DATA_LENGTH, CMD, FLAGS, MASK_LENGTH, CRC, ETX};
sendData(d, 5+DATA_LENGTH);
int bytesReceived = read_response();
Serial.println("Response:"); // usually AA 00 02 01 85 86 BB
for ( int n = 0; n < bytesReceived; n++ ) {
Serial.println(RESPONSE[n], HEX);
}
}
/*
* got this working
*
*/
void MF_GET_SNR() {
byte d[] = {STX, 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, ETX};
sendData(d, 8);
//delay(5);
int bytesReceived = read_response();
if ( statusOK() ) {
//Serial.println("OK");
unsigned long id = 0b00000000000000000000000000000000;
unsigned long id_byte1 = RESPONSE[5];
unsigned long id_byte2 = RESPONSE[6];
unsigned long id_byte3 = RESPONSE[7];
unsigned long id_byte4 = RESPONSE[8];
id = id | id_byte1<<24 | id_byte2<<16 | id_byte3<<8 | id_byte4;
Serial.println(id, DEC);
}
}
int read_response()
{
delay(20); // wait for the response, could be improved...
byte incomingByte;
int length = 0;
while (Serial1.available() > 0)
{
// read the incoming byte:
incomingByte = Serial1.read();
RESPONSE[length] = incomingByte;
length++;
}
return length;
}
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);
}
void loop()
{
ISO_15693_INVENTORY(); //having problems with this call...
while(1) {
MF_GET_SNR(); // works
}
}
RFID_FOR_FORUM.zip (1.05 KB)