nRF5 SDK v15.3.0
NFC UART Example

The NFC UART Example shows how to exchange custom data over NFC between the tag device and the poller device. Each of these devices collects incoming UART data and sends it over NFC. Similarly, the devices also collect incoming NFC data and send it over UART.

Note
All buffered data that was collected from UART channel before selecting the tag is discarded.

NFC tag device

When the application starts, it initializes the NFC tag and the UART peripheral. Then, it sets up the NFC library for Type 4 Tag platform, which senses the external NFC field and handles NFC communication. In this example, the library works in Raw ISO-DEP mode, which is always configured by default. In this mode, all APDU exchanges are handled by the application.

Events handled by the application are mostly the NFC events. Each of these events is related to the following LED actions:

NFC event LED action
NFC field on LED 1 is lit.
NFC data indication LED 2 is lit, when ISO-DEP chaining is active.
NFC field off All LEDs are turned off.

When the NFC tag is selected by the poller device (indicated by LED 1), the UART data exchanges can start.

The NFC UART Example shows the usage of the NFC Type 4 Tag module.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\nfc\nfc_uart\tag

Note
This application is not power optimized!

NFC poller device

The example requires the Adafruit PN532 NFC Shield.

When the example application starts, it initializes the Adafruit PN532 NFC Shield and the UART peripheral. Then, it waits for a Type 4 Tag to appear in the field. When a tag is detected, the UART data exchanges can start.

Note
This application is not power optimized!

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\nfc\nfc_uart\poller

Testing

Test the NFC UART Example with a smartphone or a tablet with NFC support by performing the following steps:

  1. Compile and program the NFC tag device.
  2. Compile and program the NFC poller device.
  3. Put the NFC Tag device close to the poller device. Observe that LED 1 is lit.
  4. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  5. Repeat the previous step for the second device.
  6. Type some text in any of the terminals and observe that it is displayed in the other one.

Documentation feedback | Developer Zone | Subscribe | Updated