Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone! I am currently having a big issue with an RFID Reader. I'm trying to read data from this reader from Amazon right here, which only supports Wiegand 26 an 34 transmissions, using an ESP32 device and utilizing this library from github.

I know that the library is shown to be for Arduino devices, but it contains functionality for ESP32 devices as well. I wanna get the right results, but I just can't get it right, and would highly appreciate all help. I'm just trying to grasp the functionality, so that I can write my own software with it in C only.

What I have tried:

I tried out the library I've linked above, and created a simple program using PlatformIO that matches the one on the GitHub page, using the pins I've chosen:

C++
#include <Arduino.h>
#include "Wiegand.h"

WIEGAND wg;

void setup() {
  // put your setup code here, to run once:
  pinMode(GPIO_NUM_23, OUTPUT);
  Serial.begin(9600);

  wg.begin(GPIO_NUM_18, GPIO_NUM_21);
  digitalWrite(GPIO_NUM_23, LOW);
}

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

The digitalWrite function sets the reader in either WG26 or WG34 mode, right here in WG34 Mode, which is (probably) the right length. That being said, holding a card against it produces this output:

Quote:
Wiegand HEX = D1E24D, DECIMAL = 13754957, Type W34

This is not the result it is supposed to give. According to the ID I got from a brand reader, it should be this: 1204937293. Mind you, the application labels it SNR, which might as well stand for serial number. The Raw Data Output of this card would be 0000000000004DE2D147, and the card type is a Legic Advant 14443. I've tried changing the modes, the output stays the same. I'd appreciate any hints and tips, everything helps!
Posted
Updated 5-Nov-22 0:56am
v2
Comments
Majestic Frog 2-Feb-22 7:00am    
Comment: It could be that the reader I have isn't compatible with the cards I'm using. Apparently not all RFID readers read the same way.

It looks the library is gathering the bits correctly ( 1204937293 = 0x47D1E24D, you see, the last 3 bytes are shown reversed in the output you posted).
but is assuming some particular message format while presenting them.
You may have a look at library code and adapt it to your needs.
 
Share this answer
 
w26 generally uses 2 site digits and 4 ID digits with the site sent first, then the ID, BUT each part is sent in reverse order. So if the code is p1 Site1 Site2 ID1 ID2 ID3 ID4 p2 it gets encoded as p2 ID1 ID2 ID3 ID4 Site1 Site2 p1 with p1 being even parity of ID4 + Site1 + Site2 and p2 being odd parity for ID1 + ID2 + ID3.
w34 just adds 2 more BCDs, 1 to Site3 and 1 to ID5.

Either the wiegand library or the tag supplier is not doing the coding order properly, but for verification purposes checking the parity then comparing the whole 24 bits with a database will work fine.

bye
 
Share this answer
 
Found the statement that the library usually passes the order of the bytes as they come in over the data lines. There should be readers that can invert the read data, otherwise you can write a function that inverts the bytes (BIG- LITTLE ENDIAN Converter).

Code can be found e.g. here:
https://stackoverflow.com/questions/2182002/convert-big-endian-to-little-endian-in-c-without-using-provided-func
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900