Commandé avant 14h00 un jour ouvrable = expédié le jour même 30 jours de délai de rétractation Garantie d’un an
← Retour à l’aperçu

Schéma de câblage et exemple de code

Voici comment connecter le Kit RFID NFC PN532 avec carte S50 et porte-clés S50 à un Arduino UNO ou à un ESP32, avec un exemple de sketch que tu peux téléverser directement.

Lecteur de carte RFID NFC PN532

Cet exemple lit les tags RFID/NFC (comme les cartes Mifare) à l’aide du module PN532 via I2C. Assurez-vous que les interrupteurs DIP du module PN532 sont réglés sur le mode I2C (généralement CH1=ON, CH2=OFF). Approchez n’importe quel tag NFC ou RFID compatible 13.56MHz du module pour afficher son UID unique dans le Serial Monitor.

Schéma de câblage : Kit RFID NFC PN532 avec carte S50 et porte-clés S50 sur un Arduino UNO
Schéma de câblage · Cliquez pour agrandir
Tableau de câblage : Kit RFID NFC PN532 avec carte S50 et porte-clés S50 sur un Arduino UNO
Tableau de câblage · Cliquez pour agrandir
PN532_RFID_NFC_Card_Reader.ino · compilé et testé
/*
 * ==================================================================
 *  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);
  }
}

Bibliothèques nécessaires : Adafruit PN532 1.3.4

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

Lecteur de tags NFC/RFID PN532 avec ESP32

Ce circuit relie le module NFC/RFID PN532 à l'ESP32 via I2C pour lire des tags RFID ou des cartes NFC standard de 13.56 MHz. Assurez-vous que les interrupteurs DIP du module sont réglés en mode I2C (Channel 0=HIGH, Channel 1=LOW). Lorsqu'une carte ou un porte-clés est placé près de l'antenne, l'ESP32 lit son identifiant unique (UID) et l'affiche dans le Serial Monitor.

Schéma de câblage : Kit RFID NFC PN532 avec carte S50 et porte-clés S50 sur un ESP32 DevKit V1
Schéma de câblage · Cliquez pour agrandir
Tableau de câblage : Kit RFID NFC PN532 avec carte S50 et porte-clés S50 sur un ESP32 DevKit V1
Tableau de câblage · Cliquez pour agrandir
PN532_NFC_RFID_Tag_Reader_with_ESP32.ino · compilé et testé
/*
 * ==================================================================
 *  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
  }
}

Bibliothèques nécessaires : Adafruit PN532 1.3.4

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

Récemment consultés

Connecteur header PCB droit - 8 broches, pas de 2,54 XH2.54mm

Connecteur header PCB droit - 8 broches, pas de 2,54 XH2.54mm

€ 0,35
Batterie rechargeable 18650 3,6 V 2850 mAh 10 A

Batterie rechargeable 18650 3,6 V 2850 mAh 10 A

€ 4,99
Voir
Connecteur header PCB droit - 7 broches, pas de 2,54 XH2.54mm

Connecteur header PCB droit - 7 broches, pas de 2,54 XH2.54mm

€ 0,35
Module de pilote de moteur TB6612FNG pour Arduino

Module de pilote de moteur TB6612FNG pour Arduino

€ 3,30
Shield de pilote de moteur L293D pour Arduino

Shield de pilote de moteur L293D pour Arduino

€ 3,15
Convertisseur de niveau logique bidirectionnel I2C-UART 5V-3,3V à 2 canaux

Convertisseur de niveau logique bidirectionnel I2C-UART 5V-3,3V à 2 canaux

€ 0,95
Plaque d’essai, 3220 trous - ZY-208, avec 4 bornes

Plaque d’essai, 3220 trous - ZY-208, avec 4 bornes

€ 16,65
Kit d’extension canon à billes d’eau ACEBOTT pour voiture robot ESP32

Kit d’extension canon à billes d’eau ACEBOTT pour voiture robot ESP32

€ 59,00
Pâte thermique 1gr 0.25ml grise en seringue

Pâte thermique 1gr 0.25ml grise en seringue

€ 4,30
Station de soudage Velleman Xytronic 80W

Station de soudage Velleman Xytronic 80W

€ 99,95
Carte de charge et de protection BMS 2S pour 2 x 18650

Carte de charge et de protection BMS 2S pour 2 x 18650

€ 2,00
Capteur de lumière ambiante et de proximité APDS-9930

Capteur de lumière ambiante et de proximité APDS-9930

€ 2,30
LD2410C 24GHz module capteur de présence humaine

LD2410C 24GHz module capteur de présence humaine

€ 6,99
Module d'alimentation sans fil 5V 2A (émetteur et récepteur)

Module d'alimentation sans fil 5V 2A (émetteur et récepteur)

€ 12,75
Voir