# FDX-B 134.2 kHz RFID reader

**URL:** <https://forum.arduino.cc/t/fdx-b-134-2-khz-rfid-reader/912859>\
**Category:** General Electronics\
**Created:** [October 8, 2021, 6:55am UTC](https://forum.arduino.cc/t/fdx-b-134-2-khz-rfid-reader/912859 "2021-10-08T06:55:55Z")\
**Posts on this page:** 1\
**Showing post:** 55

<div class="post-metadata">

**Author:** ![logitech974](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logitech974/32/1013044_2.png) [@logitech974](https://forum.arduino.cc/u/logitech974)\
**Post date:** [October 5, 2022, 12:24pm UTC](https://forum.arduino.cc/t/fdx-b-134-2-khz-rfid-reader/912859/55 "2022-10-05T12:24:12Z")

</div>

Hi!

@red_car , can you help with my coding?  
I copied your code and hooked up my arduino and rfid reader and reads small chips and both of my cats. Now i want a action/ command to happen when a certain "chip/ cat" activates the rfid.

Here's the code

\<  
#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()  
{

String content = "";  
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 what i get :

Received data: 02 37 30 36 36 35 34 46 30 32 33 34 38 33 30 30 31 30 30 30 30 30 30 30 30 30 30 7F 80 03  
Calculated checksum: 7F (Correct)  
Inverted checksum: 80 (Correct)  
Card number: 256206343  
Country number: 900  
Data block: 0  
Animal flag: 1

How can i code it so just my cat can activate it?

Thanks!

---

_[View the full topic](https://forum.arduino.cc/t/fdx-b-134-2-khz-rfid-reader/912859)._
