Introduction: Getting Started With RFID

Have you ever wondered how your ID tag works?

In this tutorial, we will be able to show you how to read a RFID button, or tag, if it’s held up against ID-12 RFID reader or any 125KHz module. Also this project is an easy and fun way to explain the basic concept of digital identification technique using ID-12 together with ping ultrasonic and LEDs.

Step 1: Materials

Step 2: ID-12LA RFID Kit - ID-12LA RFID Reader

In this kit there are three things: ID-12LA RFID reader, RFID Button, and ATMEGA32U2 USB Dev Board.

Here is a little information about each part:

ID-12LA RFID reader: It uses radio frequency to identifying any object with a RFID tag wirelessly within a certain range.

  • This reader is going to send out a radio signal that is going to be picked up and answered with a unique string of data from the RFID tag or button. This module has been used in applications such as access control, load identification, alarm system, and so on.
  • The only things that make ID-12 different from the other RFID module (ID-2 and ID-20) is that it has a built-in antenna, and the size of the antenna. All these different ID readers use the same communication protocols, and works within a three data output format. This tutorial is using the ASCII (American Standard Code for Information Interchange) data format. That means out of 32 bit unique number of the RFID button, this tutorial concentrates on the 12 bit from the DATA and CHECKSUM.
    • STX stands for Start-of-Text. It indicates that communication between the RFID button and RFID reader has started while ETX is an End-of-Text communication.
    • DATA are the 10 ID tag number.
    • Check Sum is the sum of the data for the purpose of detecting error.
    • CR is the Carriage Return and LF is Linefeed.
      • See first image above.
  • It’s designed to include 11 pins, which is shown in the diagram in the second image above. In order for the reader to work, it requires a power supply to the ground and digital pin that are connected to the Arduino for serial communication. It can draw around 65mA current and works within about 100mm range.

Step 3: ID-12LA RFID Kit - RFID Button

RFID Button: Having a diameter of 30mm, this button holds a unique 32 bit ID. This ID is read by the ID-12LA RFID, or any other device using 125kHZ module. The unique serial number of each button makes them useful as a key system, or to track individual objects. Refer to the second image in the previous step for more information.

Step 4: ID-12LA RFID Kit - ATMEGA32U2 USB Dev Board:

ATMEGA32U2 USB Dev Board: This device is made compatible for the RFID reader (ID-12) that we are using to do this tutorial. It contains an Atmega32u2 microcontroller and an extra pin that can be used to control other sensors. Also the board has an LED and Buzzer to indicate whether the reader made a scan or not.

We only used this board for connection purpose since the ID-12 has a large pin that makes it hard to connect on to a breadboard.

Step 5: Ping Ultrasonic Sensor

This sensor is used to measure distance by using ultrasonic waves. Ultrasonic describes sound that has a frequency above human ear limit, which is about 20,000Hz. The device can measure a distance from about 2cm (0.8in) to 3m (3.3yd). It works by sending an ultrasonic wave, and then provides an output pulse to approximate the time it took for the echoed wave to return to the sensor. The distance is the result of the rate of speed multiplied with how long it took for the wave to hit the object and to echo back to the sensor. These kinds of sensors are widely used in robotic applications.

Distance between two objects = (Speed of Sound * Time) / 2

Step 6: Hardware Assembly

1. Place a black and red wire on the breadboard. Connect the red wire to 5V on the Arduino while the black wire is connected to the GND.

Step 7: Hardware Assembly - Continued

2. Place the Ping Ultrasonic sensor on the breadboard. Connect the left most pin to the GND, the middle to the power supply (+5V), and the right most pin to digital pin 6 on the Arduino.

Step 8: Hardware Assembly - Continued

3. Attach ID-12 reader to the Atmega32U2 USB Dev board and place it on the breadboard.

Then connect from the board to the Arduino/ breadboard as follows:

  • VCC => =5V
  • GND = > GND
  • TX => Pin 3

Step 9: Hardware Assembly - Continued

4. Place the LEDs on the breadboard and connect the resistors from the GND to the short pin of the LED.

Connect the long pin to the digital pin 7 for the Red LED and digital pin 9 for the Green LED.

Step 10: Software Program

In this section we are going to program the Arduino to identify the specific person assigned for each RFID button.

First, we need a program to read the RFID button. After compiling and loading, we will use the unique numbers that were read from each RFID button for identification purposes.

/*Using RFID ID-12 to read unique character that is assigned to each RFID button or tag*/
char val = 0; //variable to store the char read from the RFID buttonvoid setup() {Serial.begin(9600); //connect to the serial port} void loop () {//read the serial portif(Serial.available() > 0)val =; //read from one char from the ID-12 and store it Serial.print(val); //display the char in the serial monitor}}

At this point, we will be able to know each RFID button’s unique identifier.

Step 11: Software Program - Continued

Since we already have the unique identifier from the earlier code, we are going to store it in the system. Once the user comes near to the ultrasonic sensor, it will ask for an ID. After the reader scans, check to make sure it matches the one stored in the system. The output will be displayed on the serial monitor as well as the ON and OFF functions of different LEDs to indicate matching.

<p>/*This program uses ID-12 reader to read any RFID button or card, and Identify if this ID is known in the system*/<br>// include a header file to........... <br>#include  SoftwareSerial mySerial(3,2); // virtual serial port //////////////////////////////////////////////////////////////////<br> int R_LED= 7; // pin attached to the red LED<br> int G_LED = 9;<br> int LEDpin= 13;
int Reset = 12;
int Sonic_pin = 6; // pin from the ultrasonic sensor
char val = 0; // what if it's byte many is it storing
// because I already read and stored the ID's and I assigned it to the people
char id_tag1[] ="78003BDE66FB";
char id_tag2[] = "78003BF78B3F";
char* nam_tag[] = {"Derek", "Jay"};
char IDstring[13];
int i=0;  
int p =0;
void setup()
Serial.begin (9600);  // begin serial communication
pinMode (Sonic_pin, INPUT);
pinMode (R_LED, OUTPUT);
pinMode (G_LED, OUTPUT);
pinMode (Reset, OUTPUT);
pinMode (LEDpin, OUTPUT);
digitalWrite(LEDpin ,LOW);
void loop()
 //calculate the distance measured from the ping ultrasonic sensor until the target is less than 4cm away
  float distance;
  float time;
  // send out a pulse tone by creating
  pinMode(Sonic_pin, OUTPUT);
  digitalWrite(Sonic_pin, LOW);
  digitalWrite(Sonic_pin, HIGH);
  digitalWrite(Sonic_pin, LOW);
  //let the ultrasonic sensor be an input to take back the echoed wave
  pinMode(Sonic_pin, INPUT);
  time = pulseIn(Sonic_pin, HIGH); // get the echoed duration in microsecond
  distance = SecToCm(time); // call function to calculate the distance
  delay(1000);} while (distance>4.0);
  Serial.println("Hello, please swipe your ID");
  //Serial.println(" ");
  Serial.println(" ");
void Access()
  // turns the green LED on if the ID is known to the system
  digitalWrite(G_LED, HIGH);
  digitalWrite(G_LED, LOW);
void Denied()
  // turns the red LED on if the ID is not known to the system
  for(int i=0; i<3; i++)
  digitalWrite(R_LED, HIGH);
  digitalWrite(R_LED, LOW);
float SecToCm(float time)
  // convert the time measured into distance in centimeter
  //the ultrasonic read 29 microseconds per centimeter
 return time/29.0/2.0 ;
void Red_tag()
 { // if there is a radio frequency available from let the ID-12 read each char and store the value
   while (mySerial.available() >0)
     IDstring[p] = val;
  Serial.print("ID Number: ");
  // print out on the serial monitor the RFID unique ID stored in string
    for ( i=0; i<13;i++)
 Serial.print("Please wait while checking");
 void Iden_tag()
   boolean reading = true; //to check if the ID is known
   boolean reading1 = false;// to check if the first ID is not known
   boolean reading2 = false;// to check if the second ID is not known
 for (int i=0; i<12;i++)// comparing the new button read to the ID 2 stored in the system
 if (IDstring[i+1] != id_tag2[i])
  reading2= true; //indicate that the ID is not the same
  reading = false;
   // break;
 if (reading==true)
 delay (1500);
  Serial.println("Access granted");
  Serial.print("ID belongs to ");
   Access(); // call a function to light up the green LED
 reading = true;
 for (int i=0; i<12;i++)// why 12 not 13 try to figure out
 if (IDstring[i+1] != id_tag1[i])
    reading1= true;
    reading = false;
 if (reading==true)
   delay (1500);
  Serial.println("Access granted");
  Serial.print("ID belongs to ");
 if (reading1== true && reading2 ==true)
     Serial.println("Access Denied");
     Serial.println("Please try again ");
void resetID()
 for(int i = 0; i < 13; i++){ 
    IDstring[i] = 0;

Step 12: Code Explanation

The first part of the code includes the serial header file that is used to implement serial communication between the Arduino and RFID reader module. We are then going to create an object, in this case “mySerial”, to assign the communication pins. Then we define the global variable pin that is used by the LED and ping ultrasonic sensor. Also, as a global variable, we have created a character array to hold the two ID numbers that we got from the previous code as well as two names that are assigned for each ID number. These variables can be used by any function declared in this program.

Inside the setup function we have defined the serial communication between the computer and the Arduino as well as ID-12 and Arduino using same frequency band (9600). Then we defined which pin is used as an output or input. When we look at the loop function, the first thing we did was use another loop known as do while loop. Inside this loop, we calculated the distance at least once and checked if the target is located less than 4cm away. In order to calculate the distance, we first have to send out a pitched tone from the ultrasonic sensor. And this is done by sending Low-High-Low sequence by triggering digital pin 6. After it hit a target and returned back to the sensor, the sensor will output echo pulse. Using pulseln(), we can measure the echoed time pulse in microsecond and then converted it into distance. According to the datasheet for ping ultrasonic sensor, the speed of the sound is 340m/s and that means there are 29 seconds per centimeter. Calling out function Red_tag, we are going to scan and store any RFID button. In order to do this, we created a new array to hold on to each character. The Iden_tag function is going to compare the button that was stored on to the new array and the Id_tag created at the beginning of the code. Then we are going to see the output on the serial monitor as well as the LEDs.

Step 13: Results

Above is a screenshot of the serial monitor displaying the output.

If the detector doesn’t work after running the code, check the connection as well as any mistyping when writing the code. As we conclude this tutorial, we can now use this project for monitoring any object with a RFID tag.

Ready to get started? Jaycon Systems' online store has all the products you need to create your own project. While you're there, check out the other tutorials we have available for you! Also, if you haven't already, explore our Instructables profile.

If you have any questions about this tutorial, do not hesitate to post a comment, shoot us an email, or post it in our forum.

Thanks for reading!


jacktravis (author)2017-03-09

Hi, I wish to build your rfid system ... but I can't found the purpose of the ping ultrasonic sensor ?

JeanF10 (author)2016-02-22

Hello, thanks for this article !

There is a little mistake in step 5 : "Distance = Speed of Light * Time" should be "Distance = Speed of Sound * Time" ;)

JayconSystems (author)JeanF102016-02-23

I see the confusion. The equation provided was the general formula to find distance. You almost got it, but in this case distance between two objects can be found as follows:

Distance = (Speed of Sound * Time) / 2

This equation was provided inside the code (Step 11). Please go back and look at Step 5, we have updated it. Thank you so much for pointing that out.

rafununu (author)2016-02-19

Thank you for these precious explanations. There's a Kickstarter project about RFIDs but with Arduino.

JayconSystems (author)rafununu2016-02-19

You're welcome! We hope it helps your creations! :]

About This Instructable




Bio: We bring hardware products to life, specializing in engineering, prototyping, and mass manufacturing. We've worked with over 20 Kickstarter projects.
More by JayconSystems:How to Measure a Corner's Radius Using a 3D Printed ToolSending Commands Via the LCD BackpackProgramming a Single 7 Segment Display
Add instructable to: