Can't find Adafruit_nRF52_Arduino library on Platformio

Hi I’m using nRF52840 DK and trying to run a sample that uses the bluefruit.h header from the Adafruit_nRF52_Arduino library. I followed this youtube tutorial and was able to program the BLE sample on an Arduino IDE.
Here’s my platformio.ini-


platform = nordicnrf52

board = nrf52840_dk

framework = arduino

monitor_speed = 115200

build_flags = -DNRF52_S140 ; softdevice version

lib_deps =

    ; adafruit/Adafruit MAX31865 library @ ^1.3.0

    ; adafruit/Adafruit BusIO@^1.11.2

As you can see, I’m trying to include the library via the Github url but apparently that’s not working. I could try to download the library and include in the /lib folder but then I’ll need to find and include dependencies upon dependencies. My final goal is to use platformio IDE to write a BLE peripheral that advertises some analog values read from the pin on a nRF52840 DK. Your help is appreciated!!!


That’s because it’s not a library its an entire Arduino core. You can’t just lib_deps that. The Arduino core to use is already determined by the board = ... in the platformio.ini and the underlying board JSON’s core information. As you can see in platform-nordicnrf52/boards at develop · platformio/platform-nordicnrf52 · GitHub, there is nrf52840_dk and nrf52840_dk_adafruit for the Adafruit core. Just use

platform = nordicnrf52
board = nrf52840_dk_adafruit
framework = arduino
monitor_speed = 115200

Thanks @maxgerhardt you the champ. I can build the arduino examples that include bluefruit library now and I can flash onto the nRF52840 dk via the j-link usb.

However, the application is not running and I can’t detect it on BLE tools, either the nRF connect app or the Bluefruit connect app. I’m running this “custom_HRM” example.

This is the successful log from building and flashing.

> Executing task in folder nrf_adafruit_feather_dev: C:\Users\Tranks\.platformio\penv\Scripts\platformio.exe run --target upload --environment nrf52840_dk_adafruit <

Processing nrf52840_dk_adafruit (platform: nordicnrf52; board: nrf52840_dk_adafruit; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Nordic nRF52 (9.2.0) > Nordic nRF52840-DK (Adafruit BSP)
HARDWARE: NRF52840 64MHz, 243KB RAM, 796KB Flash
DEBUG: Current (jlink) On-board (jlink) External (blackmagic, cmsis-dap, stlink)
 - framework-arduinoadafruitnrf52 1.10200.0 (1.2.0)
 - framework-cmsis 2.50700.210515 (5.7.0)
 - tool-adafruit-nrfutil 1.503.0 (5.3)
 - tool-bossac-nordicnrf52 1.10901.201022 (1.9.1)
 - tool-jlink 1.75001.0 (7.50.1)
 - tool-openocd 2.1100.211028 (11.0)
 - tool-sreccat 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 13 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit Bluefruit nRF52 Libraries>
|   |-- <Adafruit nRFCrypto>
|   |   |-- <Adafruit TinyUSB Library>
|   |-- <Adafruit TinyUSB Library>
|   |-- <Adafruit Little File System Libraries> 0.11.0
|   |   |-- <Adafruit TinyUSB Library>
|   |-- <Adafruit Internal File System on Bluefruit nRF52> 0.11.0
|   |   |-- <Adafruit Little File System Libraries> 0.11.0
|   |   |   |-- <Adafruit TinyUSB Library>
Building in release mode
Checking size .pio\build\nrf52840_dk_adafruit\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.7% (used 14156 bytes from 248832 bytes)
Flash: [=         ]  14.5% (used 117904 bytes from 815104 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, nrfjprog, stlink
CURRENT: upload_protocol = jlink
Uploading .pio\build\nrf52840_dk_adafruit\firmware_signature.bin
SEGGER J-Link Commander V7.50a (Compiled Jul  8 2021 18:18:11)
DLL version V7.50a, compiled Jul  8 2021 18:16:52

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-nRF5340-NordicSemi compiled Jul  2 2021 10:55:25
Hardware version: V1.00
S/N: 1050239339
Target connection not established yet but required for command.
Device "NRF52840_XXAA" selected.

Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
DPIDR: 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
PC = FFFFFFFE, CycleCnt = 00000008
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000
SP(R13)= FFFFFFD8, MSP= FFFFFFD8, PSP= 00000000, R14(LR) = FFFFFFF9
XPSR = 01000003: APSR = nzcvq, EPSR = 01000000, IPSR = 003 (HardFault)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= 00000000
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= 00000000
FPSCR= 00000000

Downloading file [.pio\build\nrf52840_dk_adafruit\firmware.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (118784 bytes)
J-Link: Flash download: Total: 3.725s (Prepare: 0.071s, Compare: 0.012s, Erase: 2.322s, Program & Verify: 1.276s, Restore: 0.042s)
J-Link: Flash download: Program & Verify speed: 91 KiB/s

Downloading file [.pio\build\nrf52840_dk_adafruit\firmware_signature.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (4096 bytes)
J-Link: Flash download: Total: 0.165s (Prepare: 0.046s, Compare: 0.002s, Erase: 0.083s, Program & Verify: 0.010s, Restore: 0.022s)
J-Link: Flash download: Program & Verify speed: 399 KiB/s

Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.

Script processing completed.

========================================================================= [SUCCESS] Took 8.20 seconds =========================================================================
Terminal will be reused by tasks, press any key to close it.

What’s the output on the serial monitior?

@maxgerhardt sorry for the late reply as my focus shifted. It appears to be working now as expected and i can see the serial logs after including #include "Adafruit_TinyUSB.h". However, currently I’m having to change between the two usb ports on the dk, one(j-link) for flashing and the other for reading serial. Is this expected or how can i just read the serial through the j-link as well?

I also don’t understand why there are two COMs appear when I connect j-link usb to pc. I currently use the upload button provided by platformio, so I don’t have to know which COM port but I would like to specify the COM port for upload_port in platformio.ini.


JLink uploads need not to specify the JLink’s COM port. In fact a JLink’s COM ports are completely optional and can be switched off using their JLink configuration software (there’s a tool for that in the official Jlink download package). That’s because the upload uses the USB device for the JLink’s JTAG interface, not a COM port. Hence no need to set upload_port.

I would also suggest you run that JLink configuration tool to see the COM configuration for it. Some JLinks are capable of opening two COM ports, maybe that’s the case with yours.

1 Like

Hi everyone, new to PIO here, migrating from Arduino IDE.
I’m using Seeed Studio Xiao nRF52840, and was able to use bluefruit.h on Arduino IDE. Now I’m using @maxgerhardt platform like this:

platform =
board = xiaoble

But this, I’m guessing doesn’t use the Adafruit core… Should I be able to use board = nrf52840_dk_adafruit when it’s not an Adafruit board ?

Look at There’s board = xiaoble_adafruit.

1 Like

How did I miss this :person_facepalming:
Thanks a lot @maxgerhardt for such a quick reply!