New NFC feature on nRF52 Series: Read/write capable Type 4 Tag NFC library in nRF5 SDK.

The nRF52832 and nRF52840 devices have a built-in NFC radio which can be used for exposing data as a dynamic NFC tag (a tag with configurable data). This can be used as a standard tag type for storing a web link or a text, to launch apps on smartphones and tablets as well as for simple and secure BLE pairing (read more here). All these features are provided by the Type 2 Tag library in the nRF5 SDK. Starting from version 12.2 of the nRF5 SDK, we expanded the NFC software to support even more features. The new Type 4 Tag library does not only allow faster communication and exposing more data in the tag, but also provides the write functionality. So you can write data to the tag with an NFC Reader/Writer such as a smartphone. Furthermore, NFC Type 4 Tag is used in many secure transactions systems, e.g., payment systems, transport ticketing systems etc. Thus, it opens up new markets for the nRF52 Series with its combined NFC and BLE functionallity

Use case: Configuring a BLE device via NFC.

Writing data through the NFC can be used to easily configure a BLE device such as a beacon. Most beacons don’t have I/O capabilities (displays, buttons), and if there are many of them in the range, it is not that easy to configure their parameters – you would need to find the one and setup a BLE connection. So why not use NFC to configure your beacon by simply touching it? Additionally, this could be helpful for production configuration – there could be plenty of beacons on a production line and each of them needs its own configuration.

Let me try to explain how to do it. First you need to define what parameters you would like to send to your beacon: this could be name, UUID, specific advertising parameters etc. Then prepare your data for writing to the tag: you can try to develop your own app, that will encode the configuration data or use an existing app. Use custom “MIME Type” because the tag information is non-standard. The detailed format of the beacon configuration parameters to send over NFC is up to you. Additionally, if authentication is required you may use signing of the configuration data and verify them in the beacon application.

image description

On the embedded side you will need to develop a BLE application, that will use the Type 4 Tag library in a writable mode. The data received from the smartphone will use the standard NFC format called NDEF. To get your configuration parameters out of the NDEF message use the NDEF parser libraries (message and record parsers) and your own parser to decode the payload according to the format you defined. Then store the received data using the “Flash Storage” module. Now your application can re-configure to use the new parameters. The SDK application “Experimental: Writable NDEF Message Example” can help you configure and use the Type 4 Tag library in a writable mode. As you can see, implementation of an NFC-configurable beacon is not very complex. And from a beacon user perspective, configuration through NFC can be a great simplification.

Getting started with NFC Type 4 Tag using nRF5 SDK

As a first step, open the “Writable NDEF Message Example” (examples\nfc\experimental_writable_ndef_msg) – it will show you, how the Type 4 Tag library can be used for exposing initial data in the tag in a writable mode, so a reader/writer can overwrite it. The written data can be parsed using the following NDEF Message Parser (components\nfc\ndef\parser\message).

Once you have your configuration data you can use it and/or store it in a persistent storage e.g. on-board Flash memory using nrf_nvmc module (components\drivers_nrf\hal) or the Flash Storage module (components\libraries\fstorage) if you use a SoftDevice in your application.