Here are some notes for using the various RFID modules we have.
SparkFun ID-12 Innovations (125 kHz)
- FTDI USB-to-serial adapter on SparkFun breakout board
- Pin 01 (Vusb) to +5
- Pin 10 (RX) to ID12 Pin 09 (TX)
- GND to GND
- ID-12 Innovations RFID reader on SparkFun breakout board
- Pin 01 (GND) to GND
- Pin 02 (RST) to +5v
- Pin 07 (FS) to GND
- Pin 09 (TX) to FTDI Pin 10 (RX)
- Pin 10 (BZ) through 1K resistor to LED to GND
- Pin 11 (5V) to +5v
Demonstration program in Processing
/* RFID Reader Demonstration
based on Igoe, Making Things Talk, 1st ed, 310-313
FTDI USB-to-Serial adapter on SparkFun breakout board
Pin 01 (Vusb) to +5v
Pin 10 (RX) to ID12 Pin 09 (TX)
GND to GND
ID-12 Innovations RFID reader on SparkFun breakout board
Pin 01 (GND) to GND
Pin 02 (RST) to +5v
Pin 07 (FS) to GND
Pin 09 (TX) to FTDI Pin 10 (RX)
Pin 10 (BZ) through 1K resistor to LED to GND
Pin 11 (5V) to +5v
*/
import processing.serial.*;
Serial myPort;
String tagID = "";
void setup() {
size(600, 200);
// set serial port to first on list and initialize it
println(Serial.list());
String portnum = Serial.list()[0];
myPort = new Serial(this, portnum, 9600);
myPort.buffer(16);
// use third font available
PFont myFont = createFont(PFont.list()[2], 24);
textFont(myFont);
}
void draw() {
background(0);
text(tagID, width/4, height/2 - 24);
}
// read bytes from the serial port and put them into tag string
void serialEvent(Serial myPort) {
String inputString = myPort.readString();
tagID = parseString(inputString);
}
// read string and look for 10-byte tag ID
// assumes string begins with STX byte (0x02) and ends with ETX byte (0x03)
String parseString(String thisString) {
String tagString = "";
char firstChar = thisString.charAt(0);
char lastChar = thisString.charAt(thisString.length() - 1);
if ((firstChar == 0x02) && (lastChar == 0x03)) {
tagString = thisString.substring(1, 11);
}
return tagString;
}
