This post was last edited by dirty on 2023-11-5 23:10
Combined with hardware resources, this article mainly realizes the creation of new projects and reading NFC tags.
Preparation:
1. Insert the NFC tag antenna into the development board as shown in Figure 1 below, with the NORDIC silkscreen facing up. Do not insert it upside down, as it will feel stuck when inserted properly.
2. Install the NFC APP on your phone. Nordic recommends nRF Toolbox, which seems to be hard to find in the resource app store. I used the alternative "NFC Tag Assistant" from Fudan Micro, which can also be used for subsequent debugging.
Figure 1: NFC tag installation
1. New construction project
1. Open VSCode, as shown in Figure 2. Create a new application project and select the NFC project.
Figure 2: Create a new application project
2. Set the project path and folder name. The path is recommended to be under the SDK path.
Figure 3: Select the project path and project folder
3 After the above is completed, a project folder is generated under the SDK, as shown on the left side of Figure 5. Configure the compilation options, select the board-level nrf77002dk_nrf5340_cpuapp_ns, (where ns is the app running non-safety applications, and without nsapp runs safety applications), and configure as shown in Figure 4.
Figure 4: Compile configuration
4. Add some logging to the code to understand NFC events. Build with ACTIONS option as shown in Figure 5.
Figure 5: Project files and compilation
5. Burn and open the serial port
Figure 6: Burning program and serial port configuration
2. NFC tag reading and interpretation
1. Turn on the NFC function on your phone, open the NFC APP, and bring it close to the NFC antenna. When the NFC event is triggered, the development board LED1 lights up, and when it leaves the proximity field, LED1 turns off. The debug serial port prints relevant logs (as shown in Figure 7). The NFC APP displays the NFC tag information (as shown in Figure 8).
Figure 7: NFC event log
Figure 8. NFC tag information
2. Interpret the code and label content.
In main.c, initialize the LED, set up NFC, register the event callback function nfc_callback, then register the package name and payload. Then set the NFC payload data and start NFC sensing.
The actual test label content is consistent with the setting parameters, as shown in Figure 9.
Figure 9: NFC tag content
Through the construction and testing of NFC projects, I became more familiar with the development in the vscode environment. Many of the official APIs have been packaged in the form of lib, and the main thing is to learn how to build and call the process.
In addition, you need to have some basic knowledge of the Linux-like Zephyr OS. Here is a very useful resource library @[1], which allows you to find the API you need in a large amount of information, helping you learn and develop DK.
[1]zephyr API Document
https://docs.zephyrproject.org/latest/doxygen/html/index.html