XIAO BLE NFC doesnt work

Hi,
I’m trying to work with the NFC without luck.
I’ve connected a few NFC antennas that work with other NFC devices but I can get any reading from it.
I’ve installed version 1.0.0 and used the example projects for text and URL.

Any ideas?

Did you enable the NFC pins as NFC pins? Not sure if they are enabled by default.

hmm… how do I do that?

They supposed to be enabled by default, but may be you can check. Also the NFC antenna circuit has to be very specific with proper external capacitors sizing. Check with this forum by Nordic:
https://devzone.nordicsemi.com/f/nordic-q-a/35505/nrf52-enabling-gpio-on-nfc-pins

What antennas have you tried, I plan on looking into being able to change the NFC (TAG) message programmatically if it’s indeed possible. Maybe some smart seeed guys or gals has an answer.

I see it requires tuning with the correct caps. I’m curious to find out how thick of material (PLA or Carbon-fiber nylon) would it pass through. ANy ideas or thoughts on the subject is appreciated.

GL ;-p

Hey just checking to see if you got this working I have wired up an antenna but it isn’t seeming to work using the seeed code.
Thanks

Hi Parker_Gust,
Wow cool what antenna is that? , What type ? Any schematic ,
what value of capacitors did yo use?
I use NFC pro Tools to test with… LOL
HTH
GL :-p

The Seeed nRF52 Boards version 1.1.3 and Seeed nRF52 mbed-enabled Boards version 2.9.2 have been tested and approved.
You can update these yourself in the Arduino IDE’s Board Manager.
Thank you all for waiting :smiley:!

The NFC pins on the boards that I got were not set to NFC function.
I’ve reflashed the bootloader and it worked.

Hi Tovi,
Could you provide more info on the NFC configuration you are using. Would you be able to post relevant code example. any antenna info also, would be greatly appreciated and the users would all benefit.
GL :slight_smile: PJ

For us Short bus Folks can You spell it out on This?
TIA
GL :slight_smile: PJ

Due to the issue

Sorry, new users can only put one embedded media item in a post.
Sorry, new users can only put 2 links in a post.

I split this up in several posts …

I also tried to get the NFC running. Here what I did and how I got it running for my use cases.

Required steps

  1. It is required to configure the NFC pins for NFC with the UICR (Nordic documentation)
  2. It is required to recompile the (Adafruit_nRF52) bootloader (link) with the option USE_NFCT, which prevents setting the cmake option CONFIG_NFCT_PINS_AS_GPIOS, which disables the NFC pins for NFC usage on each reboot.
  1. The Adafruit nRF52 bootloader does not include the XIAO BLE boards definition. You need to add them yourself. I took 0hotpotman0’s changes as a reference and applied it to the latest Adafruit nRF52 Bootloader version. See my git diff file below

    1. build with “make BOARD=xiao_nrf52840_ble_sense” (I assume you have the dependencies like gcc installed)
    2. Double reset the XIAO BLE board and copy the file _build/build-xiao_nrf52840_ble_sense/update-xiao_nrf52840_ble_sense_bootloader-0.7.0-32-g7210c39-dirty_nosd.uf2
  2. It is required to get a NFC Antenna and tune it with the correct capacitors (It won’t work without these capacitors!)

    1. I had a broken nRF52840-dk. So I took the antenna and the required 300pf capacitors from there.
  3. I am not sure here, but it seemed somehow my UICR were protected?? So I required? an eraseall using a SWD debugger. (more info below)

    1. See Nordic Devzone 82798 for more information

      1. Erase all

        1. nrfjprog --eraseall
      2. Check the NFC related UICR. It should return FFFFFFFF and not FFFFFFFE

        1. nrfjprog --memrd 0x1000120C --w 32 --n 4
      3. Flash the adafruit bootloader again after having erase all.

        1. nrfjprog -f nrf52 --verify --chiperase --program _build/build-xiao_nrf52840_ble_sense/xiao_nrf52840_ble_sense_bootloader-0.7.0-32-g7210c39-dirty_s140_7.3.0.hex --reset

Copied this from the Adafruit Feather nRF52840 Sense tutorial on the Adafruit page (Sorry cannot use more than 2 links per post). This made me think I need to eraseall

D2/NFC2: The D2 pin is uses the same pad as one-half of the NFC antenna pins. By default, the nRF52840 Feather ships with these pins configured for GPIO mode, which is done by writing a value to the UICR flash config memory. If you wish to use NFC, you will need to erase the UICR memory which requires erasing the entire chip, and you will need a
[Segger J-Link] to reflash the bootloader and firmware.

This is how my board looks like now.

Verification by flashing the sample NFC: Launch App with an iPhone

Additional information / more details

  1. Code to check if the NFC pins are configured for NFC and configure them for NFC if not.

    1. Note that this code is for nRF Connect SDK not Arduino. (I think you only need to change printk with print and include nrf headers)
    2. Note that if the bootloader is configured without USE_NFCT, it will revert your changes with each reboot. And since the changes only get active after reboot, this code does not work without bootloader changes.
    if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
        printk("NFCPINS = as NFC\n");
    } else {
        printk("NFCPINS = as GPIO\n");
        nvmc_config(NVMC_CONFIG_WEN_Wen);
        NRF_UICR->NFCPINS = NRF_UICR->NFCPINS | (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos);
        nvmc_wait();
        nvmc_config(NVMC_CONFIG_WEN_Ren);
        NVIC_SystemReset();     
    }
  1. Diff to the latest Adafruit nRF52 Bootloader version (7210c39)
diff --git a/src/boards/boards.c b/src/boards/boards.c
index de95950..c2f56b2 100644
--- a/src/boards/boards.c
+++ b/src/boards/boards.c
@@ -73,9 +73,8 @@ void board_init(void)
   // Use Internal OSC to compatible with all boards
   NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC;
   NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
-
-  button_init(BUTTON_DFU);
-  button_init(BUTTON_FRESET);
+  //button_init(BUTTON_DFU);
+  //button_init(BUTTON_FRESET);
   NRFX_DELAY_US(100); // wait for the pin state is stable
 
 #if LEDS_NUMBER > 0
diff --git a/src/boards/boards.h b/src/boards/boards.h
index 8aa0ece..9bb6b83 100644
--- a/src/boards/boards.h
+++ b/src/boards/boards.h
@@ -37,13 +37,13 @@
 #define UF2_VOLUME_LABEL   "NRF52BOOT  "
 #endif
 
-#ifndef BUTTON_DFU
-#define BUTTON_DFU      BUTTON_1
-#endif
+//#ifndef BUTTON_DFU
+//#define BUTTON_DFU      BUTTON_1
+//#endif
 
-#ifndef BUTTON_FRESET
-#define BUTTON_FRESET   BUTTON_2
-#endif
+//#ifndef BUTTON_FRESET
+//#define BUTTON_FRESET   BUTTON_2
+//#endif
 
 // The primary LED is usually Red but not in all cases.
 #define LED_PRIMARY 0
@@ -105,9 +105,9 @@ void led_tick(void);
 // BUTTONS
 //--------------------------------------------------------------------+
 // Make sure we have at least two buttons (DFU + FRESET since DFU+FRST=OTA)
-#if BUTTONS_NUMBER < 2
-#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
-#endif
+//#if BUTTONS_NUMBER < 2
+//#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
+//#endif
 
 void button_init(uint32_t pin);
 bool button_pressed(uint32_t pin);
diff --git a/src/boards/xiao_nrf52840_ble/board.mk b/src/boards/xiao_nrf52840_ble/board.mk
index 8a77053..9142556 100644
--- a/src/boards/xiao_nrf52840_ble/board.mk
+++ b/src/boards/xiao_nrf52840_ble/board.mk
@@ -1,2 +1,3 @@
 MCU_SUB_VARIANT = nrf52840
-SD_VERSION = 7.3.0
\ No newline at end of file
+SD_VERSION = 7.3.0
+USE_NFCT = yes
\ No newline at end of file
diff --git a/src/boards/xiao_nrf52840_ble_sense/board.mk b/src/boards/xiao_nrf52840_ble_sense/board.mk
index 8a77053..9142556 100644
--- a/src/boards/xiao_nrf52840_ble_sense/board.mk
+++ b/src/boards/xiao_nrf52840_ble_sense/board.mk
@@ -1,2 +1,3 @@
 MCU_SUB_VARIANT = nrf52840
-SD_VERSION = 7.3.0
\ No newline at end of file
+SD_VERSION = 7.3.0
+USE_NFCT = yes
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 960daa4..55e53d6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -259,10 +259,10 @@ static void check_dfu_mode(void)
 
   /*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
   // DFU button pressed
-  dfu_start = dfu_start || button_pressed(BUTTON_DFU);
+  //dfu_start = dfu_start || button_pressed(BUTTON_DFU);
 
   // DFU + FRESET are pressed --> OTA
-  _ota_dfu = _ota_dfu  || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;
+  //_ota_dfu = _ota_dfu  || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;
 
   bool const valid_app = bootloader_app_is_valid();
   bool const just_start_app = valid_app && !dfu_start && (*dbl_reset_mem) == DFU_DBL_RESET_APP;

SORRY new users are not allowed to post more than 3 consecutive posts … So I have to remove all links below :frowning:

  1. How to attach SWD in case the device gets bricked or to erase flash and flash the complete bootloader incl. softdevice.

    1. I found this XIAO BLE (Sense) bootloader bricked, how to restore it? (I had to remove the link. Search this forum yourself)

    2. (What I did) You can use any Nordic dk. For example see chapter 4.11.2 Programming a board with custom connections of nRF7002_DK_User_Guide_v1.0.0.pdf (I had to remove the link. Google for yourself)

      1. Make sure that the voltage fits. In case of the nRF7002dk, do not attach USB power but use the 1.8V VDD of the dk!
      2. Just hold 2 jumper wires against the CLK and DIO pins on the back while flashing. That is enough. No soldering or anything complex. It’s only a second to flash.
  2. I did not use any Arduino code. So I do not know if there are issues.

  3. Actually I cannot really make sense of this statement. “The Seeed nRF52 Boards version 1.1.3 and Seeed nRF52 mbed-enabled Boards version 2.9.2 have been tested and approved.”

    1. Might be that they updated the bootloader?
    2. Might be there was an issue in the Arduino NFC library?

Just a further note, in case you missed this in the documentation: Do not expect that you can read/write NFC. This is a NFC tag only.

I hope this help in getting the NFC feature work :slight_smile:

The NFC function will perform well when we use the “Seeed nRF52 mbed-enabled Boards Library”.

I managed to replicate the Arduino example code in the Wiki using the “Seeed nRF52 mbed-enabled Boards Library” as stated and both antennas below:

1 Like

Both worked right just after soldering without further circuit tuning. Later, I added two 43 pF caps from each NFC pad to GND to further enhance the interrogation distance for the TAOGLAS FXR.07.A.DG.

The ~40 pF cap value was calculated from subsection “6.14.10 NFCT antenna recommendations” in nRF52840 MCU product specification datasheet.

PS. Not sure why they mark these replies as spam - They’re not, just trying to help here…

Hi there,
They are not Spam, looks like a too quick to click with the Spam flag, the spam bombing the forum took.earlier.
Repost it as a topic Please , it’s good info for Xiao users here.
Thanks,
GL :slight_smile: PJ :v:
" Xiao NFC antenna info" or something. the "XIAO BLE NFC doesnt work " isn’t getting it LOL :smile:

Yeah, you’re right! Thanks for the suggestion.

Here is the new topic link for those interested: