Project 44 – Simple RFID Reader

The pins on the ID12 readers are non-standard spacing so they will not fit into a breadboard. You will need to obtain a breakout board from a supplier such as Sparkfun. The cards or tags can be purchased from all kinds of sources and are very cheap; I got a bag of small keyfob style tags on eBay for a few dollars. Make sure the tag or card is of 125KHz technology, otherwise it will not work with this reader.

Parts Required

ID-12 RFID Reader images
ID-12 Breakout Board* images
Current Limiting Resistor images
5mm LED images
125KHz RFID tags or cards*
(At least 4)
images

*image courtesy of Sparkfun

Connect It Up

Connect everything as shown in Figure 16-1.

images

Figure 16-1. The circuit for Project 44 – Simple RFID Reader (see insert for color version)

Connect an LED via a current limiting resistor to Pin 10 (BZ) on the reader.

Enter the Code

Enter the code in Listing 16-1.

Listing 16-1. Code for Project 44.

// Project 44

char val = 0; // value read for serial port

void setup() {
    Serial.begin(9600);
}

void loop () {

  if(Serial.available() > 0) {
  val = Serial.read(); // read from the serial port
  Serial.print(val, BYTE); // and print it to the monitor
  }
}

Run the code, open up the serial monitor, and hold your RFID tag or card up to the reader. The LED will flash to show it has read the card, and the serial monitor window will show you a 12 digit number which makes up the unique ID of the card. Make a note of the IDs of your tags as you will need them in the next project.

The code is nothing more than a simple read of the data present on the serial port. By now, you should know enough to work out how this program works. I shall therefore skip over the code overview and look at the hardware instead.

Project 44 – Simple RFID Reader – Hardware Overview

RFID is everywhere from your bus pass to the doors that let you into your office or college, and so on. The tags or cards come in all kinds of shapes and sizes (see Figure 16-2) and can be made so small that scientists have even attached RFID tags to ants to monitor their movements. They are simple devices that do nothing but transmit a unique serial code via radio waves to the reader. Most of the time, the cards or tags are passive, meaning they have no battery and need power from an external source. Other options include passive RFID, which has its own power source, and battery assisted passive (BAP), which waits for an external source to wake it up and then uses its own power source to transmit, giving greater range.

The kind you are using are the passive type that have no battery. They get their power from a magnetic field transmitted by the reader. As the tag passes into the magnetic field, it inducts a current in the wires inside the tag. This current is used to wake up a tiny chip, which transmits the serial number of the tag. The reader then sends that data in serial format to the PC or microcontroller connected to it. The format of the data sent from the ID12 reader is as follows:

images

An STX or transmission start character is sent first (ASCII 02), followed by 10 bytes that make up the individual HEX (Hexadecimal) digits of the number. The next two HEX digits are the checksum of the number (this will be explained in the next project), then there's have a Carriage Return (CR) and Line Feed (LF), followed by an ETX or transmission end code.

Only the 12 ASCII digits will show up on the serial monitor as the rest are non-printable characters. In the next project, you'll use the checksum to ensure the received string is correct and the STX code to tell you that a string is being sent.

images

Figure 16-2. RFID tags and cards come in all shapes and sizes (image courtesy of Timo Arnall)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.42.158