FDX-B 134.2 kHz RFID reader

That's correct @lentilcapacitor, it only has a Tx pin... the communication is one way. I'm getting readings at about 10-15cm... haven't had a chance to do any tuning yet.

Here is my code if you want to reuse it.


#include <SoftwareSerial.h>

SoftwareSerial RFID(7, 8);

byte b;
byte buffer[30];

uint8_t idx;
boolean started = false;

byte     XOR;
byte     inverted;

uint32_t   value;



void setup()
{
  Serial.begin (9600);
  RFID.begin (9600);
}

void loop()
{
  while (RFID.available())
  {
    b = RFID.read();

    if (b == 0x02) // Start byte
    {
      idx = 0;
      started = true;
    }


    if (started) // Ignore anything received until we get a start byte.
    {
      buffer[idx++] = b;

      if (b == 0x03) // End byte
      {
        started = false;
        
        
        // Display the received data.
        Serial.print("Received data: ");
        for (int x = 0; x < idx; x++)
        {
          if (buffer[x] < 0x10)
          {
            Serial.print("0"); // Pad with leading 0
          }
          Serial.print (buffer[x], HEX);
          Serial.print (" ");
        }
        Serial.println("");


        // Check we received the message ok.  XOR checksum on bytes 01-26 should match byte 27.
        XOR = buffer[1];
        for (int x = 2; x <= 26; x++)
        {
          XOR ^= buffer[x];  
        }
        Serial.print("Calculated checksum: ");
        Serial.print(XOR, HEX);

        if (XOR == buffer[27])
          Serial.println(" (Correct)");
        else
          Serial.println(" (Error)");


        // Check the inverted XOR checksum
        inverted = ~XOR;
        Serial.print("Inverted checksum: ");
        Serial.print(inverted, HEX);
        if (inverted == buffer[28])
          Serial.println(" (Correct)");
        else
          Serial.println(" (Error)");

        
        // Extract the card number from bytes 01 (LSB) - 10 (MSB).
        value = 0;
        for (int x = 10; x >= 1; x--)
        {
          if(buffer[x] <= '9')
            value = (value<<4) + buffer[x] - '0';  
          else
            value = (value<<4) + buffer[x] - '7';  
        }
        Serial.print("Card number: ");
        Serial.println(value);


        // Extract the country number from bytes 11 (LSB) - 14 (MSB).
        value = 0;
        for (int x = 14; x >= 11; x--)
        {
          if(buffer[x] <= '9')
            value = (value<<4) + buffer[x] - '0';
          else
            value = (value<<4) + buffer[x] - '7';  
        }
        Serial.print("Country number: ");
        Serial.println(value);


        // Extract the Data Block from byte 15.
        Serial.print("Data block: ");
        Serial.println(buffer[15] - '0');

        
        // Extract the Animal Flag from byte 16.
        Serial.print("Animal flag: ");
        Serial.println(buffer[16] - '0');

        Serial.println("\r");
      }
    }
  }
}

This is the output...

Received data: 02 33 39 38 44 38 35 42 30 30 30 36 44 33 30 30 31 30 30 30 30 30 30 30 30 30 30 79 86 03 
Calculated checksum: 79 (Correct)
Inverted checksum: 86 (Correct)
Card number: 190371987
Country number: 982
Data block: 0
Animal flag: 1
1 Like