RFID-12 reader and UNO interface

I am new to the arduino programming and i really need some help to program an RFID-12 reader into my UNO board. I am trying to make this project i found on instructables, http://www.instructables.com/id/Arduino-RFID-Door-Lock/?&sort=ACTIVE&limit=40&offset=200#step5 and am having trouble programming my RFID-12 reader to my uno board. Any suggestions?

here is the reader i am using


Note: I read i need to connect the rfid reader to my arduino and open the serial monitor then copy the numbers from there onto my code. Would these numbers the serial monitor gives me the same as the ones printed on RFID cards?

I think I have the same board (it's and ID12) and I wired it up the way they suggested. You only need 3 wires to your Arduino: +5v, GND, and serial out (D0) which you plug into D0 on the Uno (Rx). This sketch:

void setup()
  // start serial port at 9600 bps:

#define MAX_ID 20

char cur_id [MAX_ID] = "";
int len = 0;

void loop()
  char inByte;
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    // get incoming byte:
    inByte = Serial.read();
    switch (inByte)
      case 2:   len = 0;
      case 3:  cur_id [len] = 0;
               Serial.println (cur_id);
        case 10:
        case 13:
             if (len >= (MAX_ID - 1))
             cur_id [len++] = inByte;
    }  // end of switch
  }  // end of incoming data
}  // end of loop

I found that the number displayed was partly printed on the card. I couldn't see how you could reconstruct the whole number (maybe it started with a manufacturer number). The number on the card was decimal, the number I displayed was hex. There is probably a pattern, so you could work out what to check for in the program by substituting the number on the card with the extra bits on each end.

Yes, i have the RFID ID-12 reader and the Arduino Uno board. Why do i need to have my 5v and ground connected on my Arduino? Or are you talking about sending those to the RFID reader as well as the serial port? i have the rfid and arduino wired like this RFID

I still cant figure it out though because that code had an error when i tried to upload it then my arduino crapped out and am trying to fix that. I will insert the code you have provided once i fix my arduino. Thanks for your help.

I meant, you run 3 wires from the Arduino to the ID-12.

Attached is a photo of my exact setup. You need +5v and Gnd to power the reader, plus you run Pin 9 (D0) on the reader to Pin D0 (Rx) on the Arduino. My photo shows 4 wires, but the green one (Tx) isn't connected as you don't need it.


Oh i see now. Thanks for the help. Unfortunately i will not be able to try this until my arduino is up and running again :frowning:

Rather than converting the 12 hexadecimal digits into 5 binary bytes and then converting back into hex for display I would just keep them as a String. I'd also use NewSoftSerial to get the serial input. It will allow you to use the USB connection for debugging.

#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

SoftwareSerial RFID = SoftwareSerial(rxPin, txPin); 

// Data format:
// 02 <10 hex digits of data> <2 hex digits of checksum> 13 10 03

#define START_CHAR 0x02
#define END_CHAR 0x03

void setup()
  Serial.begin(9600);  // Hardware serial for Monitor 2400bps
  RFID.begin(9600);    // RFID reader SOUT at 9600bps

void loop()
  int bytesread, val;
  String code = "";

  // Wait for header byte
  while(RFID.read() != START_CHAR) 
    /* DO NOTHING */    ;

  bytesread = 0;
  while ((val = RFID.read()) != END_CHAR)
    if (val == START_CHAR)
      break; // Bad frame
    if (bytesread > 14)
      break;  // Too many characters
    code += val;     // append the character  

  if (bytesread == 14 && code[12] == 13 && code[13] == 10)  // Valid read
    code = code.substring(0,12);  // strip off the 13 and 10
    Serial.print("Your code is: ");

  delay(1000);                       // wait for a second

This is how i have it setup. Do i also need to hook up 1 to gnd and 2 to vcc? I still cannot get the serial monitor to show me any output from my RFID card.

Well, yes. You haven't exactly got it like the link you showed. Pin 1 is Gnd, it won't work without that. Pin 2 is reset, which need to be tied high (eg. Vcc).

Unless you have soldered in links underneath where we can't see, you haven't got it set up like I had it.

i have it soldered to the breakout board as it should be. It goes 1-5 on the side with the one white wire and goes 6-11 on the side with the white and red wires connected to it. I dont know why im not getting anything outputted to my serial moniter

Looking at my picture further up the page I have 2-11 not 6-11.

Pin 6 is marked NC (not connected).

it worked! i got it. i just had to disconnect my rx from the arduino to the reader and upload my program then plug it in then everytig worked fine. i got a 12 digit hex code. i was under the impression i was going to get a 10 digit hex value. oh well, i got a code outputted from the reader. thanks guys!