Hardware Reference
In-Depth Information
Reading RFID Tags in Processing
In this project, you'll read some RFID tags
to get a sense for how the readers behave.
You'll see how far away from your reader
a tag can be read. This is a handy test
program to use any time you're adding
RFID to a project.
MATERIALS
» ID Innovations ID-12 or ID-20 RFID reader
» EM4001 RFID tags
» RFID breakout board
» Male header pins
» 1 uSb-to-TTL serial adapter
The ID Innovations readers operate on 5 volts and have a
TTL serial output, so the circuit is very simple.
All the ID Innovations readers use the same protocol. They
operate at 9600bps. The serial sentence begins with a
start-of-transmission (STX) byte (ASCII 02) and ends with
an end-of-transmission (ETX) byte (ASCII 03). The STX is
followed by the 10-byte tag ID. A checksum follows that,
then a carriage return (ASCII 13) and linefeed (ASCII 10),
then the ETX. The EM4001 tags format their tag IDs as
ASCII-encoded hexadecimal values, so the string will never
contain anything but the ASCII digits 0 through 9 and the
letters A through F.
There's also a buzzer pin, which goes high whenever a
tag is read, so you know that the reader's working. An
LED will work fine in place of the buzzer. Figure 9-8 shows
the circuit for the ID Innovations reader connected to a
USB-to-Serial adapter. The Parallax reader can work for
this project too, though you'll have to modify the code to
match its protocol.
Try It
The Processing sketch
shown here reads from
an ID Innovations reader. The setup()
should look very familiar to you by
now—it's just opening the serial port
and establishing a string for incoming
data. Since the ID Innovations serial
sentence ends with the value 03, you'll
buffer any incoming serial until you see
a byte of value 03.
/*
ID Innovations RFID Reader
Context: Processing
Reads data serially from an ID Innovations ID-12 RFID reader.
*/
// import the serial library:
import processing.serial.*;
Serial myPort; // the serial port you're using
String tagID = ""; // the string for the tag ID
void setup() {
size(150,150);
// list all the serial ports:
println(Serial.list());
// change the number below to match your port:
String portnum = Serial.list()[2];
// initialize the serial port:
myPort = new Serial(this, portnum, 9600);
// incoming string will end with 0x03:
myPort.bufferUntil(0x03);
}
 
Search WWH ::




Custom Search