RFID number-difference

Hello Arduino-friends,
I have a question to my RFID starter code.

On my RFID TAG is the number “0007912551”

The serial monitor says “9 9 8 8 5 6 6 7 4 5 6 0”

#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3); // Pin 2 & 3

String ID;


void setup()
{
  RFID.begin(9600);    // Verbindung zum RFID Modul
  Serial.begin(9600);  // Verbindung zum PC
}

void loop()

{
  if (RFID.available() > 0) 
  {
     ID = RFID.read();
     ID = ID.substring(1,13);
     Serial.print(ID);
     Serial.print(" ");
  }
  
}

Why the difference?

greeting from Germany

What RFID reader?

RDM6300 EM4100

125 Khz

RonSH:
Hello Arduino-friends,
I have a question to my RFID starter code.

On my RFID TAG is the number "0007912551"

The serial monitor says "9 9 8 8 5 6 6 7 4 5 6 0"

Why the difference?

greeting from Germany

I think some RFID feaders return more digits than just the ID code of the tag.

A couple of years ago I did some testing with a reader which returned 14 digits from a 10 digit RFID card:

  • // 2 digits manufacturer code
  • // 10 digits card code
  • // 2 digits parity bits
    = 14 digits returned in total while the card code is only 10 digits

And in your code you create many extra spaces in the serial output with this line of code:

Serial.print(" ");

Do you really want to invent extra space characters with your code and mixing them into the serial output?

BTW: Function call " RFID.read()! will read just one single character from the SoftwareSerial input

On my RFID TAG is the number “0007912551”

The serial monitor says “9 9 8 8 5 6 6 7 4 5 6 0”

I used to work designing RFID readers and access control systems.

Often the number printed on the tag has no relationship with the number stored in the tag. This is for security reasons, and prevents easy duplicating of tags. Often the number on the tag is scrambled by the reader before passing it on to the rest of the access control features as well.

An EM4100 tag has no digits manufacturer code, or any other “special” bits unless the vendor requests them. It will simply send all of the 64 bits programmed into the tag at manufacture.

In this link em4001 protocol they have chosen to put parity bits into them reducing the useful code to just 40 bits. It is important to note that this is not compulsory and many “custom” tags can be made by not having these parity bits.

I can better read 9 9 8 8 5 6 6 7 4 5 6 0 as 998856674560

My next problem is if I put the chip on the reader longer as 1 sec,
the number is more often.

998856674560998856674560998856674560

If I change the code with a

delay(5000);

at the end,
the serial monitor write every 5 sec. two numbers.

99
5 sec. later
88
5 sec. later
56
etc.....

Sorry for my englisch :wink: I hope, you understand me

Might have something to do with this...

jurs:
BTW: Function call RFID.read() will read just one single character from the SoftwareSerial input

Do you have a idea for a new code?

"If the code insert, wait 5-10 sec. and read again"

thank you guys

That number is 12 digits long. Just don't read anything from the serial port until you have at least 12 digits in the serial buffer. Then read 12 bytes and print them out and then print a new line character or a Serial.println then each read will come out on a new line.

RonSH:
Do you have a idea for a new code?

You want a new code for initial testing and debugging your RFID reader and tag?

Perhaps try your old code, but change the loop function to different code:

void loop()

{
  if (RFID.available() > 0) 
  {
  char c=RFID.read();
     Serial.write(c);
  }
  
}

Open and watch the serial monitor, do some tag readings, copy and paste the output from the serial monitor here.
Let's see what you get then.

Some of the characters received may not be printable. Might be better to display in HEX:

void loop() {
    int character = RFID.read();
    if (character != -1)
        Serial.prinln(character, HEX);
}

I edit the code to

void loop() {
    int character = RFID.read();
    if (character != -1)
        Serial.prinln(character, HEX);
}

The answer is "231313030373842433637423"

What can I do for a 5 sec. break?

If I need delay(5000),

the serial monitor write every 5 sec. two numbers.. 23 break 13 break...

RonSH:
The answer is “231313030373842433637423”

23 13 13 03 03 73 84 24 33 63 74 23

That doesn’t look at all right. Isn’t it supposed to return 0x02 (SOH: Start of Header), 10 ASCII digits, a 1 byte checksum and 0x03 (ETX: End of Text)? Maybe the baud rate is wrong? You should try other rates to see if any return the expected pattern of bytes:
02 30 30 30 37 39 31 32 35 35 31 E2 03

I wonder how your program translated that mess into “998856674560”.