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

Libraries

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)
MOSI = GPIO13 (HW SPI)
MISO = GPIO12 (HW SPI)
SCK = GPIO14 (HW SPI)
GND = GND
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()) {
delay(50);
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
delay(50);
return;
}
// 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);
Serial.println();
} // 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!

Recommendations

  • Toys Contest

    Toys Contest
  • Big and Small Contest

    Big and Small Contest
  • First Time Author

    First Time Author

62 Discussions

0
None
Stryker_242

Question 5 weeks ago

What range does this reader have?

0
None
RebeccaL117

Question 2 months ago

Working on a project with the rfid reader and an wemoss d1 i need to code it to read card and send info over wifi to a central server to put on a website there will be several readers sending info the this server

0
None
Emoloj05

Question 5 months ago

My RFID reader is not reading the tag in my connection with wemos d1(esp8266).
Kindly assist

0
None
joelonthefloor

Question 10 months ago

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

2 more answers
0
None
JorgenVikingGodjoelonthefloor

Answer 10 months ago

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...

0
None
joelonthefloorJorgenVikingGod

Reply 10 months ago

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..

0
None
AnthonyP189

11 months ago

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
0
None
JorgenVikingGodAnthonyP189

Reply 11 months ago

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.

0
None
AnthonyP189JorgenVikingGod

Reply 11 months ago

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.

0
None
JorgenVikingGodAnthonyP189

Reply 11 months ago

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:
https://stackoverflow.com/questions/32037217/how-can-i-replace-delay-by-millis/32043899#32043899

0
None
SunilT34

1 year ago

Hi Jorgen,

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

0
None
JorgenVikingGodpavanR21

Reply 1 year ago

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)

0
None
inghaj

1 year ago

Hi

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 !

IMG_9750.JPG
3 replies
0
None
PedroT54inghaj

Reply 1 year ago

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

0
None
JorgenVikingGodPedroT54

Reply 1 year ago

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

esp8266_devkit_horizontal-01.png
0
None
PedroT54JorgenVikingGod

Reply 1 year ago

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?

0
None
PuiuM2

1 year ago

Hi, did you managed to connect the OLED display?