NFC: Shell

This sample demonstrates the NFC transport feature for a shell interface. It runs the shell interface with the NFC T4T ISO-DEP transport layer. It uses the NFC shell transport library.


The sample supports the following development kits:

Hardware platforms


Board name

Build target

nRF54L15 PDK



nrf54l15pdk/nrf54l15/cpuapp nrf54l15pdk@0.3.0/nrf54l15/cpuapp

nRF54H20 DK




nRF5340 DK



nrf5340dk/nrf5340/cpuapp/ns nrf5340dk/nrf5340/cpuapp

nRF52 DK




nRF52840 DK




When built for an _ns build target, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

The sample also requires the polling device with support for raw ISO-DEP (ISO14443-4A) protocol. The polling device must follow data exchange mechanism described in the NFC shell transport library.


This sample presents one of possible ways to run shell through the NFC T4T transport layer. This is not a common use case for NFC as an NFC tag is a passive device. However, this feature can be useful, for example, for devices provisioning on the production line. This sample runs a shell over the NFC transport and implements two shell commands that control LED 2.

You can use the following commands:

  • The led on command lits LED 2.

  • The led off command dims LED 2.

User interface

LED 1:

Blinks, toggling on/off every second, when the main loop is running.

LED 2:

Lits or dims when user issues the shell commands that control the LED.

Building and running

This sample can be found under samples/nfc/shell in the nRF Connect SDK folder structure.

To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Configuring and building an application for other building scenarios, Programming an application for programming steps, and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.


If you are using debug messages in the NFCT driver, the driver might not be working properly if you have CONFIG_LOG_MODE_IMMEDIATE enabled. The NFCT driver is part of the nrfx driver package. For more information about this driver, see the NFCT driver page in the nrfx repository.


After programming the sample to your development kit, complete the following steps to test it:

  1. Open a serial port connection to the kit using a terminal emulator that supports VT100/ANSI escape characters (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.

  2. Reset your development kit.

  3. Observe that the sample starts.

  4. Touch the NFC antenna with the polling device.

  5. Observe that the shell prompt appears on the terminal.

  6. Keep the NFC antenna in the polling device field range.

  7. Issue the led on command through the terminal.

  8. Observe that the LED 2 lits.

  9. Issue the led off command through the terminal.

  10. Observe that the LED 2 dims.

  11. You can play with other build-in shell commands.


This sample uses the following nRF Connect SDK libraries:

It uses the following Zephyr libraries:

  • include/zephyr/kernel.h

  • zephyr/shell/shell.h