RepositoryCCACanada
h2zero

h2zero/n-able-Arduino

An arduino core for ARM based BLE devices supported by the NimBLE stack.

60stars
17forks
25issues
4views

n-able Arduino core

An Arduino Core for ARM based BLE boards supported by the NimBLE stack.

If you are interested in assisting the development of this project please submit issues and PR's. Or become a collaborator!

Features

  • Fully supports the NimBLE-Arduino library on Arm based BLE devices (only Nordic mcu's for now)
  • No softdevice, NimBLE provides a complete BLE stack.
  • Contains a subset of the EEPROM library to support basic config storage in flash.
  • Supports printf and Serial.printf
  • Uses/includes FreeRTOS.
  • Designed to maximize battery life using tickless idle. This allows the MCU to sleep any time delay is called.
  • Custom configuration of FreeRTOS and NimBLE compile options supported by providing a build_opt.h file in your sketch.

Why?

I wanted to have a consistent BLE API on all of the devices I work with. NimBLE is the best choice for this as it is the most feature complete and fully open source library available for Arduino.

BLE

This Arduino Core does not contain any BLE functionality. It has been designed to support using the NimBLE-Arduino library for BLE operation. Note: Only the release version 1.4.0 and above of NimBLE-Arduino supports Arm devices.

Supported boards

nRF52840

nRF52833

nRF52832

nRF52810

nRF51

Installing

Platformio

  1. Install PlatformIO
  2. Create PlatformIO project and configure a platform option in platformio.ini file:
[env]
platform = https://github.com/h2zero/platform-n-able.git@^1.0.0
framework = arduino
lib_deps = h2zero/NimBLE-Arduino@^1.4.0
board = ...
...

Arduino Board Manager

  1. Download and install the Arduino IDE (At least v1.6.12)
  2. Start the Arduino IDE
  3. Go into Preferences
  4. Add https://h2zero.github.io/n-able-Arduino/package_n-able_boards_index.json as an "Additional Board Manager URL"
  5. Open the Boards Manager from the Tools -> Board menu and install "Arm BLE Boards"
  6. Select your board from the Tools -> Board menu

From git (for core development)

  1. Follow steps from Board Manager section above
  2. cd <SKETCHBOOK>, where <SKETCHBOOK> is your Arduino Sketch folder:
  • OS X: ~/Documents/Arduino
  • Linux: ~/Arduino
  • Windows: ~/Documents/Arduino
  1. Create a folder named hardware, if it does not exist, and change directories to it
  2. Clone this repo: git clone https://github.com/h2zero/n-able-Arduino.git
  3. Restart the Arduino IDE

Install NimBLE-Arduino

  1. Arduino Library manager: Go to sketch -> Include Library -> Manage Libraries, search for NimBLE and install version 1.4.0 or greater.
  2. Add #include "NimBLEDevice.h" at the beginning of your sketch.

Flashing your device

  1. Select your board from the Tools -> Board menu
  2. Select any options you want
  3. Select a programmer (J-Link, ST-Link V2, CMSIS-DAP, Black Magic Probe, adafruit-nrfutil or nrfutil) from the Tools -> "Programmer: " menu
  4. Connect your programmer to the device and click Upload
  1. Make sure you have Segger J-Link installed on your system.
  2. (For Windows) add the JLink.exe path to your environment variables.
  3. Select J-Link as the firmware uploader in the tools menu.

Uploading via adafruit-nrfutil (for Adafruit bootloader devices only)

  1. Install adafruit-nrfutil if not already installed pip install adafruit-nrfutil
  2. Select adafruit-nrfutil as the firmware uploader in the tools menu.

Uploading via (Nordic) nrfutil (for Nordic bootloader devices only)

  1. Install nrfutil if not already installed pip install nrfutil
  2. Select nrfutil as the firmware uploader in the tools menu.

Configuration (optional)

You can change the configuration for many settings by creating a build_opt.h file in your sketch folder. In here you can set compile time definitions for settings that will be included directly on the command line. For example: '-DCONFIG_MAIN_TASK_STACK_SIZE=512' This will set the main task stack size to 512 words (2048 bytes).

Configuration option list

  • CONFIG_MAIN_TASK_STACK_SIZE - sets the size in 32bit words of the main loop task.
  • CONFIG_RTOS_TICK_RATE_HZ - set the tick rate for FreeRTOS (default 1024).
  • CONFIG_RTOS_MAX_PRIORITIES - set the maximum priority level for FreeRTOS tasks.
  • CONFIG_RTOS_MIN_TASK_STACK_SIZE - set the minimum task stack size.
  • CONFIG_RTOS_TIMER_QUEUE_LENGTH - set the queue size for the FreeRTOS timers.
  • CONFIG_RTOS_TIMER_STACK_DEPTH - set the timer task stack size in 32bit words.
  • CONFIG_RTOS_THREAD_LOCAL_STORAGE_POINTERS - set the number of thread local storage pointers for FreeRTOS tasks (default 1, used for printf buffer management).
  • CONFIG_WDT_TIMEOUT_SECONDS - set the number of seconds before the watchdog times out (0 = disable watchdog, default = 0).
  • CONFIG_PRINTF_BUFFER_SIZE - set the size of the buffer used for printf and Serial.printf (default 128 bytes, set to 1 for no buffer).
  • CONFIG_PRINTF_BUFFER_INDEX - set the FreeRTOS storage pointer index used for managing the printf buffer (default 0).
  • USB_CDC_DEFAULT_SERIAL - For devices with USB CDC support, this enables the USB CDC serial by default, set to 0 to disable (default 1), Serial will be redirected to the UART if this is disabled.
  • Nimble configuration options can also be included, the list of those can be found here
  • Other compiler options or definitions for other libraries can also be specified.

API

There are a few useful functions available to help with your project.

RTOS class functions

  • uint32_t RTOS.getMainTaskHwm(); - Returns the high water mark of the Main task stack in 32bit words.
  • uint32_t RTOS.getIsrStackHwm(); - Returns the high water mark of the ISR stack in 32bit words.
  • uint32_t RTOS.getIdleTaskHwm(); - Returns the high water mark of the Idle task stack in 32bit words.
  • uint32_t RTOS.getTimerTaskHwm() - Returns the high water mark of the Timer task stack in 32bit words.
  • uint32_t RTOS.getBleHostTaskHwm(); - Returns the high water mark of the NimBLE Host task stack in 32bit words.
  • uint32_t RTOS.getBleLLTaskHwm() - Returns the high water mark of the NimBLE Link Layer task stack in 32bit words.
  • uint32_t RTOS.getFreeHeap(); - Returns the currently free heap size in bytes.

General system functions

  • uint32_t getResetReason(); - Returns the reset reason for the last boot.
  • void systemPowerOff(); - Shuts down the MCU.
  • void systemRestart(); - Reboot.
  • For USB supported boards, additional USB functions beyond CDC are available by including the TinyUSB library (built in) by adding the following to your sketch:
#include "Adafruit_TinyUSB.h"

Bootloader

There are currently three bootloader options available for use with this core, the Adafruit BLE bootloader, the Adafruit serial bootloader, or no bootloader.

On boards that come with Adafruit bootloaders it will be the default option and will work out of the box.

Other boards can optionally use the Adafruit bootloader by selecting it from the tools menu and clicking Burn Bootloader (requires a compatible SWD programmer such as the Segger J-Link). This will install the Adafruit bootloader on the device, which will allow you to upload firmware over USB using the adafruit-nrfutil uploader option. If you do not want to use the Adafruit bootloader you can select "No Bootloader" from the tools menu and click Burn Bootloader to erase any existing bootloader on the device.

Important notes

  • The last four pages of flash, before the bootloader (if applicable) are reserved for user storage and bond information storage (2 pages each).
  • Careful attention should be paid to selecting the correct bootloader (tools->Bootloader Type) for your build (if applicable) to ensure the correct linkage.

Credits

This core is based on Arduino-nRF5 by Sandeep Mistry, which is based on the Arduino SAMD Core. With some code from Adafruit_nRF52_Arduino

The following libraries are used:

Similar Projects

Discover other similar projects and AI models.

RepositoryC
h2zero/NimBLE-Arduino

A fork of the NimBLE library structured for compilation with Arduino, for use with ESP32, nRF5x.

1.2k
Nov 27, 2026
RepositoryC
tsl0922/EPD-nRF5

E-paper display firmware for Nordic nRF51/nRF52, with support for image transfer, OTA update.

618
Sep 8, 2026
RepositoryC
InfiniTimeOrg/InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS

3.5k
Nov 24, 2026
RepositoryC
sqfmi/Watchy

Watchy - An Open Source E-Ink Smartwatch

2.9k
Aug 19, 2025
RepositoryC
GhostESP-Revival/GhostESP

The open-source wireless research platform for ESP32.

1.2k
Nov 16, 2026
RepositoryC
tinygo-org/bluetooth

Cross-platform Bluetooth API for Go and TinyGo. Supports Linux, macOS, Windows, WebAssembly, & bare metal using Nordic SoftDevice or HCI (ESP32/Pico-W/etc)

1.0k
Dec 1, 2026
RepositoryC
fbiego/esp32-c3-mini

LVGL UI for ESP32 C3 mini 240*240 board (ESP32-2424S012)

559
Oct 8, 2026
RepositoryC
redbear/nRF5x

nRF51822 and nRF52832 based baords, e.g. BLE Nano, RBL_nRF51822, Nano 2 and Blend 2

192
Nov 15, 2018
RepositoryC
decrazyo/unifying

FOSS re-implementation of the Logitech Unifying protocol

123
Nov 26, 2024