Read nfc with PN532

i try to send text from PHONE via "NFC TOOL app" using PN532(i2c) but i cant read it in esp

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

#define PN532_IRQ   (2)
#define PN532_RESET (3)

Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup(void) {
  Serial.begin(9600);
  Serial.println("Hello!");

  // Initialize PN532 module
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (!versiondata) {
    Serial.println("Didn't find PN53x board");
    while (1); // halt
  }

  // Configure board to read RFID tags
  nfc.SAMConfig();
  Serial.println("Waiting for an NFC tag ...");
}

void loop(void) {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an NFC tag
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

  if (success) {
    Serial.println("Found an NFC tag!");

    Serial.print("UID Length: ");
    Serial.print(uidLength, DEC);
    Serial.println(" bytes");

    Serial.print("UID Value: ");
    for (uint8_t i = 0; i < uidLength; i++) {
      Serial.print(" 0x");
      Serial.print(uid[i], HEX);
    }
    Serial.println("");

    // Read data blocks containing text message from the NFC tag
    uint8_t blockNumber = 4; // Adjust the block number where your text message is stored
    uint8_t data[16]; // Buffer to store the read data
    success = nfc.ntag2xx_ReadPage(blockNumber, data);

    if (success) {
      Serial.println("Data read from NFC tag:");
      Serial.write(data, 16);
      Serial.println("");
    } else {
      Serial.println("Failed to read data from NFC tag");
    }

    delay(1000);
  }
}

i get this

Found an NFC tag!
UID Length: 4 bytes
UID Value: 0x8 0x47 0xC3 0xED
Failed to read data from NFC tag

i want a way so that i can get an ID or something that i can identify the phone not a random UID every time

is that what your phone is expecting ?

i try to send text from phone , and to read in arduino ide serial

its not about text its about finding a way to send some id or characters so i can identify in code and do some function if i read that

I don't know that app but it seems to be designed to write a tag, not receive requests to provide content.

whatever app or way is ok for me just to send data from phone and read via PN532 so i can identify the phone and do a task based on that

You need an app using the built in NFC chip of your phone to pose as an active NDEF tag….

I don’t know an app for that

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.