RFID Reader - Wiegand 34 and UART. Is this even possible?

Hello All!

I have a reader connected to the Arduino via Wiegand 34. That is working fine, 34 bits, 1st bit parity of the first 16 bits, last bit parity of the last 16 bits and the 32 bits in the middle Facility + Card Number.

I also have another Arduino with a RFID reader/writer module:
http://www.ebay.co.uk/itm/200868439895?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

It's connected via serial UART interface and the problem is that the same card doesn't give me the same number at all. I thought I could convert the number from UART to Wiegand but I looked all over the internet and I start thinking it's not even possible.

Any idea or link that can point me in the good direction?

Thanks in advance!

I have a reader connected to the Arduino via Wiegand 34.

This is a bit like saying "I have my Arduino connected to a servo via Spanish." It doesn't make sense, and tells us nothing about the reader, the wiring, the software, or the cards.

I also have another Arduino with a RFID reader/writer module

Now, this is a lot better.

It isn't obvious at all the both readers read the same kinds of cards.

Just meanwhile I was writing this post I found the solution. Actually there was nothing to find the code was giving me the serial card number backwards.

This is a bit like saying "I have my Arduino connected to a servo via Spanish." It doesn't make sense, and tells us nothing about the reader, the wiring, the software, or the cards.

Obviously I don't express myself properly. Sorry about that. I have this reader (http://www.aliexpress.com/snapshot/214317754.html) connected to an arduino Mega. Wiring: DATA0 Pin 2, DATA1 Pin 3.

This is the code (GitHub - johannrichard/SeeedRFIDLib: Arduino RFID Tool for SeedStudio's (and possibly other) RFID Readers with both an UART and Wiegand Interface implementation.):

#include <Wiegand.h>

WIEGAND wg;

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

void loop() {
	if(wg.available())
	{
		Serial.print("Wiegand BIN = ");
		Serial.print(wg.getCode(),BIN);
                Serial.print(", Wiegand HEX = ");
		Serial.print(wg.getCode(),HEX);
		Serial.print(", DECIMAL = ");
		Serial.print(wg.getCode());
		Serial.print(", Type W");
		Serial.println(wg.getWiegandType());    
	}
}

Response:
Wiegand BIN = 10010011101110000111010100001010, Wiegand HEX = 93B8750A, DECIMAL = 2478339338, Type W34

And this reader (http://www.ebay.co.uk/itm/200868439895?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649) connected to an arduino Uno.

#include <SoftwareSerial.h> 
SoftwareSerial mySerial(2, 3); //pin2 Rx, pin3 Tx 

int CMD[64];
int comlen =0;
int out_flag =0;

void setup() 
{ 
Serial.begin(9600);
mySerial.listen();
Serial.println("Serial number will be displayed here if a card is detected by the module:\n"); 
// set the data rate for the SoftwareSerial port 
mySerial.begin(9600); 
delay(10);
mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual 

} 
void loop() // run over and over 
{ 
      
      while (Serial.available()) 
      {
          int a = SerialReadHexDigit();
          if(a>=0){
          CMD[comlen] = a;
          comlen++;
          }
          delay(10);
      }
      
      for(int i=0; i<comlen; i+=2){
          int c = mySerial.write( CMD[i]*16 + CMD[i+1]);
          Serial.print(c);
        }
      comlen =0;
      
      while (mySerial.available()) {
      byte C = mySerial.read();
      if (C<16) Serial.print("0");
      Serial.print(C ,HEX); //Display the Serial Number in HEX 
      Serial.print(" ");
      out_flag =1;
      }
     if (out_flag >0) {
       Serial.println();
       out_flag = 0;
     }
     
}



int SerialReadHexDigit()
{
    byte c = (byte) Serial.read();
    if (c >= '0' && c <= '9') {
        return c - '0';
    } else if (c >= 'a' && c <= 'f') {
        return c - 'a' + 10;
    } else if (c >= 'A' && c <= 'F') {
        return c - 'A' + 10;
    } else {
        return -1;   // getting here is bad: it means the character was invalid
    }
}

Response: 0A 75 B8 93

Thanks for your reply. Hope that helps someone. :slight_smile:

Hellow trikerr

I think that your card number from your two reader is same data except of byte ordering.

your wiegand reader get 0x93B8750A hex decimal and

your rs232 reader get 0x0A75B893 hex decimal

so if you want a card number from rs232 reader like wiegand card reader then you shoud make byte ordering

such as 0A 75 B8 93 => 93 B8 75 0A

Byte order is determined by CPU on reader so your both card reader's cpu will be different.

I'm not good at English but I think you will get see BYTE ORDER