RFID tagid, should tagid read match with printed id ?


I just received the 125Kz RFID reader with Wiegand interface. (compliments on the service ! :slight_smile:)
The example code provided doesn’t produce sensible output on my Seeduino v328, therefore I created my own sketch (attached at bottom of this post).

I get 5 different codes for my 5 tags (3 keyrings + 2 cards) which is fine, however the codes read do not match the codes printed on the keyrings.

Now the main question is: should the codes read match the printed codes ?

E.g. skipping the parity bits at the front and back one of my tokens returns:

Looking at the data sheet it seems that this should be interpreted as the last 3 bytes of a 4 byte long value.
(translation of the datasheet could be improved though :wink: )

As a long the bit sequence produces 6349670
The example code provided produces 4 decimals (although the latter is always 0 !)
Reading the bit string as 3 separate bytes produces: 96 227 102

The code on the keyring however is 0010427545.

If the codes read via RFID should match the printed codes then I am very curious what kind of coding is being used !! :slight_smile:

Kind regards,


// RFID Wiegand interface v3
// J. Klunder , September 3, 2009

// which ports to use
int data0 = 8;
int data1 = 9;

long card_num=0;

int bitnum;
boolean processBit(int d1){
   switch (bitnum) {
      case 0: // parity even 
      case 25: // parity odd + ready
        if (d1 == 0){

void setup(){
  pinMode(data0 , INPUT);
  pinMode(data1 , INPUT);

void loop(){
  int d0 = digitalRead(data0);
  int d1 = digitalRead(data1);
  if (d0 != d1){
    // we got signal ;-)
    if (processBit(d1)){
      // we got a complete sequence
      card_num=0; //reset card_number 
    delayMicroseconds(80); // Data impulse width delay 80us

I’ve noticed the same data-ID/printed-ID mismatch as well.

jklu thank you so much for this nice easy to understand code… it helped me very much for my “diplomarbeit” (masterthesis) about homeautomation with the arduino :slight_smile:

the c-code in the shop didnt work properly… it read in wrong values.
but yours is perfect :slight_smile:

best regards from hamburg