Therefore i used a ESP8266, more specific the Wemos D1 mini Wifi module.
Test 1 (fail)
I found a project on http://www.instructables.com/id/WiFi-RFID-Reader/ using a Wemos D1 mini. The exact info about the pins was missing.RFID | ESP8266 | Wemos D1 mini |
RST | GPIO05 (free GPIO) | D1 |
SS | GPIO4 (free GPIO) | D2 |
MOSI | GPIO13 (HW SPI) | D7 |
MISO | GPIO12 (HW SPI) | D6 |
SCK | GPIO14 (HW SPI) | D5 |
GND | GND | G |
3.3V | 3.3V | 3V3 |
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); } }Unfortunate the example above did not working for me. I got output on the terminal, however there was a message about perhaps bad connections.
Test 2 (succes)
More succesfull was the next example that i found this on github:https://github.com/Jorgen-VikingGod/ESP8266-MFRC522
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 (including the one i used)
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 tags
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);
}
}