Penggunaan MFRC522 RFID Reader dengan Arduino

Overview

Cara kerja RFID (Radio-Freq Identification (RFID) mengunakan gelombang radio untuk membaca informasi yang disimpan di tag. Tag dapat dibaca beberapa cm tanpa harus lurus dengan reader.

Ada beberapa type RFID,

Specifications

 

RC522-RFID Reader/Writer menggunakan frekuensi 13.56 MHz

Berkomunikasi menggunakan SPI

where to buy
what we need

Schematic


Program

#include "SPI.h" // SPI library
#include "MFRC522.h" // RFID library (https://github.com/miguelbalboa/rfid)
const int pinRST = 9;
const int pinSDA = 10;
MFRC522 mfrc522(pinSDA, pinRST); // Set up mfrc522 on the Arduino
void setup() {
  SPI.begin(); // open SPI connection
  mfrc522.PCD_Init(); // Initialize Proximity Coupling Device (PCD)
  Serial.begin(9600); // open serial connection
}
void loop() {
  if (mfrc522.PICC_IsNewCardPresent()) { // (true, if RFID tag/card is present ) PICC = Proximity Integrated Circuit Card
    if(mfrc522.PICC_ReadCardSerial()) { // true, if RFID tag/card was read
      Serial.print("RFID TAG ID:");
      for (byte i = 0; i < mfrc522.uid.size; ++i) { // read id (in parts)
        Serial.print(mfrc522.uid.uidByte[i], HEX); // print id as hex values
        Serial.print(" "); // add space between hex blocks to increase readability
      }
      Serial.println(); // Print out of id is complete.
    }
  }
}

 

Demonstration
Next Project

Leave a Reply

Your email address will not be published. Required fields are marked *