Read NDEF (NFC) using ESP32-C3, PN532 and MicroPython

magicfelix
Posts: 1
Joined: Mon Feb 23, 2026 11:05 am

Read NDEF (NFC) using ESP32-C3, PN532 and MicroPython

Postby magicfelix » Mon Feb 23, 2026 11:34 am

My goal is to read NDEF data containing an URL which is about 128 bytes.
I use an ESP32-C3-DevKitM1 and a the following PN532 NFC reader: https://www.berrybase.de/en/detail/0192 ... 9d428169dc
For communication with the PN532, this library is used: https://github.com/insighio/micropython ... n/pn532.py

Generally, using the reader works. It detects cards and prints their UIDs.
But trying to read NDEF data produces the following error („Response length checksum did not match length”):

Code: Select all

Found PN532 with firmware version: 1.6
No response from PN532!
Card UUID: 08355a34
Response length checksum did not match length!
Did not receive expected ACK from PN532!
The code producing this output is the following:

Code: Select all

from pn532 import PN532Uart

DEBUG = False

try:
    rf = PN532Uart(1, tx=6, rx=7, debug=DEBUG)
    rf.SAM_configuration()
    ic, ver, rev, support = rf.get_firmware_version()
    print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
except Exception as e:
    rf = None
    print('No NFC reader (PN532) detected')

while rf is not None:
    try:
        uid = rf.read_passive_target()
        print("Card UUID: " + ''.join('{:02x}'.format(x) for x in uid))
        # INSELECT
        rf.call_function(0x54, params=[0x01])
        # Select application
        rf.call_function(
            0x40,
            params=[0x01, 0x00, 0xA4, 0x04, 0x0C, 0x07, 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01, 0x00],
        )
        # Select file
        rf.call_function(
            0x40,
            params=[0x01, 0x00, 0xA4, 0x00, 0x0C, 0x02, 0xE1, 0x04],
        )
        # Read binary
        ndef_data = rf.call_function(
            0x40,
            params=[0x01, 0x00, 0xB0, 0x00, 0x00, 0x00],
        )

        print(ndef_data)

    except Exception as e:
        print(e)
Does anyone have an idea how to get it working?

Who is online

Users browsing this forum: trendictionbot and 2 guests