Arduino + ESP8266 + RC522 RFID Module to save RM 100 replacement fee for my RFID access card.

ESP8266 connects with RC522 RFID module.
ESP8266 connects with RC522 RFID module.

My RFID card just not working anymore. We passed the access card to the management and let them find the issue. They told us the card needed RM 100 to replace it.

My inner thought was like: WHAT ???!!!!! SO EXPENSIVE!!!

Since I still have another working access card and know a bit about Arduino, maybe I could use Arduino to clone a new card.

Let's do it.

RFID Card Frequency: 13.56 MHz or 125 KHz?

First, we need to figure out the access card technology. I try to use my phone's NFC to sense the access card, but nothing happens. I believe the access card uses RFID technology. However, I'm not sure about which frequency. I guess the access card could be 13.56MHz or 125KHz.

Therefore, I sneak to the access door and look up the RFID reader. After that, I can confirm the access card using MIFARE 13.56MHz.

Pick-Up Part

The next thing to do is start picking up some parts. I already have an ESP8266, so the only thing left is the RFID module.

I pick the classic MFRC522 RFID module that supports read and write data for the MIFARE 13.56Mhz RFID card. It costs RM 10, including an RFID module with soldered pins and two RFID cards.

ESP8266
ESP8266
RC522 RFID Module
RC522 RFID Module

Wire-up ESP8266 and RC522 RFID Module

Now, we can wire up all the parts together according to below:

 ------------ ----------
|   ESP8266  |  RC522   |
 ------------ ----------
|  D1(GPIO5) |   RST    |
 ------------ ---------- 
|  D2(GPIO4) |   SDA    |
 ------------ ---------- 
|     3V     |   3.3V   |
 ------------ ---------- 
|    GND     |   GND    |
 ------------ ---------- 
| D5(GPIO14) |   SCK    |
 ------------ ---------- 
| D6(GPIO12) |   MISO   |
 ------------ ---------- 
| D7(GPIO13) |   MOSI   |
 ------------ ---------- 

Coding

After wiring up everything, we can start coding(Not really).

Install MFRC522 Library

  1. Open Arduino
  2. Go to Sketch, Include Library, and click Manage Libraries...
  3. Search "MFRC522" and install the library.

Open and Upload Dumpinfo Sketch.

  1. Go to File -> Example -> MFRC522
  2. Click Dumpinfo

This Dumpinfo is a sketch(program) to read the RFID access card. Change the RST_PIN to 5 and SS_PIN to 4.

Then, we upload the program into the ESP8266 and tap the functioning access card on the MFRC522 module to retrieve the data. We can open the serial monitor to view all the data.

Here is my card info. I think the main thing is UID. Save the UID for later.

Serial Monitor shows the functioning access card's UID read from the RC522.
Serial Monitor shows the functioning access card's UID read from the RC522.

Open and Upload ChangeUID Sketch.

  1. Go to File -> Example -> MFRC522
  2. Click ChangeUID

The ChangeUID is a sketch to write the UID into the RFID card. We need to replace the value on line 36 with our functioning RFID access card's UID. Also, change the RST_PIN to 5 and SS_PIN to 4. Then, upload it to the ESP8266.

The Problem

At first, I thought the RFID cards from the RC522 module could change UID. When I tap it on the RC522 module, the serial monitor prompts errors.

Serial Monitor shows error while try to change UID on read-only RFID card.
Serial Monitor shows error while try to change UID on read-only RFID card.

After some research, I found out I needed the RFID card can be written through all storage sectors.

I ordered from an online store and received the new RFID card after two weeks. Then, I tap the new RFID card on the RC522 module. The serial monitor shows everything ok.

Storage sectors from the new RFID access card.
Storage sectors from the new RFID access card.

Looking at the storage sectors, we can see the first to fourth sectors are the UID. The fifth sector is the checksum. The rest is the manufacturer's info.

So, I think this card should work.

Test the RFID access card.

I tested the RFID access card at the side and the main door, and both working without issues.

**Check the result in my video at 3:05.

Conclude

In the end, I saved around RM 70 by cloning the access card myself.

Cost breakdown:

  • ESP8266 - RM16
  • RC522 RFID Module - RM 10
  • RFID Card - RM 3

Maybe I can start my business by cloning the access card. I know. I'm just joking.

Next Post Previous Post
No Comment
Add Comment
comment url