WiFi RFID Reader


Introduction: WiFi RFID Reader

The main idea was to read in 13.56 MHz RFID (tags / tokes / stickers / wristbands / cards) by a magic box and post the RFID UID to a local database by WiFi network.

This instructable builds the base of the whole system - the first working RFID reader on ESP8266 WiFi SoC. (many thanks to nikxha from the ESP8266 forum for the initial help)

Step 1: Requirements

You have to install the Arduino IDE 1.6.4. or 1.6.5.

  • Arduino > Preferences > "Additional Boards Manager URLs:" and add: http://arduino.esp8266.com/package_esp8266com_index.json
  • Arduino > Tools > Board > Boards Manager > type in ESP8266 and install the board
  • download MFRC522 module (see Libraries) and copy folder to Arduino library path


Step 2: Wiring RFID RC522 Module

wiring the MFRC522 to ESP8266 (ESP-12)
(please use wiring below instead of diagram above)

RST = GPIO05 (free GPIO)
SS = GPIO4 (free GPIO)
3.3V = 3.3V

Step 3: Software

define RFID module

#include "MFRC522.h"
#define RST_PIN 15 // RST-PIN for RC522 - RFID - SPI - Modul GPIO15 
#define SS_PIN 2 // SDA-PIN for RC522 - RFID - SPI - Modul GPIO2
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

Initialize RFID module

void setup() {
Serial.begin(9600); // Initialize serial communications
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522

Read RFID tag

void loop() { 
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
// Show some details of the PICC (that is: the tag/card)
Serial.print(F("Card UID:"));
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
} // Helper routine to dump a byte array as hex values to Serial
void dump_byte_array(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);

Step 4: Final Steps ...

As I wrote at the beginn of this short instructable, this is just the base.
But you can make many funny projects by using this hard and software.

For my next project I'm using not only the RFID module (SPI), I will use a small OLED display (I2C), and toggle button.
The boxes are fully self configurable by one master RFID card.
There is also a webinterface to manage all boxes and add some topics, tags and description.

If I'm finished the project, I will upload it to instructables - so stay tuned.
There will be also a link here to the new tutorial.

3 People Made This Project!


  • Casting Contest

    Casting Contest
  • Make it Move Contest

    Make it Move Contest
  • Woodworking Contest

    Woodworking Contest

We have a be nice policy.
Please be positive and constructive.


1 Questions

Can i use this same setup to send data to a database? If not so could you update me on that?

You can send the read data to what destination you want.
My example is just how you can read in the UID.
But there are thousands of examples out there how to send data from ESP8266 to cloud or database. Just spend a little effort to find the correct ones. I'm really busy these days and do not have the time to create new examples...


So you're setup can't be used to send data to the database?
And if I understand correctly, you're setup is used to read uid using the esp8266-01 as board. Yes?
I am sorry if I am asking irrelevant questions cause I am a newbie into this..

Thanks for the great tutorial. I have a quick question... with the RC522 plugged in, I can successfully read and write to a card, but the WiFi becomes incredibly slow and unstable (takes minutes to connect to network, can't connect to a host or make HTTP requests). When I remove the RC522, however, the WiFi connects almost instantly and makes requests very quickly. Do you know what might cause this problem? Maybe the RC522 needs a separate power supply?

3 replies

Hi Anthony, your idea to use more power is a good one. The RFID module do not use much, but can drain to much power from the RF module of the ESP.
It can also be a to high poll interval of the rfid module inside your loop.
Reading card can take some "time" and if you polling to fast inside the loop, the WIFI handling can be dropped down.

Thanks for your response. I was able to get it to work by connecting the RC522's 3V3 and GND pins to another "dummy" ESP-12E and connecting them to a separate USB power source, and leaving the other pins connected to the first ESP-12E (and leaving it connected to the first USB power source).

But now I'm confused because no one else seems to have had this problem. I have plenty of delays in my loops and have also tried several USB cords. I also tried swapping out the original ESP-12E board altogether to see if it was faulty, but it wasn't.

Would you mind pointing me in the right direction for how to do this without the "dummy" ESP8266? I assume I can have one USB cord or wall wart go to something that splits the power, so that the ESP8266 is not responsible for powering the RC522. But I don't know what to search for.

using delay on ESP8266 is a really bad idea, because it can force to fire the watchdog and reboot.
If you want to "pause" or poll only every x times - just use millis like in this post:

Hi Jorgen,

I'm looking for a similar technology and I need your help. How do I contact you ?

It only has two IO pins available in addition of RX/TX. You can drive I2C, but not HW SPI as far as I know. Maybe you can use the PN532 module (it has also I2C interface)


Im a bit new to this. Im trying to use an ESP-12E and an RC522 to make this (no other Board, as I see some Arduino Boards in some of the pictures).

I've followed this instructions, and everything appears to work fine... except after "Scan for Card and print UID:" I get no cards read :-(

Im using Arduino IDE 1.6.5 and I've tried both pin combinations, but no joy

Should this work on just an ESP-12E?

Any suggestions ?

Thanks !

3 replies

Did u solved it? please if u did, tell me how!

Hi Pedro, sorry did not see your comment. As I can see in your picture, you are using the NodeMCU board.
Maybe the pin mapping is different to the raw ESP-12E Board.

This wiring should work for you:
SS      - D4 (GPIO2)
SCK   - D5 (GPIO14) (hw spi)
MOSI - D7 (GPIO13) (hw spi)
MISO - D6 (GPIO12) (hw spi)
IRQ    -
GND  - G
RST   - D3 (GPIO0) (FLASH)
3.3V   - 3V3

and just use this defines into the demo sketch will do the job:
#define RST_PIN D3
#define SS_PIN D4

Best regards, Jorgen


Thanks for the answer, but I already tried to use that pins, but without sucess. I tried all free GPIO as SS and RST, but it dont work. I switched my IDE for the 1.6.5 version hoping it works, but failed. My code is an example of the MFRC522 library that runs perfectly in arduino. Any other tips?

Hi, did you managed to connect the OLED display?

3 replies

Hi - yes it worked perfectly. But only with I2C. SPI is not working on the same port, because the RFID module is requesting different SPI header than most tft displays.

can u pls post the code and the schematic for ESP+I2C+RFID? I will try to modify it for my purpose. TY!

Hi, Can I use instead GPIO13 and 12, MOSI and MISO from the ESP12e?
And what I need to do for this?


hi, i try this one, and didnt get it work.

I cant upload the Code, when the rfid-rc522 board is connected.

i get this Message :

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

When i disconnect the rfid Board, i can upload the Code. But it still doesnt work.
Does someone have a idea ? i try a diffrent esp12e, the same result.