ID12 RFID Reader

An RFID reader module that reads tags and sends the ID as a 9600-8N1 serial stream

Hello World!

Import program

00001 // Hello World for printing RFID tag numbers
00002 
00003 #include "mbed.h"
00004 #include "ID12RFID.h"
00005 
00006 ID12RFID rfid(p14); // uart rx
00007 
00008 int main() {
00009     printf("Hello World\n");
00010     while(1) {
00011         if(rfid.readable()) {
00012             printf("RFID Tag number : %d\n", rfid.read());             
00013         }
00014     }
00015 }

ID12 RFID Hello World Schematic ID12 RFID Hello World breadboard

Library

The mbed library for the ID12 RFID reader, returning the 32-bits of the ID as an int

Import library

Public Member Functions

  ID12RFID (PinName rx)
  Create an ID12 RFID interface, connected to the specified Serial rx port.
int  readable ()
  Non blocking function to determine if an ID has been received.
int  read ()
  A blocking function that will return a tag ID when available.

Reference




1 related question:

0
answers
test Dan Ros
4 months, 3 weeks ago

team, test


16 comments:

11 Jun 2010

Hey this looks really awesome, any idea how well it might possibly port over to the ID-20?

11 Jun 2010

Hi Jorge,

I imagine that would be quite simple, yes. Assuming they are quite similar (you'll have to compare the data sheets to confirm), if you look at the code it is not doing all that much, so i'm confident you could get it working without too much trouble.

Simon

11 Jun 2010

Simon Ford wrote:

Hi Jorge,

I imagine that would be quite simple, yes. Assuming they are quite similar (you'll have to compare the data sheets to confirm), if you look at the code it is not doing all that much, so i'm confident you could get it working without too much trouble.

Simon

I got it working flawlessly, no changes were required. The code and the pin-out are exactly the same. Thanks much.

02 Feb 2011

/media/uploads/4180_1/id12breakout-01-l_i_ma.jpg

http://www.sparkfun.com/products/8423 is a $.95 breakout board for both the ID-12 and ID-20 from Sparkfun. Pins are spaced 2mm and not .1 inch. They also sell the ID-12 and ID-20. In the UK SKPang also has them.

28 Mar 2011

Hi Simon!

This is a great example, is there something similar for java. Someway to call it and read the input with mbed. Is is something similar to 'Interfacing With Java'?

Sorry for such novice questions, I know what I want to achieve from the setup but its the how to that is confusing me, very new I just received my mbed last week.

Thanks in Advance!

20 Apr 2011

Hello Simon, So I compiled the program in the mbed online compiler and it compiled with success. And I downloaded the bin file into mbed memory. But how do I see the output? Where does the RFID number appear? I am sorry I am still quite new with this and today is the first time I used the compiler here.

Thanks.

22 Apr 2011

Hi guys, so I figured out the terminal output issue. I was able to run the code and view the output in putty. But I am getting more issues.. the program runs, prints "Hello World" but when I try to read a 125khz rfid card, it doesn't print anything? I have the ID12 and have connected it exactly as you mention here. In fact me and some of my colleagues have worked on it together... still no read on the cards.. do you know what could be causing something like that? It might be an obvious thing, but I have never worked on RFID before..

Thanks guys, I am making slow progress, getting there day by day.. just so much new stuff..

03 May 2011

How can I use serial interrupt with this? I believe I need to modify the library and add a interrupt method but can't quite understand how exactly to do it

26 Sep 2011

Just found and corrected a 'Bug' in RFID code,

Previously, the ID Number read back was treated as a decimal number, not a HEX String, My fix corrects this.

#include "ID12RFID.h"

#include "mbed.h"

ID12RFID::ID12RFID(PinName rx)
        : _rfid(NC, rx) {
}

int ID12RFID::readable() {
    return _rfid.readable();
}

int ID12RFID::read() {
    while (_rfid.getc() != 2);

    int v = 0;
    _rfid.getc(); // drop 1st 2 bytes - we actually only read the lower 32-bits of the code
    _rfid.getc();

    for (int i=7; i>=0; i--) {
        char c = _rfid.getc(); // a ascii hex char
        int part = c - '0';

	// test if 'Alpha'

	if (part > 9) part -= 7;     // Quick & dirty !
	
	
        v |= part << (i * 4);
    }
    
    for (int i=0; i<5; i++) {
        _rfid.getc();
    }
    
    return v;
}

Hope this is of use

Ceri

09 Apr 2012

Hi, Can somebody please let me the interfacing to get an output on my PC.

Thank you:)

10 Apr 2012

the code at the top of this page will send the serial number to the PC,

using your favorite terminal program.

:-) ceri

25 Nov 2012

Hey, thanks very much to all out there for your help! This code does indeed work with the ID-20. It took a couple of hours to get to go and the datasheet was very helpful.

Thank you :o)

29 Apr 2013

Gentelmen, I'm trying to use this code to create a program using VS 2012. I can "include" the "ID12RFID.h" file, but the "mbed.h" file is needed, and this only includes other libraries. I need this for the uni project. Could anyone help me with adapting this code? Many thanks

11 Sep 2013

Hello,

I need to read RFID tags from 2 separate ID-12 reader. But this does not work when both rfid readers are connected !! No chars go out both ID-12 The code read well when only one rfid reader is connected (+5v disconnected on the other, not only Rx). One or the other work well, but not both simultaneously.

To do so, I connect 2 ID-12 respectively on rx pins 10 and 14. The code is : Print RFID tag numbers

  1. include "mbed.h"
  2. include "ID12RFID.h"

ID12RFID rfid1(p10); serial1 rx

ID12RFID rfid2(p14); serial2 rx

int main() {

printf("test twin simultaneous RFID ID-12 devices \n");

while(1) {

if(rfid1.readable()) {

printf("RFID Tag number : %d\n", rfid1.read());

}

if(rfid2.readable()) {

printf("RFID Tag number : %d\n", rfid2.read());

} } }

I have suspected various hypothesis :

- not enough 5V supply (ID-12 require 30 mA, VU fall to 4,2V when both ID-12 are connected), but nothing better with and external power supply :-(

- devices may be too near from each other (RF could perturbate ?). Adding a long cable to have a 2 meter distance don't solve the problem :-((

- to see if there is RF influence, I tried 2 ID-12 but with 2 separate MBED : both work fine but separately :-(((

Anyone could tell me what is wrong ?

Thanks in advance. Dominique

21 Sep 2013

Anyone know if this will work with 15 digit RFID tags?

20 Nov 2013