RF ID is Radio Frequency Identification which is used to make track of every physical object.

The frequency of operation widely used at present are LF –Low Frequency 125 KHz & UHF (Mifare) 13.5MHz.

In this post our focus is on 125KHz RF ID.

The main components of the RF ID system are :

1) The RF ID Reader  – EM-18 type of RFID reader is used for demo in this post.

2) RF ID tag – The Tag contains an Integrated circuit for memory & an Antenna coil.

         There are 2 types of Tags – Passive & Active. We make use of Passive tags here .As the name implies these tags do not have a power source .When the passive Tag is near a RF ID reader , the energy is induced by electromagnetic waves.The tag “wakes up” & responds by sending the data stored in its memory. The RANGE of passive tag access is below 10 cm.

Active tags have their own battery source & offer a long range of access.Active tags are costlier than the passive ones.

rfid2

 

Tags are available in different Encasements.Widely used are the Visiting card type tags.

If you remove the cover of this tag you can see a Microchip & an Antenna coil.

The Antenna coil may be in Rectangle or a Round shaped as seen in fig. below :

Image 7

The Microchip is CMOS IC EM4102 manufactured by the company EM MicroElectronic.

These chips have internal rectifier & filter to convert Electromagnetic waves from RFID reader to DC power required for its operation.While in vicinity of a RFID reader the tag responds by sending information contained in the factory programmed memory array.

These EM type tags are READ ONLY & you can’t write your own data on it. For Read & write operation consider using Mifare tags at 13.5MHz.But remember that an EM tag can be Read by an EM RF ID Reader only .

 

Image 3

 

The EM-18 RF ID Reader too has an inbuilt antenna coil .When power is applied , the reader generates an electromagnetic field which is induced by the antenna present inside the tag.

The EM-18 reader provides 2 types of data

1) WIEGAND Formatted (EM26 bit version) DATA at pins Data 0 & Data 1

WIEGAND Protocol :

Uses 3 wires : GND , DATA 0 (Data Low) , DATA 1 (Data High).

When data lines are idle , the lines are at logic high (+5v). When binary 0 is being sent , DATA 0 wire will move from High to Low , while Data 1 remains High.

When binary 1 is sent , DATA 1 will move from High to Low , while Data 0 remains High.

2) TTL level RS232 Format Data at 9600 baud (UART TTL interface) on pin TXD.

Here we concentrate on RS232 data , as the UART output at TXD pin can be directly interfaced with a Microcontroller.

Pin configuration of EM-18 RFID module is as seen in fig. below :

rfid2

 

For card detection response, a mini buzzer is used .This is driven by a PNP transistor  connected at the BUZZ pin of the reader. When a card is detected this BUZZ pin goes LOW making the transistor conduct.The LED will glow along with the buzzer sound.

This detector response circuit is built on a base board , over which the EM-18 module is plugged on.

Image 3

 

Understanding the code printed on RF ID Tags :

tag

 

The tag has a 10 digit Decimal number printed followed by  8 digit number.Most of the RFID readers convert this 10 digit Decimal to HEX value & output at the TX pin.

To see the actual output we upload an empty code on to Arduino

void setup() {}

void loop() {}

Now the boot loader of Arduino is by passed & the Serial monitor of Arduino can be used as a Hyper terminal to read the serial port.

After uploading the empty code connect Tx of RFID reader to Tx (pin1) of Arduino.  +5v of RFID  to  +5v of Arduino , GND to GND.

Remember that this connection is Tx to Tx  (not Reverse).

usb

 

Open the Serial monitor of Arduino . Show the tag near the reader.

The decimal number printed on Tag 0006907246  is printed in Hex as  100069656E72

 usb2

To verify, open the calculator of windows &  set View – > Programmer mode.

Select Dec option & feed in the Decimal code seen on the card 0006907246 .

Now select the HEX to get the HEX value result.

calc1

 

But in Arduino serial monitor the hex code displayed is 12 bytes of data –>    1000 6965E 72

The trailing value 72 is the XOR value of check sum.

( 10 || 00 || 69 || 65|| 6E = 72 )  .Use the windows calculator  to arrive at the checksum. || represents XOR function.

The leading 10 is the START byte ,which varies according to card manufacturers.

This 12 bytes of data displayed on Arduino serial monitor is used in the code later, to compare the tags & identify the “ wanted tag”.

Further if you calculate the decimal conversion of 69 , you get 105

Decimal value of 656E is 25966 . This 105, 25966 is the last 8 digits you see on the tag.

calc2

 

calc3

 

Now we shall connect a Servo motor to Arduino .When “wanted Tag” is identified ,the servo is given a pulse to operate.By this way we can control a door lock connected to the Servo arm .When correct TAG is shown , the Servo operates to open & close the door lock.

It is suggested to use a separate power source for the Servo & Reader.Your Arduino cannot source enough power to both.

A dual 5v supply source is used in this demo.

Connect the Vcc of RFID to 5v of Power source &  Gnd to Gnd.

The Tx of RFID is connected to Rx of Arduino . Note that the connection now is reverse (Tx –> Rx).

Remember to disconnect this pin while uploading the Code.

A Servo motor is attached to PWM pin 9 of Arduino.The power is supplied from 5v of Power Source & Gnd to Gnd.

The GND of Power source must be connected to GND of Arduino.

Generally all Servos have 3 wires , the center one always RED , is connected to +5v .

Servo-Motor-Connector      ServoJR

 

The Brown or Black wire is GND.

The Orange or Yellow  wire is the Signal wire , which is connected to pin 9 of Arduino.

 

rf2

Upload the following code to Arduino. Always remove connections at Rx/Tx pins of Arduino while uploading code.

——————————————————–

char tagOk[] ="100069656E72"; // Replace with your wanted Tag ID
char inputTag[12];        // A variable to store the Tag ID being presented

#include <Servo.h>      // include the Servo library
Servo myServo;             // create an instance object myServo of Class Servo

void setup()
{
Serial.begin(9600);    //begin serial communication at baud 9600
myServo.attach(9);    // attach servo at pin 9  
myServo.write(0);      // initial position of servo at angle 0 
}

void loop()
{
  if (Serial.available()){
   
  int count = 0;
      while(Serial.available() && count < 12) {
         inputTag[count] = Serial.read();
         count++;
         delay(10);
         }
      Serial.print(inputTag);
      int compare = 1;
      compare = (strncmp(tagOk, inputTag,12)) ; // if both tags are equal strncmp returns a 0
      if (compare == 0){
         Serial.println( "   TAG OK  ");
        myServo.write(180);
        delay(2000);  //  delay of 2 secs  a must for servo to respond
        myServo.write(0);
       delay(100);
        Serial.println("…..door.open..");
          }
      else Serial.println (" TAG Not recognized ");
     
       }
      
}

————————————————-

After uploading the code , show the Tag near the Reader.If the correct tag is shown , the Servo will respond & open the door for a moment & close again.