Παραγγελία έως τις 14:00 τις εργάσιμες = αποστολή την ίδια ημέρα 30 ημέρες δικαίωμα υπαναχώρησης Εγγύηση 1 έτους
← Πίσω στην επισκόπηση

Διάγραμμα σύνδεσης και παράδειγμα κώδικα

Έτσι συνδέεις το PN532 RFID NFC Kit με S50 Κάρτα και S50 Key Tag σε ένα Arduino UNO ή ESP32, με ένα παράδειγμα sketch που μπορείς να ανεβάσεις αμέσως.

Αναγνώστης καρτών RFID NFC PN532

Αυτό το παράδειγμα διαβάζει RFID/NFC tags (όπως κάρτες Mifare) χρησιμοποιώντας το module PN532 μέσω I2C. Βεβαιωθείτε ότι οι διακόπτες DIP στο module PN532 είναι ρυθμισμένοι για λειτουργία I2C (συνήθως CH1=ON, CH2=OFF). Κρατήστε οποιοδήποτε συμβατό tag NFC ή RFID 13.56MHz κοντά στο module για να εμφανιστεί το μοναδικό UID του στο Serial Monitor.

Διάγραμμα σύνδεσης: PN532 RFID NFC Kit με S50 Κάρτα και S50 Key Tag σε ένα Arduino UNO
Διάγραμμα σύνδεσης · Κάνε κλικ για μεγέθυνση
Πίνακας σύνδεσης: PN532 RFID NFC Kit με S50 Κάρτα και S50 Key Tag σε ένα Arduino UNO
Πίνακας σύνδεσης · Κάνε κλικ για μεγέθυνση
PN532_RFID_NFC_Card_Reader.ino · μεταγλωττισμένο και δοκιμασμένο
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : PN532 RFID NFC Card Reader
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : PN532 RFID NFC Module
 *  Libraries : Adafruit PN532 1.3.4
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <Adafruit_PN532.h>

#define PN532_IRQ   2
#define PN532_RESET 3

Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println(F("Initializing PN532 NFC Module..."));
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (!versiondata) {
    Serial.println(F("PN532 board not found. Check wiring and I2C mode switch."));
    while (1) delay(10);
  }

  Serial.print(F("Found PN532 chip! Firmware ver: "));
  Serial.print((versiondata >> 24) & 0xFF, HEX);
  Serial.print('.');
  Serial.println((versiondata >> 16) & 0xFF, HEX);

  nfc.SAMConfig();
  Serial.println(F("Waiting for an ISO14443A card or tag..."));
}

void loop() {
  uint8_t uid[7];
  uint8_t uidLength = 0;

  bool success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500);
  if (success) {
    Serial.print(F("Found tag! UID: "));
    for (uint8_t i = 0; i < uidLength; i++) {
      if (uid[i] < 0x10) Serial.print('0');
      Serial.print(uid[i], HEX);
      if (i < uidLength - 1) Serial.print(':');
    }
    Serial.println();
    delay(1000);
  }
}

Απαραίτητες βιβλιοθήκες: Adafruit PN532 1.3.4

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Αναγνώστης ετικετών NFC/RFID PN532 με ESP32

Αυτό το κύκλωμα συνδέει το module NFC/RFID PN532 με το ESP32 μέσω I2C για να διαβάζει τυπικές ετικέτες RFID 13.56 MHz ή κάρτες NFC. Βεβαιωθείτε ότι οι DIP switches του module έχουν ρυθμιστεί σε λειτουργία I2C (Channel 0=HIGH, Channel 1=LOW). Όταν μια κάρτα ή μπρελόκ τοποθετηθεί κοντά στην κεραία, το ESP32 διαβάζει και εμφανίζει το μοναδικό του ID (UID) στο Serial Monitor.

Διάγραμμα σύνδεσης: PN532 RFID NFC Kit με S50 Κάρτα και S50 Key Tag σε ένα ESP32 DevKit V1
Διάγραμμα σύνδεσης · Κάνε κλικ για μεγέθυνση
Πίνακας σύνδεσης: PN532 RFID NFC Kit με S50 Κάρτα και S50 Key Tag σε ένα ESP32 DevKit V1
Πίνακας σύνδεσης · Κάνε κλικ για μεγέθυνση
PN532_NFC_RFID_Tag_Reader_with_ESP32.ino · μεταγλωττισμένο και δοκιμασμένο
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : PN532 NFC/RFID Tag Reader with ESP32
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : PN532 RFID NFC Module
 *  Libraries : Adafruit PN532 1.3.4
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <Adafruit_PN532.h>

// Use I2C interface without dedicated IRQ/Reset pins
#define PN532_IRQ   (-1)
#define PN532_RESET (-1)

Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("Initializing PN532 NFC Reader...");
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (!versiondata) {
    Serial.println("PN532 not found! Check DIP switches (I2C mode) and wiring.");
    while (1) delay(100);
  }

  Serial.print("Found PN532 chip with firmware version: ");
  Serial.print((versiondata >> 16) & 0xFF, DEC);
  Serial.print('.');
  Serial.println((versiondata >> 8) & 0xFF, DEC);

  // Configure Secure Access Module (SAM)
  nfc.SAMConfig();

  Serial.println("Ready! Present an RFID card or NFC tag to the reader...");
}

void loop() {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
  uint8_t uidLength;

  // Wait up to 500ms for an ISO14443A card
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500);

  if (success) {
    Serial.println("Card detected!");
    Serial.print("UID Length: ");
    Serial.print(uidLength, DEC);
    Serial.println(" bytes");
    Serial.print("UID: ");
    nfc.PrintHex(uid, uidLength);
    Serial.println();

    delay(1000); // Debounce to avoid repeated rapid reads
  }
}

Απαραίτητες βιβλιοθήκες: Adafruit PN532 1.3.4

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Πρόσφατα προβεβλημένα

10x LED Δίοδος Διαφανής 5mm Πράσινο 3V

10x LED Δίοδος Διαφανής 5mm Πράσινο 3V

€ 1,85
Ψηφιακό Μικροσκόπιο 600x 3.6MP με βάση

Ψηφιακό Μικροσκόπιο 600x 3.6MP με βάση

€ 65,70
Προβολή