Sunday, January 13, 2013

Reading RFID With Raspberry Pi (or any linux device) + Reader

I'm using the following Parallax USB RFID reader: http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/28140-28340-RFIDreader-v2.2.pdf

First you will need to ensure you have PySerial installed by trying to "import PySerial" while running Python's IDLE. If you receive an error:
Install PySerial:
    1. Install python's setuptools: apt-get install python-setuptools
    2. Install PySerial: pip install pyserial

Once you have PySerial installed, open IDLE again and use the following code to see output from the reader:


Why didn't ser.read(12) return the same unique identifier as what is written on the fob?:
  • If the key on the card says 30788590 and the reader returns 3501D5CBEE. The "1D5CBEE" part is the card number. Try going from the card number in DEC to HEX it in the windows calculator while it's in scientific mode if you don't believe me.

5 comments:

  1. I'm curious about your "string = string[2:]" statement. Granted I have the serial version of the same reader, but the 12 byte string my reader sends consists of a start byte x0A, then the unique 10 character identifier and lastly a stop byte x0D.

    So I remove the start and stop bytes with a "string = string[1:11]" statement, which leaves just the 10 character ID for comparison to stored ID's.



    ReplyDelete
  2. "string = string[2:]" removes the first two hex characters because they're not part of the number on the card/fob. My requirement was to convert output from the reader into what's on the front of the card.

    With all 10 characters: 0F0184F07A = 64449998970 (not what's on the card.

    With only 8 characters: 0184F07A = 25489530 (what IS on the card)

    Not sure what the significance of those first two characters are. Maybe they're some type of checksum?

    ReplyDelete
  3. I get the following error
    ValueError: invalid literal for int() with base 16

    When I dont convert my data to an int it looks like this
    \xae\xf6v\xd6VE\xcb\xf5\x95\x00

    How should I go about converting that to a normal string?

    ReplyDelete
  4. I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information. rfid tags

    ReplyDelete
  5. I used your code to read an RFID tag using EM reader. I am getting only a null response after getting the beep sound from the reader. What is the solution?

    ReplyDelete