Difference between revisions of "WeMOS: D1 R1 mini RFID 2"

From OnnoWiki
Jump to navigation Jump to search
Line 17: Line 17:
 
  #define SS_PIN 4 // SDA-PIN for RC522 - RFID - SPI - Modul GPIO4  
 
  #define SS_PIN 4 // SDA-PIN for RC522 - RFID - SPI - Modul GPIO4  
 
  MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
 
  MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
 
+
 
 
 
  void setup() {
 
  void setup() {
   Serial.begin(9600);    // Initialize serial communications
+
   Serial.begin(115200);    // Initialize serial communications
   SPI.begin();           // Init SPI bus
+
   SPI.begin();         // Init SPI bus
   mfrc522.PCD_Init();    // Init MFRC522  
+
   mfrc522.PCD_Init();    // Init MFRC522
 
  }
 
  }
 
+
 
  void loop() {  
 
  void loop() {  
 
   // Look for new cards
 
   // Look for new cards

Revision as of 20:21, 31 May 2024

Sumber: https://blog.jeronimus.net/2018/03/rfid-and-wemos-d1-mini-1.html

Tabel sambungan:

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


Source

#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

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

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);
  }
}