• Stars
    star
    163
  • Rank 230,514 (Top 5 %)
  • Language Arduino
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MFRC522 RFID module connected to ESP8266 (ESP-12) WiFi module

ESP8266-MFRC522

MFRC522 RFID module connected to ESP8266 (ESP-12) WiFi module

Many thanks to nikxha from the ESP8266 forum (for initial work) and omersiar (for more details of wiring and additional examples)

Requirements

You have to install Arduino IDE 1.6.10 or later. Links are listed below.

  • Arduino > Preferences > "Additional Boards Manager URLs:" and add: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Arduino > Tools > Board > Boards Manager > type in ESP8266 and install the board
  • Download MFRC522 library and extract to Arduino library folder or you can use "Library Manager" on the IDE itself to install the MFRC522 library.

Download Links

Simple Example

Wiring RFID RC522 module

The following table shows the typical pin layout used:

Signal MFRC522 WeMos D1 mini NodeMcu Generic
RST/Reset RST D3 [1] D3 [1] GPIO-0 [1]
SPI SS SDA [3] D8 [2] D8 [2] GPIO-15 [2]
SPI MOSI MOSI D7 D7 GPIO-13
SPI MISO MISO D6 D6 GPIO-12
SPI SCK SCK D5 D5 GPIO-14
  • [1] (1, 2) Configurable, typically defined as RST_PIN in sketch/program.
  • [2] (1, 2) Configurable, typically defined as SS_PIN in sketch/program.
  • [3] The SDA pin might be labeled SS on some/older MFRC522 boards

Define RFID module

#include "MFRC522.h"
#define RST_PIN	5 // RST-PIN for RC522 - RFID - SPI - Modul GPIO5 
#define SS_PIN	4 // SDA-PIN for RC522 - RFID - SPI - Modul GPIO4 
MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance

Initialize RFID module

void setup() {
  Serial.begin(115200);    // 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);
  }
}

More Examples

More Repositories

1

Qt-Frameless-Window-DarkStyle

simple MainWindow class implementation with frameless window and custom dark style. It adds also support for titlebar and buttons (minimize, maximize, close)
C++
1,130
star
2

node-rpi-ws2801

A node.js library to control a WS2801 RGB LED stripe via SPI with your Raspberry Pi
JavaScript
27
star
3

FastLED-GFX

FastLED port of https://github.com/adafruit/Adafruit-GFX-Library
C
25
star
4

ESP8266-WiFi-Relay

simple sketch of using ESP8266WebServer to switch relays on GPIO pins. It serves a simple website with toggle buttons for each relay
HTML
21
star
5

ESP8266-WiFi-Relay-Async

simple sketch for ESP8266 of using ESPAsyncWebServer to switch relays on GPIO pins, serves a simple website with toggle buttons for each relay and uses AsyncWiFiManager to configure WiFi network.
C++
16
star
6

visa32

simple VISA SCPI interface for node.js (tested only on Windows + no commercial use!)
JavaScript
8
star
7

Espruino-Pico-Examples

some examples with Espruino Pico (Javascript on microcontroller)
JavaScript
6
star
8

FastLEDMatrix

obsolete >> use LEDMatrix fork instead
C++
4
star
9

3M-Controller

3M-Controller = Multi Modular MIDI Controller
C++
3
star
10

RobustRotaryEncoder

Simple library for robust reading of rotary encoders
C++
3
star
11

WordClock-15x15

C
1
star
12

mqtt-ws-bridge

simple bridge between socket.io (in browser) and mqtt client (in node.js)
HTML
1
star
13

FastLED-examples

Some short examples to try out FastLED library, running on Teensy 3.1.
Arduino
1
star
14

ESP8266-WiFi-Relay-Bahtinov-Masks

simple sketch for ESP8266 of using ESP8266WebServer to switch relays on GPIO pins, control servos to open and close masks, serves a simple website with toggle buttons for each relay and mask servo.
HTML
1
star