PN532: MIFARE Classic NDEF tag falls back to UID due to authentication failure on block 0x04
The problem
I am using a PN532 over I2C with an ESP32-C3 to read Home Assistant NFC tags.
When scanning a MIFARE Classic 1K card containing a valid Home Assistant NDEF URL, ESPHome fails to read the NDEF payload and falls back to the physical UID.
The same card is read correctly by an Android phone. NFC Tools confirms that the card contains a valid NDEF record such as:
https://www.home-assistant.io/tag/11111111-2222-3333-4444-555555555555
The issue is reproducible even when the card is written by the same PN532 using ESPHome's write_mode(): the phone subsequently reads the written NDEF tag correctly, but ESPHome still fails to read it back and reports:
Authentication failed - Block 0x04
ESPHome then exposes only the physical card UID instead of the Home Assistant tag ID.
Expected behavior: The PN532 should read the NDEF record and return the Home Assistant tag ID, matching the result from a phone scan.
Actual behavior: MIFARE Classic authentication fails on block 0x04, no NDEF message is returned, and ESPHome falls back to the hardware UID.
Related issue: #9875 shows the same Authentication failed - Block 0x04 message, but appears to address a different repeated-read/timeout problem.
Which version of ESPHome has the issue?
2026.8.2
What type of installation are you using?
Home Assistant Add-on
What platform are you using?
ESP32
Component causing the issue
pn532 / pn532_i2c
YAML Config
esphome:
name: pn532-mifare-test
esp32:
variant: esp32c3
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
api:
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
i2c:
sda: GPIO8
scl: GPIO9
scan: true
frequency: 100kHz
pn532_i2c:
id: pn532_reader
update_interval: 500ms
on_tag:
then:
- lambda: |-
ESP_LOGI(
"nfc_test",
"UID: %s | has_ndef_message: %s",
x.c_str(),
tag.has_ndef_message() ? "true" : "false"
);
if (tag.has_ndef_message()) {
auto message = tag.get_ndef_message();
auto records = message->get_records();
for (auto &record : records) {
ESP_LOGI(
"nfc_test",
"NDEF payload: %s",
record->get_payload().c_str()
);
}
}
- homeassistant.tag_scanned: !lambda |-
return x;Anything in the logs that might be useful for us?
The PN532 detects the card correctly as MIFARE Classic, but authentication of block 0x04 fails:
[D][pn532:362]: Mifare classic
[E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[I][nfc_test]: UID: 81-07-6B-6D | has_ndef_message: false
[D][pn532:197]: Found new tag '81-07-6B-6D'
[D][pn532:377]: Waiting to read next tag
The same physical card is readable by Android/NFC Tools and contains a valid NDEF record:
https://www.home-assistant.io/tag/4980ba32-316c-4a6c-84d1-daa5e53f45d6
Card information reported by NFC Tools:
Tag type: ISO 14443-3A
Product: NXP MIFARE Classic 1K
UID: 81:07:6B:6D
ATQA: 0x0004
SAK: 0x08
Technologies: MifareClassic, NfcA, Ndef
I also reproduced this after writing a new Home Assistant NDEF URI using the same PN532 through ESPHome write_mode(). The Android phone reads the newly written NDEF URI correctly, while ESPHome subsequently fails to read the NDEF content back and again falls back to the physical UID.Additional information
Additional verification:
- The card can be read correctly by Android/NFC Tools.
- NFC Tools identifies it as NXP MIFARE Classic 1K and shows the expected Home Assistant NDEF URL.
- The same PN532 can write a Home Assistant NDEF URI to the card using ESPHome
write_mode(). - After that write, Android immediately reads the correct new Home Assistant tag ID.
- Reading the same card again with ESPHome still results in
Authentication failed - Block 0x04and only the physical UID is returned.
This suggests that the PN532 hardware and the card itself are working, while the ESPHome MIFARE Classic NDEF read/authentication path is failing.
Possible areas to investigate:
- authentication key handling for MIFARE Classic NDEF sectors
- fallback to the default MIFARE key
FF FF FF FF FF FF - reselect/deselect behavior after a failed authentication attempt
Source: esphome/esphome