Skip to main content
Visitor II
September 23, 2025
Solved

Emulate NDEF tag ESP32

  • September 23, 2025
  • 3 replies
  • 801 views

Hello,

I’m working with an ST25R3916 and an ESP32-S3. I ported the RFAL library to the ESP32 (platform.c), and it works — I can successfully read a tag with this setup.
However, I’m struggling to emulate a tag in order to send an NDEF message.

Does anyone know where I could find an example implementation for this?

For more context: when I enable tag emulation, my reader correctly detects the programmed UID, but I can’t manage to retrieve the NDEF.

Thanks in advance.

    This topic has been closed for replies.
    Best answer by Brian TIDAL

    Hi,

    in Card Emulation, the ST25R3916 hardware handles automatic replies to anticollision frames. Once the Card Emulation is ready for upper layer communication (i.e. once the remote reader has retrieved the Card Emulation UID), the replies to remote commands are handled by the FW. The typical first message being received is RATS where the FW has to reply in less than 5ms. Could you make sure your port to ESP32 schedule the demo_cycle as a dense loop to be able to reply to RATS in less than 5ms?

    Also I suggest to enable the DEMO_CARD_EMULATION_ONLY compilation flag.

    Printf-like debugging/logging can as well delay the reply to the RATS.

    Rgds

    BT

     

    3 replies

    Technical Moderator
    September 23, 2025

    Hi Baptiste,

    An example of Card Emulation code is available in the pairing demo of the  ST25 Embedded Library. The X-CUBE-NFC6 also includes Card emulation demo. 

    See demo_polling.c and demo_ce.c files in those packages.

    Rgds

    BT

    BaptcalloAuthor
    Visitor II
    September 26, 2025

    Hi,

    Thanks for your reply,

    I tested with the two files (demo_ce.c and demo_polling.c), but unfortunately it still doesn’t work. With these demos, when I present a tag, it is detected properly. However, when I present a reader (tested with a Flipper Zero and several smartphones), the best I get is the UID — I never receive the NDEF message.

    I’ve been stuck on this issue for several weeks now. Could this be related to a hardware problem (custom board), or since I can already read a tag and emulate a UID, does it rather suggest a software issue?

     

     

    Technical Moderator
    September 29, 2025

    Hi,

    in Card Emulation, the ST25R3916 hardware handles automatic replies to anticollision frames. Once the Card Emulation is ready for upper layer communication (i.e. once the remote reader has retrieved the Card Emulation UID), the replies to remote commands are handled by the FW. The typical first message being received is RATS where the FW has to reply in less than 5ms. Could you make sure your port to ESP32 schedule the demo_cycle as a dense loop to be able to reply to RATS in less than 5ms?

    Also I suggest to enable the DEMO_CARD_EMULATION_ONLY compilation flag.

    Printf-like debugging/logging can as well delay the reply to the RATS.

    Rgds

    BT

     

    BaptcalloAuthor
    Visitor II
    September 29, 2025

    I had a 10 ms delay in the demo_cycle, I changed it to 1 ms and now it works.

    Thank you so much !