Cheap Chinese 125khz RFID reader 'Picaxed'

Haku

Senior Member
After reading this entry on Hack-a-Day: http://hackaday.com/2011/11/19/getting-useful-data-from-a-dirt-cheap-rfid-reader/ I ordered one of those cheap RFID readers for myself from this eBay seller: http://www.ebay.co.uk/sch/gbmsale/m.html?_nkw=125khz+rfid (note: it took 3.5 weeks to arrive)
I also ordered 10 125khz RFID keychain tags a week later, they haven't arrived yet but luckily I already have a glass capsule 125khz tag to test with.

When plugged into a PC it pretends to be a USB keyboard, placing a tag next to the antenna causes it to be read and then the red LED blinks green and a loud beep is emitted (you'll be searching for tape or blu-tack to dampen the sound) and the 10 digit number is 'typed out' with an Enter on the end.

But this unit is dead easy to use with a Picaxe, there's an unused pinheader point on the circuitboard with 4 lines; +5v, GND, Serout and one I have no idea what it does.


(click pictures for bigger)


To read the tag with a Picaxe you simply hook the +5v, GND & Serout to the Picaxe (a resistor on the serial line won't hurt), then read in the data at 9600 baud. This is an example of the 19 numbers the Picaxe will receive:

189 5 30 39 36 32 36 5 3 189 6 35 30 38 33 38 40 5 3

And the actual tag ID in this instance is 1073769149. So how do you extract that number? easily, you only need the 3rd, 4th, 5th, 6th, 7th, 12th, 13th, 14th, 15th, 16th numbers which are USB scan codes, read the comments in the Hack-a-Day link above for a more detailed explanation of the serial data the Picaxe received.

This little program for M2/X2 parts will read in and output the scanned RFID tag number through your programming cable:
Code:
#picaxe 08m2
#no_data
#terminal 19200

setfreq m16

symbol RFID=c.1
symbol RFIDbaud=t9600_16

main:
 bptr=28
 serin [800,main],RFID,RFIDbaud,@bptr,@bptr,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr,@bptr,@bptr,@bptr,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr
 bptr=28
 for b0=1 to 10
  b1=@bptrinc
  b1=b1-29//10
  sertxd(#b1)
 next b0
 sertxd(cr,lf)
goto main
The use of the @bptr & @bptrinc in the serin line mean only the 10 relevant numbers are captured & stored in memory, the b1=b1-29//10 line is for turning the captuired USB scan codes for "0"-"9" into 0-9.

Main loop for non-M2/X2 parts:
Code:
main:
 serin RFID,RFIDbaud,b0,b0,b0,b1,b2,b3,b4,b5,b5,b5,b5,b5,b6,b7,b8,b9
 b0=b0-29//10
 b1=b1-29//10
 b2=b2-29//10
 b3=b3-29//10
 b4=b4-29//10
 b5=b5-29//10
 b6=b6-29//10
 b7=b7-29//10
 b8=b8-29//10
 b9=b9-29//10
 sertxd(#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7,#b8,#b9,cr,lf)
goto main
Bonus points for anyone who can write a short piece of code to turn the 10 digit decimal number (actually a 32bit number) into two 16bit numbers the Picaxe can easily & quickly cope with for comparing against known IDs stored in memory, it'll also make storing tag IDs take up just 4 bytes instead of 10.

What am I going to do with this RFID reader? I haven't got the foggiest, I just wanted another electronic toy in my toolbox to tinker with and the price was right.
 

westaust55

Moderator
Thanks for posting your project Haku.
While no immediate need, having such information available here can allow a rapid start should the need for a project based on the same RFID module arise. Likely even some other clones will be the same/similar.

IMHO, this is how more "Finished" projects should be posted.
Photo or two, schematic or conenction details, some description and demo/working PICAXE code.
A link to a You-tube video with nothing to enable others to replicate the project is little more than a "Brag" post.
 

rinthesun

New Member
If you look at Wiegand 26 code-where this all started- you will see that the info on the card is stored as 10 hex digits. So that is what you see when the card is read with a Wiegand 26 reader. The UART serial readers, such as the Parallax, outputs this hex string as a ascii string with start and stop characters. The card data can be stored in memory as 5 bytes with 2 hex digits each, i.e., 40 bits. This gives 2 exponent 40 unique codes.

I do not understand this reader. I assume it is outputting keyboard scan codes. 0x31 is keyboard scan code for "1" which is also ascii character code. Is this reader outputting hex or has it converted it to decimal?

I have both a Wiegand and UART reader as well as this cheap reader so I will soon know.
 
Last edited:

westaust55

Moderator
Is this reader outputting hex or has it converted it to decimal?
In general all modern (not aware of any that do not but you never know) computers, micro controllers, etc work in binary. An exception in the past was "Analog" computers.
However for ease of readability by us humans we get the PC's etc to show the data in decimal or hex formats or ASCII encoded.
so %01010101 = $55 = 0X55 = 85 decimal = "U" ASCII

some file formats do add the $ or "0X" to the front of values for file dumps, but at the end of the day it is there for us humans not the computers.
 
Last edited:

DakLak

New Member
This might be a very useful security device for a vehicle.

Presently I use a disabler on my motorcycle, with a concealed trigger.

Your handy article might point the way to a far better solution, an RFID tag that is not seemingly an alarm/security device as might a fob with buttons.

Thanks for the idea.
 

SteveT

Senior Member
Haku, I don't suppose you know the max distance the reader detects your glass tag? I was thinking about using an rfid reader some time ago with an 'N' gauge model railway. Detector under the track, glass capsule on the bottom of rolling stock to trigger a picaxe to play 'station announcements' using your excellent find of the MDfly mp3 player.
 

stevesmythe

Senior Member
Correction

In case anyone tries Haku's code for M2/X2 parts, I think there is an error. As it stands, it skips one too many characters and adds an extraneous one at the end. The serin line should be:
Code:
serin [800,main],RFID,RFIDbaud,@bptr,@bptr,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr,@bptr,@bptr,@bptr,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr
(I have deleted one instance of @bptr).
 
Top