You are here

FEED blog.jeronimus.net

Subscribe to FEED blog.jeronimus.net feed
The Jeronimus.Net blogJeronimusnoreply@blogger.comBlogger158125
Updated: 1 hour 21 min ago

RFID and Wemos D1 mini (1)

Thu, 2018-03-29 08:45
I wanted to connect an RFID reader to my home network.
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.
As a test i created the circuit as a test on a breadboard using the Wemos D1 mini pin info on https://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/. (See also this picture with Wemos D1 mini connections)




RFIDESP8266Wemos D1 miniRSTGPIO05 (free GPIO)D1SSGPIO4 (free GPIO)D2MOSIGPIO13 (HW SPI)D7MISOGPIO12 (HW SPI)D6SCKGPIO14 (HW SPI)D5GNDGNDG3.3V3.3V3V3
The instructional also contains software to read basic RFID info and send it over the serial (usb) line.

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 instanceInitialize RFID modulevoid setup() {
Serial.begin(9600); // Initialize serial communications
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
}Read RFID tagvoid 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 moduleThe following table shows the typical pin layout used:SignalMFRC522WeMos D1 miniNodeMcuGenericRST/ResetRSTD3 [1]D3 [1]GPIO-0 [1]SPI SSSDA [3]D8 [2]D8 [2]GPIO-15 [2]SPI MOSIMOSID7D7GPIO-13SPI MISOMISOD6D6GPIO-12SPI SCKSCKD5D5GPIO-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 modulevoid setup() {
Serial.begin(115200); // Initialize serial communications
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
}
Read RFID tagsvoid 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);
}
}THis did work and i expected that was a good starting point for the rest of my project.

Share this on

Twitter icon
Facebook icon
Google icon
StumbleUpon icon
Del.icio.us icon
Digg icon
LinkedIn icon
MySpace icon
Newsvine icon
Pinterest icon
Reddit icon
Technorati icon
Yahoo! icon
e-mail icon