Xiao nrf52840 Sense - Platformio.ini file for BLE and IMU usage

Months ago (back in Jan-Feb 2025), I used the following code for my platformio.ini file:

[env:xiaoblesense]
platform = https://github.com/maxgerhardt/platform-nordicnrf52
framework = arduino
board = xiaoblesense

; Ensure we use the Nordic SDK-based core (not Mbed)
board_build.core = arduino

; Include necessary libraries
lib_deps =
arduino-libraries/ArduinoBLE@^1.4.1
seeed-studio/Seeed Arduino LSM6DS3@^2.0.5

; Enable serial monitor at 9600 baud
monitor_speed = 9600

; Disable compiler optimizations for debugging (optional)
build_flags = -O0

; Ensure correct upload method
upload_protocol = nrfutil

I tried updating the IO file board specifications (pulled from Xiao nrf52840 with Platform IO) and the libraries. It mentions “sense” on the website, so I assume this can also be used. My new file is:

[env:xiaoblesense]
platform = https://github.com/Seeed-Studio/platform-seeedboards.git 
board = seeed-xiao-afruitnrf52-nrf52840
framework = arduino

; Include necessary libraries
lib_deps =
arduino-libraries/ArduinoBLE@^1.4.1
seeed-studio/Seeed Arduino LSM6DS3@^2.0.5

; Enable serial monitor at 9600 baud
monitor_speed = 9600

; Disable compiler optimizations for debugging (optional)
build_flags = -O0

; Ensure correct upload method
upload_protocol = nrfutil


But I get this error when trying to build it:

.pio/libdeps/xiaoblesense/ArduinoBLE/src/utility/HCIUartTransport.cpp:39:2: error: #error “Unsupported board selected!”
#error “Unsupported board selected!”
^~~~~
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/Source/queue.c.o
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/Source/stream_buffer.c.o
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/Source/tasks.c.o
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/Source/timers.c.o
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/portable/CMSIS/nrf52/port_cmsis.c.o
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c.o
.pio/libdeps/xiaoblesense/ArduinoBLE/src/utility/HCIUartTransport.cpp:105:40: error: ‘SerialHCI’ was not declared in this scope
HCIUartTransportClass HCIUartTransport(SerialHCI, 912600);
^~~~~~~~~
Compiling .pio/build/xiaoblesense/FrameworkArduino/freertos/portable/GCC/nrf52/port.c.o
.pio/libdeps/xiaoblesense/ArduinoBLE/src/utility/HCIUartTransport.cpp:105:40: note: suggested alternative: ‘Serial’
HCIUartTransportClass HCIUartTransport(SerialHCI, 912600);
^~~~~~~~~
Serial
Compiling .pio/build/xiaoblesense/FrameworkArduino/hooks.c.o
*** [.pio/build/xiaoblesense/lib53a/ArduinoBLE/utility/HCIUartTransport.cpp.o] Error 1

Can anyone recommend how I can fix my project? And if using either of those libraries may brick the board (because now I cannot detect the board through a COM port)?

Hi there,

So does the double reset push work ? Get back to bootloader mode and I don’t think the board Def is correct. Or you need to update PLIO perhaps.
Something is just off slightly, Enough to break it though.
Have a Look here, we got it going here

I would try one of the other platform or board def’s :+1:

HTH
GL :santa_claus: PJ :v:

  1. I uploaded my previously working PLIO wrongly, apologies. This is it:

    [env:xiaoblesense]
    platform = https://github.com/maxgerhardt/platform-nordicnrf52
    framework = arduino
    board = xiaoblesense
    
    ; Ensure we use the Nordic SDK-based core (not Mbed)
    board_build.core = arduino
    
    ; Include necessary libraries
    lib_deps =
        arduino-libraries/ArduinoBLE@^1.3.7
        seeed-studio/Seeed Arduino LSM6DS3@^2.0.4
    
    ; Enable serial monitor at 9600 baud
    monitor_speed = 9600
    
    ; Disable compiler optimizations for debugging (optional)
    build_flags = -O0
    
    ; Ensure correct upload method
    upload_protocol = nrfutil
    
  2. I was able to get the IMU detected by Windows File Manager using the steps below:

    1. Plug the board into my computer
    2. Double-click the reset button
    3. (NOTE): this only worked on my laptop, which a specific port, and with only some cables. IDK why.
  3. To reset the firmware, I followed this link and uploaded the .u2 file to the Xiao sense: XIAO nRF52840 (and Sense) | MicroBlocks Wiki.

  4. Step 3 allows the IMU to be detected again. But uploading any code (such as the blinky example in ArduinoIDE) causes the issue to come back.

  5. (NOTE): This started when I uploaded BLE code using the updated PLIO.

(For anyone else) I decided to update it because I was receiving this error:
.pio\libdeps\xiaoblesense\Seeed Arduino LSM6DS3\LSM6DS3.cpp: In member function ‘status_t LSM6DS3Core::beginCore()’:
.pio\libdeps\xiaoblesense\Seeed Arduino LSM6DS3\LSM6DS3.cpp:108:17: error: ‘class arduino::MbedSPI’ has no member named ‘setBitOrder’
SPI.setBitOrder(MSBFIRST);
^~~~~~~~~~~
.pio\libdeps\xiaoblesense\Seeed Arduino LSM6DS3\LSM6DS3.cpp: In member function ‘void LSM6DS3::fifoBegin()’:
.pio\libdeps\xiaoblesense\Seeed Arduino LSM6DS3\LSM6DS3.cpp:766:13: warning: unused variable ‘thresholdHByte’ [-Wunused-variable]
uint8_t thresholdHByte = (settings.fifoThreshold & 0x0F00) >> 8;
^~~~~~~~~~~~~~
*** [.pio\build\xiaoblesense\lib1b4\Seeed Arduino LSM6DS3\LSM6DS3.cpp.o] Error 1

This solves the issue: https://github.com/Seeed-Studio/Seeed_Arduino_LSM6DS3/issues/28

Hi there,

So , I see the Arduino BLE is an Older version. Known issues with it on certain BSP so beware. :+1: good on you for sticking with it..

GL :santa_claus: PJ :v: