2023年8月18日 星期五

ESP32 + NFC PN532 Reader

 ESP32 + NFC PN532 Reader 





move the selector 1 of the micro DIP switch to 1 (on) and selector 2 to 0 (off). 

//====================================================
// esp32-wroom-32 devkit v1 default pins
//       SCL D22
//       SDA D21
//====================================================

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
/* Uno's A4 to SDA & A5 to SCL */
//=============================================
void setup(void) {
    Serial.begin(115200);
    Serial.println("NDEF Reader");
    nfc.begin();
}
//=============================================
void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        tag.print();
    }
    delay(5000);

}
//=============================================

沒有留言:

張貼留言

習題解答 (5/6)

  第五章 習題解答 一、 錯誤偵測技術 1. 何謂循環冗餘檢查法 (CRC)? 是一種根據傳輸資料產生簡短固定位數校驗碼的演算法。發送端將資料除以一個特定的多項式,得到的「餘數」即為 CRC 碼並隨資料發送;接收端以同樣多項式除之,若餘數為 0 則代表資料傳輸正確。 2. 何...