Radio-Frequency Identification (RFID) is technology that allows machines to identify an object without touching it, even without a clear line of sight. Furthermore, this technology can be used to identify several objects simultaneously. RFID can be found everywhere these days – anything from your cat to your car contains RFID technology. This post will cover how RFID works, some practical uses, and maybe even some example code for reading RFID data.

52564176757b7f89488b4567

 

What is RFID?

RFID is a sort of umbrella term used to describe technology that uses radio waves to communicate. Generally, the data stored is in the form of a serial number. Many RFID tags, contain a 32-bit hexadecimal number. At its heart, the RFID card contains an antenna attached to a microchip. When the chip is properly powered, it transmits the serial number through the antenna, which is then read and decoded.

RFID tags come in lots of shapes and sizes. For hobbyists, the most common type of tags are known as active and passive tags. Active tags contain a power source used for transmission, whereas passive tags rely on the RFID reader to power the circuitry. Active tags generally cost more because of the added hardware required. However, because of this, active tags have a much greater range. Anywhere from 100 feet (30.5 meters) to 300 feet (100 meters) is possible, compared to maybe 20 feet (6 meters) with passive tags. Of course this is all depending on the tags and environmental factors. These tiny capsules have a range of only a few inches. Passive tags are often meant to be disposable.

The exact frequency the tags transmits at is variable and depends on its purpose. This is usually done to avoid interference with other electronics or RFID tags and readers in the vicinity. RFID systems can use a system found in the cellular world known as Time Division Multiple Access (TDMA) to make sure the wireless communication is handled properly.

52564176757b7f0f428b456c

Security Issues

Skimming: when someone uses an RFID reader to scan data from an RFID chip without the holder’s knowledge. Eavesdropping: when someone reads the frequencies emitted from the RFID chip as it is scanned by a reader.

Right now, some credit cards have RFID technology built into them for fast and easy checkout. The buyer can simply tap their card on the scanner and complete the checkout. This is prone to some security issues, however. Skimmers can scan your card while it is in your wallet and steal valuable information. As a fix, some wallets have metal woven into them. This prevents a reader from powering the chip, preventing the code from being transmitted. You can read about that here. US passports also contain an RFID chip. The Department of Homeland Security insists that the e-passport is perfectly safe to use, and that proper precautions have been taken to ensure user confidentiality. For protection against skimming, the passports also contain a metallic anti-skimming device. When the e-passport is closed, it can’t be scanned at all; when it’s open, it can only be read by a scanner that is less than 4 inches (10 centimeters) away. To guard against eavesdropping, some areas where the passport is scanned are thoroughly covered and enclosed so that signals cannot be picked up beyond the RFID reader.

52564176757b7fb1148b4569

Some Code

I’ve had awesome luck using this RFID module from Parallax.  Below is some code for this reader; maybe you’ll find it useful.

char card[12] = {''8','3','1','7','5','7','2','A','8','3'};
char code[12];
int bytesread = 0;
int lockPin = 13; // Connect LED to pin 13
int rfidPin = 2; // RFID enable pin connected to digital pin 2
int val=0;

void setup()
{
  Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  pinMode(rfidPin,OUTPUT);   // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(lockPin,OUTPUT); // Set lockPin to output
  digitalWrite(rfidPin, LOW); // Activate the RFID reader
}

void loop()
{
  digitalWrite(rfidPin, LOW);

  if(Serial.available() > 0)    // if data available from reader
  {

     if((val = Serial.read()) == 10)    // check for header
     {
      bytesread = 0;
      while(bytesread<10)   // read 10 digit code
      {

        if( Serial.available() > 0)
        {
          val = Serial.read();

          if((val == 10)||(val == 13))  // if header or stop bytes before the 10 digit reading
            break;               // stop reading

          code[bytesread] = val;       // add the digit
          bytesread++;           // ready to read next digit
        }
      }
      if(bytesread >= 10)       // if 10 digit read is complete
      {
        digitalWrite(rfidPin, HIGH);        // De-Activate the RFID reader

        if(strcmp(code, card) == 0)
        {
          Serial.print("Code is accecpted: ");
          Serial.println(code);
          unlock();
        }
        else
        {
          Serial.print(code);
          Serial.println(" is not valid!");
        }
      }
      bytesread = 0;
      delay(500);                // wait for a second
     }
  }
}

void unlock()
{
  //do business here
}

Until Then
SHRIRAM