Op werkdagen vóór 14:00 uur besteld = dezelfde dag verzonden en in 98% van de gevallen de volgende dag in huis. Gratis retourneren 30 dagen bedenktijd 1 jaar garantie
← Tillbaka till översikten

Kopplingsschema och kodexempel

Så här kopplar du PN532 RFID NFC Kit med S50 Kort och S50 Nyckelbricka till en Arduino UNO eller ESP32, med ett exempel­sketch som du kan ladda upp direkt.

PN532 RFID NFC Card Reader

This example reads RFID/NFC tags (such as Mifare cards) using the PN532 module over I2C. Make sure the DIP switches on the PN532 module are set for I2C mode (usually CH1=ON, CH2=OFF). Hold any compatible 13.56MHz NFC or RFID tag near the module to print its unique UID to the Serial Monitor.

Kopplingsschema: PN532 RFID NFC Kit med S50 Kort och S50 Nyckelbricka på en Arduino UNO
Kopplingsschema · Klicka för att förstora
Kopplingstabell: PN532 RFID NFC Kit med S50 Kort och S50 Nyckelbricka på en Arduino UNO
Kopplingstabell · Klicka för att förstora
PN532_RFID_NFC_Card_Reader.ino · kompilerad och testad
/*
 * ==================================================================
 *  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);
  }
}

Nödvändiga bibliotek: Adafruit PN532 1.3.4

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

PN532 NFC/RFID Tag Reader with ESP32

This circuit connects the PN532 NFC/RFID module to the ESP32 over I2C to read standard 13.56 MHz RFID tags or NFC cards. Ensure the module's DIP switches are set to I2C mode (Channel 0=HIGH, Channel 1=LOW). When a card or key fob is placed near the antenna, the ESP32 reads and prints its unique ID (UID) to the Serial Monitor.

Kopplingsschema: PN532 RFID NFC Kit med S50 Kort och S50 Nyckelbricka på en ESP32 DevKit V1
Kopplingsschema · Klicka för att förstora
Kopplingstabell: PN532 RFID NFC Kit med S50 Kort och S50 Nyckelbricka på en ESP32 DevKit V1
Kopplingstabell · Klicka för att förstora
PN532_NFC_RFID_Tag_Reader_with_ESP32.ino · kompilerad och testad
/*
 * ==================================================================
 *  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
  }
}

Nödvändiga bibliotek: Adafruit PN532 1.3.4

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

Tidigare visade

2P Dupont plastkåpa stiftkontakt 2.54mm

2P Dupont plastkåpa stiftkontakt 2.54mm

€ 0,15
Keramisk Kondensator - 104 - 100V - 0.1uF / 100nF / 100.000pF

Keramisk Kondensator - 104 - 100V - 0.1uF / 100nF / 100.000pF

€ 0,35
Integral 32GB V10 High Speed microSDHC-kort Klass 10 - 100MB/s med SD-adapter

Integral 32GB V10 High Speed microSDHC-kort Klass 10 - 100MB/s med SD-adapter

€ 11,49
Visa
MOSFET 3V-24V elektronisk strömbrytare F5305S

MOSFET 3V-24V elektronisk strömbrytare F5305S

€ 1,75
24AWG 15cm Tennpläterad Koppar Elektronisk Tråd Röd

24AWG 15cm Tennpläterad Koppar Elektronisk Tråd Röd

€ 0,15
PNP-transistor S8550 D331 25V 0.5A 100MHz 1W TO-92

PNP-transistor S8550 D331 25V 0.5A 100MHz 1W TO-92

€ 0,35
Espressif ESP32-WROOM-32E 4M 32Mbit Flash Wifi-modul med integrerad antenn

Espressif ESP32-WROOM-32E 4M 32Mbit Flash Wifi-modul med integrerad antenn

€ 7,55
Sortiment krympslang 2:1 - 328 delar, 5 färger, 8 diametrar

Sortiment krympslang 2:1 - 328 delar, 5 färger, 8 diametrar

€ 4,70
Visa
I2C-UART dubbelriktad logic level-omvandlare 5V-3.3V 2-kanals

I2C-UART dubbelriktad logic level-omvandlare 5V-3.3V 2-kanals

€ 0,95
4x AAA batterihållare med av/på-brytare (6V)

4x AAA batterihållare med av/på-brytare (6V)

€ 1,70
Arduino Starterkit UNO R3 på nederländska med gratis ChatGPT

Arduino Starterkit UNO R3 på nederländska med gratis ChatGPT

€ 34,95
Visa
1602 LCD  grönt/gult bakgrundsljus med  I2C förlött

1602 LCD grönt/gult bakgrundsljus med I2C förlött

€ 7,65
Testklämmor till Dupont Female 10 stycken

Testklämmor till Dupont Female 10 stycken

€ 3,90
10x motstånd 220 Ohm 1/4 Watt 5% (LED förkopplingsmotstånd)

10x motstånd 220 Ohm 1/4 Watt 5% (LED förkopplingsmotstånd)

€ 1,25