Step 1: Let’s Get Started!
We’ll be using the ID Innovations ID-12 to perform the task of reading an RFID tag. At a minimum, it requires +5V, ground, and a digital pin (on the Arduino) that we will utilize for serial communication.
The ID-12 operates at 9600bps and has an LED output pin. This LED output is great! We can use this to verify if the ID-12 is reading the tag even before it is connected to the Arduino!
The ID-12 has unusual pin spacing. Pick up the breakout board from SparkFun (SEN-08423 ) to make it easily fit on your breadboard.
All of ID Innovations readers read at a frequency of 125 kHz. Any 125 kHz RFID tag will do.
Step 2: Okay, Let’s Start Wiring
Okay, before we even start messing with the Arduino, let’s get the ID-12 wired up. Follow the wiring layout above using your breadboard and jumpers to make the necessary connections.
I did not show an LED connected to the LED pin (10), but it’s a good idea to use this at first for read verification. Also, I prefer to insert a small capacitor (100nF) between +5V and ground to keep the power clean.
Once the ID-12 has been connected it’s time to bring out the Arduino! Connect TX (D0, Pin 9) from the ID-12 to RX on the Arduino.
Step 3: Time for Some Code!
This first sketch will test to make sure the ID-12 is working correctly. The Arduino waits for serial comms and prints the output. We can see that output using the serial monitor. The output may look like junk, but it is, in fact, the unique ID for our RFID tag. We will use this ID in the next sketch.
Copy the code below and paste it into a new sketch. Verify, compile, and upload. When it has finished uploading, pass the RFID tag over the reader. If you have the LED pin on the ID-12 connected to an LED, you should see the LED blink. This indicates a succesful read. If the Arduino is wired and working correctly, you should see 12 hexadecimal characters in the serial monitor. This is the tag’s unique identifier.
I should mention that you MUST disconnect the Arduino RX pin while uploading the sketch, otherwise, you will get an error.
———————————————————————————-
/* RFID ID12 */
char val = 0; // variable to store the data from the serial port
void setup() {
Serial.begin(9600); // connect to the serial port
}
void loop () {
// read the serial port
if(Serial.available() > 0) {
val = Serial.read();
Serial.print(val, BYTE);
}
}
———————————————————————————-
Step 4: Final Sketch
Take your unique identifer, slice off the last two characters so you are left with 10 characters. For example, I read 2900940E9526 as my identifier. So, I will use 2900940E95. 26 is the ID’s checksum. Don’t worry about this. Insert your identifier in the code where it says [INSERT IDENTIFIER HERE]. You can also add your name in the [ADD YOUR NAME HERE].
Remember when we connected ID-12 pin 9 to the Arduno RX. We’re going to free up the RX pin and relocate that connection to digital pin 4. That’s it!
Verify, compile, upload, and run. Open the serial monitor and scan your card. You should see something like my output.
Congratulations! We have a working RFID reader!
FUTURE:
If we dig through the code, we will see ‘futureOutput’ defined for pin 12. This pin goes high for two seconds after a successful, authorized card read. It can be used to control a relay to perform a number of many different things. That is up to you!
Also, at the end of the code is the ‘unlock()’ function. This defines what happens during the unlock process. Code could be added here to initiate another sequence, perhaps X10 protocol to control a home appliance? You may see that from me in the future *WINK WINK*.
(IGNORE THE NEXT/LAST STEP. The editor freezes when I try to edit it, hanging on ‘UPDATING’. So, it’s staying there until I figure out how to get rid of it.)