I make it works with the code below, but it's always checking id tags.. I want that the reader stay in stand-by if there is no card to scan, what i have to do?
You need to make up your mind what you want.
RFID.write(0xAB);
RFID.write(0x02);
RFID.write(0x02);
You are telling the reader to send data whenever a card is scanned.
val = RFID.read();
Serial.println();
while (val != 0xAB){
val = RFID.read();
delay(10);
}
Then, you go into an infinite loop waiting for the start of tag data.
As soon as the start of tag marker arrives:
RFID.read();
RFID.read();
data[0] = RFID.read();
data[1] = RFID.read();
data[2] = RFID.read();
data[3] = RFID.read();
You read 6 bytes of data that have not yet arrived. How is that useful?
The RFID.available() function bears looking into. It will tell you how much data is available to read. Since you only seem to be concerned about the next 6 bytes, after the start marker arrives, you should have an if(RFID.available() > 0) block that then reads a character, and checks if it is a start marker. If it is, there should be a
while(RFID.available() < 6) { // Do nothing }
statement that blocks, waiting for the data of interest to arrive.