Reading an RFID tag using a Wiegand Encoded RFID Reader
A while back I bought a couple of RFID readers from SeeedStudios – it was actually the first (of many) things that I picked up from there.
Right after I got the readers, I hooked one up to my Arduino, downloaded the test library that Seeed provided and got it to read some cards… then put it in a box with the intent of making something work, soon.
It took me a couple of years to get back to it – and the Netduino was my excuse… well, that and thinking about redoing the opener on my Garage door to add a door position monitor, temperature checking and possibly an RFID reader embedded in a secret location to open the door from the outside.
I decided to start with the Reader – since it would likely be the most difficult part. It took me a few hours – but turned out to be a great way for me to learn a bit more about how to develop for the Netduino.
It took some research for me to track down the documentation on the reader. But Seeed was very nice to still have a wiki page with the data for the reader: 125Khz RFID Module – Wiegand
I’m not quite sure what possessed me when I bought it, but instead of getting the serial port version, I got the version with the Wiegand encoded output…. I’m guess it was because the Wiegand format has greater range between the reader and the board... or something like that…
However, it did give me a good challenge to read the codes and learn some of the advance bits of the Netduino.
Very long story shortened quite a bit… Maybe I’ll fill this in more later.
I really need a logic analyzer – it would have made figuring some of this out a lot easier. I started with a poor man’s logic analyzer and hooked up the outputs of the reader to my Netduino:
RFID -> Netduino GPIO
PORT3 – LED -> D2
PORT1-DATA0 -> D3
PORT1-DATA1 -> D4
+5 & GND
First, I setup some interrupt pins and raised events as the data came in – and was able to pretty quickly make the inputs correspond to the datasheet.
Once I had the interrupt events working, I was able to build out the logic to decode the incoming bits and with some bit manipulation, I was able to get the value for the code printed on the tokens to appear on my Debugger console. (YEA!)
I incorporated all of the logic for the reader into a library that I can use for other stuff – again, good practice for using the Netduino.
There is still some work to do – I’m not checking the parity of the values yet. But it should be pretty complete for reading and decoding the Wiegand formatted data. (As long as it is the 26 bit variety)
Here is the library for reading and decoding the value:
And this is the sample code that will use the library to display the serial number of the tag in the debugger: