Skip to main content

NFC Usage on Seeed Studio XIAO nRF52840 (Sense)

Both the Seeed Studio XIAO nRF52840 series are equipped with an NFC (Near Field Communication) module based on the nRF52840's built-in NFCT (Near Field Communication Tag) peripheral. It supports NFC Type 2 Tag functionality. By connecting an external NFC antenna, the XIAO nRF52840 can act as an NFC tag and be read by smartphones and other NFC readers.

This wiki walks you through the complete NFC usage workflow — from library installation, hardware connection, antenna tuning, to setup verification and creating your own NFC tag.

note

This tutorial is based on the XIAO_nRF52840_NFC library. The Seeed nRF52 Boards version 1.1.13 has been tested and approved.

Preparatory Work

For the board libraries installation, please refer to this tutorial to finish installing the Seeed nRF52 Boards. If you have already installed, we can move on.

note

Make sure to select the Seeed XIAO nRF52840 board in the Boards Manager. The older "Seeed nRF52 mbed-enabled Boards" library is no longer maintained and should not be used.

Hardware Required

Seeed Studio XIAO nRF52840Seeed Studio XIAO nRF52840 Plus
Seeed Studio XIAO nRF52840 SenseSeeed Studio XIAO nRF52840 Sense Plus
tip

The basic NFC functionality works with just the antenna soldered to NFC1/NFC2. After community testing (special thanks to andriandreo from the Seeed forum), both of the following antennas worked right after soldering without further circuit tuning:

  • MOLEX 1462360051
  • TAOGLAS FXR.07.A.DG

Later, we added two 43 pF tuning capacitors from each NFC pad (D14, D15) to GND for the TAOGLAS FXR.07.A.DG to further enhance the interrogation distance. The ~40 pF capacitor value was calculated from subsection "6.14.10 NFCT antenna recommendations" in the nRF52840 MCU product specification datasheet.

If you experience unstable behavior (incomplete pop-ups, intermittent detection), adding matching capacitors will significantly improve reliability. See Antenna Tuning for details.

For more real-world testing insights, check out the original forum discussion.

Software Required

ItemVersion / Notes
Arduino IDE1.8.x or later
Seeed nRF52 Boards1.1.13 (install via Arduino IDE Boards Manager)
XIAO_nRF52840_NFC LibraryDownload from GitHub, install via Sketch > Include Library > Add .ZIP Library (see below)
NFC Tools AppAndroid / Apple

Installing the XIAO_nRF52840_NFC Library

This library is not included in the Arduino Library Manager — you need to install it manually from GitHub.

  • Step 1. Go to the XIAO_nRF52840_NFC GitHub repository, click the green Code button, and select Download ZIP.

  • Step 2. Open Arduino IDE, go to Sketch > Include Library > Add .ZIP Library....
  • Step 3. Select the downloaded ZIP file (XIAO_nRF52840_NFC-main.zip). You should see "Library added to your libraries" in the status bar.

  • Step 4. Restart Arduino IDE. After restarting, you should see the examples under File > Examples > XIAO_nRF52840_NFC.

Hardware Connection

XIAO nRF52840's NFC pins are located on the back of the board, labeled P0.09 and P0.10:

D14 (P0.09) — NFC1 — Antenna end A
D15 (P0.10) — NFC2 — Antenna end B

Solder the NFC antenna to P0.09 and P0.10 as shown below:

In this tutorial, we are using the Seeed Studio XIAO nRF52840 with a Nordic-recommended NFC antenna for demonstration.

Front view:

Antenna soldered to XIAO front view

Back view:

Antenna soldered to XIAO back view

caution
  • NFC antenna is a differential signal and has no polarity — either end can go to D14 or D15.
  • The two pins ship from factory as NFC antenna mode (UICR = 0xFFFFFFFF) on XIAO nRF52840 and XIAO nRF52840 Sense. On XIAO nRF52840 Plus and XIAO nRF52840 Sense Plus, they may be configured as GPIO by default — check UICR first (see Step 1).
  • It is recommended to measure DC resistance across the antenna terminals with a multimeter before soldering (usually 1–3 Ω) to confirm continuity and rule out shorts.

Antenna Tuning

NFC relies on a resonant LC tank circuit. The antenna coil provides inductance (L), and the matching capacitors provide capacitance (C). Together they form a resonant circuit at the target frequency:

f = 1 / (2π√(LC))

The target is 13.56 MHz. Without external capacitors, only the nRF52840's internal ~4 pF parasitic capacitance participates — the resonance point is far from 13.56 MHz. The NFC function will still work, but communication may be unstable: phone pop-ups may show "NFC tag detected" without the full content, and error codes may appear in the serial output. Adding matching capacitors brings the LC tank to resonance and dramatically improves reliability.

tip

All the operations below are based on the Nordic Official NFC Antenna Design document. The chip delivers full power only when it sees a differential 100 Ω load at resonance.

Fixed Parameters

ItemFixed ValueSource
Operating frequency f13.56 MHzGlobal NFC standard, hard-coded in nRF52840
Load impedance100 Ω (differential)Nordic white-paper nWP_026

Measurements You Need

  • Coil inductance L — measure with a DMM / LCR meter / VNA at 100 kHz, value in µH.
  • Coil loss resistance R — read the series resistance from the same screen, in Ω.

Step 1: Impedance Pre-Check

Using the impedance-transformation formula:

Impedance formula

Target: 90–120 Ω, the closer to 100 Ω the better.

ResultMeaningNext Step
< 60 ΩAntenna too smallAdd turns or enlarge the coil area
90 – 120 ΩPASSGo to Step 2
> 150 ΩAntenna too bigRemove turns or shrink the coil area

Only after this gate is passed do you calculate capacitors; otherwise any capacitor value is useless.

Step 2: Calculate Resonant Capacitance

Formula with fixed 13.56 MHz:

Capacitance formula

This gives the total capacitance needed. For a π-network, split equally:

C1 = C2 = C / 2

Pick the closest E12 value (e.g., 39 pF, 47 pF, 56 pF, 68 pF …).

If you don't have an LCR meter and prefer a known starting point, a standard 13.56 MHz NFC coil antenna works well with the XIAO nRF52840. Below is the antenna we used during testing:

ParameterValue
Type13.56 MHz NFC coil
DC Resistance~2.3 Ω
ConnectionSolder directly to NFC1 / NFC2
note

The antenna shown above is not a Seeed Studio product. You can use any 13.56 MHz NFC coil antenna with similar specifications. The key is to measure the inductance and calculate the matching capacitor value using the formulas above.

NFC Setup & Examples

The following workflow first verifies your NFC hardware setup, then walks you through creating your own NFC tag. We use the XIAO_nRF52840_NFC library, which wraps the nRF52840 NFCT peripheral into a clean Arduino API.

The library includes six example sketches:

CategoryExample SketchPurpose
Verificationxiao-nrf52840-nfc-probeCheck UICR pin configuration + verify RF link
xiao-nrf52840-nfc-restore-uicrRestore NFC pins if they were changed to GPIO
Plus Fixxiao-nrf52840-plus-bootloader-verifyVerify bootloader on Plus variants before UICR restore
Demoxiao-nrf52840-nfc-tag-readonlyRead-Only Tag — phone reads a fixed URL
xiao-nrf52840-nfc-tag-writableWritable Tag — phone can write data to the tag
xiao-nrf52840-nfc-tag-persistentPersistent Tag — data survives power cycles (stored in Flash)

Step 1: Check UICR Pin Configuration

Purpose: Confirm P0.09/P0.10 are configured as NFC antenna pins.

Open File > Examples > XIAO_nRF52840_NFC > xiao-nrf52840-nfc-probe and upload it to your board. (Steps 1 and 2 share the same sketch — one upload does both.)

Open Serial Monitor at 115200 baud. The first few lines show the current UICR status:

How to interpret the output:

UICR ValueMeaningAction
0xFFFFFFFFNFC antenna mode ✅Proceed to Step 2
0xFFFFFFFEGPIO mode ❌Upload xiao-nrf52840-plus-bootloader-verify first (Plus variants), then upload xiao-nrf52840-nfc-restore-uicr, send RESTORE_NFC in Serial Monitor, confirm Verify result: PASS, then power-cycle the board
note

XIAO nRF52840 and XIAO nRF52840 Sense ship from factory with UICR = 0xFFFFFFFF (NFC mode). In most cases, this step is a pass and no action is needed. XIAO nRF52840 Plus and XIAO nRF52840 Sense Plus may ship with GPIO mode — if the output shows 0xFFFFFFFE, follow the restore action below.

Purpose: Confirm that NFC command frames from the phone can reach the board.

After the UICR check, the same sketch automatically enters Probe mode. In this mode, the tag does not reply to any frames — it only listens. This isolates the receive direction, making it easy to confirm whether the RF link is alive.

Place your phone's NFC area close to the antenna for a few seconds, then check the Serial Monitor output:

Key indicators:

CounterMeaningPass Criteria
FIELD_DETECTPhone's 13.56 MHz RF field detected> 0
FIELD_LOSTRF field disappearedClose to FIELD_DETECT
READER_FRAMESNFC command frames received from phone> 0 (critical)

READER_FRAMES > 0 means the phone's command frames successfully reached the board and the bidirectional RF link is established. The phone should not show a pop-up at this stage (Probe mode does not reply).

Common error codes:

Error CodeNameMeaning
0x01FRAMEDELAYTIMEOUTFrame delay timeout — tag did not receive next command within expected interval
0x02NFCANTENNAERRORNFCT cannot drive antenna — usually caused by impedance mismatch or missing antenna
0x80RX frame receive errorFrame received but CRC/parity check failed (may appear in Readonly stage)

Demo 1: Read-Only Tag

Purpose: A simple NFC tag that broadcasts a fixed URL. The phone reads it and displays a pop-up — the most common NFC use case.

Open File > Examples > XIAO_nRF52840_NFC > xiao-nrf52840-nfc-tag-readonly and upload it. Place your phone on the antenna for 2–3 seconds.

The phone should display a pop-up containing the link https://seeedstudio.com.

Antenna soldered and phone NFC popup

Key indicators:

CounterMeaningPass Criteria
FIELD_DETECTPhone's 13.56 MHz RF field detected> 0
SELECTEDPhone completed anti-collision + SELECT handshake> 0 (core indicator)
READPhone successfully read NDEF data pages> 0
FAST_READNumber of FAST_READ requests received0 or small (normal)
UNSUPPORTEDPhone sent an unsupported commandA few is normal

SELECTED > 0 is the key threshold: the anti-collision flow passed and the phone recognized the Type 2 Tag. READ > 0 means NDEF pages were actually read. The final verification is that the phone displays the full URL pop-up.

note

The URL is hard-coded in the sketch. To change it, open the sketch and modify the NDEF message, then re-upload. The tag data is stored in RAM and will be lost after a power cycle.

Demo 2: Writable Tag

Purpose: An NFC tag that the phone can both read and write. The tag starts with a default URI (https://seeedstudio.com), and the phone can overwrite it with new NDEF content using the NFC Tools app.

Open File > Examples > XIAO_nRF52840_NFC > xiao-nrf52840-nfc-tag-writable and upload it.

Test steps:

  • Step 1. Open Serial Monitor at 115200 baud. The boot log shows the tag identity (NFCID1), initial memory dump, and the default URI (https://seeedstudio.com).

The boot log also prints the default URI that the tag will broadcast:

  • Step 2. Read the tag with your phone first. The phone should detect https://seeedstudio.com.

  • Step 3. Open NFC Tools (or any NFC writer app), write the content you want to the tag. In this example, we write a simple text: hello!. After entering your content, click "Write / XX Bytes" — the byte count depends on the length of your content.

  • Step 4. Read the tag again. The phone should now display the newly written content (hello!).

After the phone leaves the NFC field, the Serial Monitor shows the updated key indicators reflecting the complete read-after-write session:

Key indicators:

CounterMeaningPass Criteria
FIELD_DETECTPhone's 13.56 MHz RF field detected> 0
SELECTEDPhone completed anti-collision + SELECT handshake> 0 (core indicator)
READPhone successfully read NDEF data pages> 0
WRITEPhone successfully wrote data to the tag> 0 (core indicator)
FAST_READNumber of FAST_READ requests received0 or small (normal)
WRITE_REJECTEDWrite attempts rejected (protected pages)0 (should never occur with standard apps)
UNSUPPORTEDPhone sent an unsupported commandA few is normal

WRITE > 0 is the key threshold for Writable: the phone successfully wrote data to the tag. WRITE_REJECTED should always be 0 — if it increases, something went wrong during the write session.

note

The written data is stored in RAM only and will be lost after a power cycle, restoring the default URI — which makes repeated write tests easy. For data that needs to survive power cycles, use the Persistent Tag demo below.

Demo 3: Persistent Tag

Purpose: An NFC tag whose data survives power cycles. The NDEF content is stored in the nRF52840's internal Flash memory (LittleFS), so it persists even after the board is powered off and on again — ideal for long-term deployments.

Open File > Examples > XIAO_nRF52840_NFC > xiao-nrf52840-nfc-tag-persistent and upload it.

Test steps:

  • Step 1. On first boot, open Serial Monitor at 115200 baud. The boot log shows the default URI and Storage state: no stored content, using default URI.
  • Step 2. Read the tag with your phone. On first boot, the phone detects https://seeedstudio.com.

  • Step 3. Open NFC Tools (or any NFC writer app), write a new text or URL record to the tag. In this example, we write a simple text: hi!. After entering your content, click "Write / XX Bytes" — the byte count depends on the length of your content.

  • Step 4. After the phone leaves the NFC field, the Serial Monitor prints Storage: tag content saved to flash, confirming the content has been written to internal Flash.
  • Step 5. Power-cycle the board — unplug the USB cable and plug it back in.

  • Step 6. After reboot, the Serial Monitor prints Storage state: previous content restored from flash, confirming the written content has survived the power cycle.

  • Step 7. Read the tag with your phone again. The phone should display the content written in Step 3 — even after the power cycle.

Key indicators:

The key indicators are the same as the Writable Tag — refer to the Writable Tag table for the full list.

Storage state: previous content restored from flash in the boot log is the core confirmation for Persistent: the data survived the power cycle. Storage: tag content saved to flash confirms each write was saved to Flash.

note

In Step 7, the phone only reads the restored content — it does not write anything. So WRITE will remain 0 in the counters, which is expected. You only see WRITE > 0 during the earlier write session (Step 3–4).

note
  • The stored content lives in the internal Flash filesystem (/nfc-tag-data.bin), separate from the sketch area — it survives sketch re-uploads.
  • To restore the default URI at any time, send RESET_TAG in the Serial Monitor.
  • Flash save happens once per write session after the phone leaves the field. If you remove the phone too early, the content may be incomplete — just write again to fix it.
tip

Summary of the three demos:

DemoData StorageSurvives Power CycleWriteable by Phone
Read-Only TagRAM
Writable TagRAM
Persistent TagFlash

Resources

Special Thanks

Special thanks to andriandreo for the extensive real-world testing of NFC antennas (MOLEX 1462360051 and TAOGLAS FXR.07.A.DG) on the XIAO nRF52840, and to PJ_Glasso for the capacitor calculation guidance and iPhone compatibility troubleshooting.

If you encounter NFC issues not covered here, you may find helpful tips in the original forum thread:

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...