TUTORIAL RFID ARDUINO
Paso #1 Descripción
RFID (Identificación por Radiofrecuencia) es un sistema para la transferir datos en distancias cortas (típicamente menos de 6 pulgadas). En ocasiones solamente uno de los dos dispositivos debe estar alimentado, mientras que el otro es un dispositivo pasivo.
Esto permite usarse fácilmente en cosas como tarjetas de crédito, llaveros y collares para mascotas ya que no hay necesidad de preocuparse sobre la energía. La desventaja es que el lector y el dispositivo pasivo (es decir, tarjeta de crédito) deben estar muy cerca y sólo puede contener pequeñas cantidades de datos.
En este tutorial utilizaremos el kit RFID para leer los tags RFID (tarjeta y llavero), identificar el número de serie de cada uno de ellos para distinguir entre usuarios. Con esto se tendrá la base para crear un sistema de control de acceso sencillo.
Paso #2 Características
- El dispositivo pasivo (tarjeta de crédito o el llavero) puede ser leído desde una distancia de 10cms.
- Frecuencia de Operación: 13.56MHz
- Seguridad: Cada tarjeta cuenta con un número en particular (ID) para prevenir falsificaciones y cada transmisión pasa a través de 3 sistemas de cifrado de 28 bits, evitando la posibilidad de intercepción.
- Velocidad de transmisión: 106KB/segundo
- Corriente de Operación :13-26mA/DC 3.3V
- Corriente de Reposo :10-13mA/DC 3.3V
- Voltaje de Operación: 3.3V (no suministrar 5V, ya que puede dañar la tarjeta)
Paso #3 Componentes
- 1 – RC522 MIFARE RFID module
- 1 – Arduino Uno board
- 1 – Llavero con 1KB EEPROM
- 1 – Tarjeta RFID con 1KB EEPROM
- 1 – Mini Protoboard
Paso #4 Descripción del Tutorial
La actividad a realizar es detectar la tarjeta RFID en el Serial Monitor del Arduino y obtener los códigos ID de los 2 dispositivos pasivos que vienen en el kit (tarjeta RFID y llavero)
Paso #5 PinOut
Paso #6 Hardware
Paso #7 Librerías
- Primeramente bajar la nueva versión del Software Arduino
- Descargar la librería Addicore RFID Arduino Library (zip file)
- Hacer el Unzip al archivo
- Pegar la carpeta completa en My Documente-Arduino-Libraries- AddicoreRFID
- Dentro de la plataforma Arduino ir a – Sketch-Import Library- AddicoreRFID
- Usar la librería AddicoreRFID
Paso #8 Software
#include <AddicoreRFID.h>
#include <SPI.h>
#define uchar unsigned char
#define uint unsigned int
//4 bytes tag serial number, the first 5 bytes for the checksum byte
uchar serNumA[5];
uchar fifobytes;
uchar fifoValue;
AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module
/////////////////////////////////////////////////////////////////////
//set the pins
/////////////////////////////////////////////////////////////////////
const int chipSelectPin = 10;
const int NRSTPD = 5;
//Maximum length of the array
#define MAX_LEN 16
void setup()
{
Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps
// start the SPI library:
SPI.begin();
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital pin 5 , Not Reset and Power-down
digitalWrite(NRSTPD, HIGH);
myRFID.AddicoreRFID_Init();
}
void loop()
{
uchar i, tmp, checksum1;
uchar status;
uchar str[MAX_LEN];
uchar RC_size;
uchar blockAddr; //Selection operation block address 0 to 63
String mynum = "";
str[1] = 0x4400;
//Find tags, return tag type
status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
if (status == MI_OK)
{
Serial.println("RFID tag detected");
Serial.print(str[0],BIN);
Serial.print(" , ");
Serial.print(str[1],BIN);
Serial.println(" ");
}
//Anti-collision, return tag serial number 4 bytes
status = myRFID.AddicoreRFID_Anticoll(str);
if (status == MI_OK)
{
checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
Serial.println("The tag's number is : ");
//Serial.print(2);
Serial.print(str[0]);
Serial.print(" , ");
Serial.print(str[1],BIN);
Serial.print(" , ");
Serial.print(str[2],BIN);
Serial.print(" , ");
Serial.print(str[3],BIN);
Serial.print(" , ");
Serial.print(str[4],BIN);
Serial.print(" , ");
Serial.println(checksum1,BIN);
// Should really check all pairs, but for now we'll just use the first
if(str[0] == 62) //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
{
Serial.print("Hola Usuario 1!\n");
} else if(str[0] == 221) { //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
Serial.print("Hola Usuario 2!\n");
}
Serial.println();
delay(1000);
}
myRFID.AddicoreRFID_Halt(); //Command tag into hibernation
}


