NimBLE
nimble_1_9_0_tagFeatures
-
Full Bluetooth 5.4 specification compliance for both Host and Controller layers.
-
Support for Data Length Extension (DLE) enabling up to 251-byte packet sizes.
-
Concurrent operation of Broadcaster, Observer, Peripheral, and Central roles.
-
Scalable connection management supporting up to 32 simultaneous connections.
-
Security Manager Protocol (SMP) with support for Legacy and Secure Connections (SC).
-
Support for Advertising Extensions (AE) for increased data capacity in advertisements.
-
Support for Periodic Advertising for synchronized data broadcasting.
-
Physical layer support for 2M PHY and Coded PHY (Long Range) communications.
-
Integrated Bluetooth Mesh subsystem for many-to-many device networking.
-
NimBLE Porting Layer (NPL) for integration with various RTOS environments like FreeRTOS and RIOT.
-
Flexible Host-Controller Interface (HCI) implementation for standard interfacing.
-
Multiple transport options including UART, emSPI, and shared RAM for combined builds.
-
Comprehensive implementation of L2CAP, ATT, GAP, and GATT protocols.
-
Low-level radio drivers for Nordic nRF51, nRF52, nRF5340, and Renesas DA1469x.
-
Support for Nordic UART / Serial Port Emulation service (bleuart).
-
Privacy features including support for Resolvable Private Addresses (RPA).
Architecture
Apache NimBLE is architected as a modular Bluetooth Low Energy stack, strictly separating the Controller (Link Layer) from the Host layer. This separation allows for flexible deployments where the Host and Controller can run on the same MCU (using shared RAM transport) or on separate processors (using UART or SPI via HCI). The Controller manages real-time radio timing, hardware-specific transceiver drivers, and the Link Layer state machine, while the Host implements high-level protocols including L2CAP, the Attribute Protocol (ATT), and the Security Manager (SM).
A critical architectural component is the NimBLE Porting Layer (NPL). The NPL provides a set of OS-agnostic primitives for tasks, mutexes, semaphores, and callouts. This abstraction layer is what enables NimBLE to be highly portable, allowing it to function as the default BLE stack for Apache Mynewt while also being integrated into external ecosystems like the Espressif ESP-IDF, RIOT OS, and the Open IOT SDK.
Core Components
- Controller: Includes the Link Layer (LL) and hardware-specific drivers for Nordic and Renesas radios.
- Host: Implements GAP, GATT, ATT, L2CAP, and the Security Manager.
- Mesh: A complete Bluetooth Mesh implementation integrated into the Host subsystem.
- Transport: Provides HCI implementations over various physical and virtual interfaces.
- NPL: The abstraction layer facilitating portability across different operating systems.
Use Cases
This library is ideal for:
- Industrial Mesh Networking: Deploying large-scale, many-to-many device networks for industrial automation or smart lighting using the integrated Mesh subsystem.
- High-Density Sensor Hubs: Creating central devices that must maintain up to 32 simultaneous connections with peripheral sensors.
- Long-Range IoT: Utilizing Coded PHY support to extend the range of BLE communications in outdoor or obstructed environments.
- Secure Wearables: Implementing secure bonding and encrypted communications for consumer electronics using LE Secure Connections.
- Cross-Platform Development: Projects that require a consistent BLE API across different hardware architectures and RTOS environments.
- HCI Controller Emulation: Turning a supported SoC into a dedicated BLE controller for use with a Linux-based host running BlueZ.
Getting Started
To get started with NimBLE, it is recommended to use the Newt build tool provided by the Apache Mynewt project. Developers can begin by exploring the apps/ directory within the repository, which contains several reference applications. For example, bleprph provides a template for a basic peripheral, while btshell offers a command-line interface to exercise the stack’s full functionality.
For integration into non-Mynewt projects, developers should refer to the porting/ directory, which contains NPL implementations for various environments. Detailed documentation, including API references for GAP, GATT, and Mesh, is available through the Apache Mynewt documentation portal. Community support is primarily handled via the Apache Mynewt developer mailing list and Slack channel.
Related Projects (19)
ESP32-S3 USB to BLE Keyboard Bridge
This project transforms standard USB keyboards into wireless Bluetooth Low Energy (BLE) devices using the ESP32-S3's native USB-OTG hardware. It features multi-device switching for up to three paired hosts and utilizes the NimBLE stack for low-latency HID report forwarding.
Apache Mynewt Sensor Network for STM32 Blue Pill
An IoT sensor network application for STM32 Blue Pill using Apache Mynewt RTOS. It supports multiple operational modes including standalone WiFi nodes, low-power nRF24L01 sensor nodes, and collector gateways. The project features internal temperature monitoring, WiFi geolocation, and integration with thethings.io via CoAP and CBOR.
ZJ-BLE: RT-Thread and NimBLE for Nordic nRF52
A comprehensive BLE 5.0 development platform for Nordic nRF52 series microcontrollers, integrating the RT-Thread RTOS with the Apache NimBLE protocol stack. It provides a fully open-source alternative to proprietary BLE stacks, utilizing Nordic SDK 15.0 drivers and supporting the Keil MDK development environment.
ZJ-TEK RT-Thread NimBLE LittlevGL Nordic Project
An integrated application project for Nordic nRF52840 and nRF52832 platforms featuring the RT-Thread RTOS, NimBLE BLE 5.0 stack, and LittlevGL (LVGL) graphics library. It demonstrates a complete embedded system solution including heart rate monitoring (HRM) and graphical user interface components.
ZSWatch
An open-source smartwatch project built on the Zephyr RTOS and powered by the nRF5340 dual-core BLE SoC. It features a high-resolution round touch display, a comprehensive suite of Bosch environmental and motion sensors, and seamless smartphone integration via Gadgetbridge or iOS.
NimBLE-Arduino
A lightweight Bluetooth Low Energy (BLE) library for Arduino based on the NimBLE stack. It provides a resource-efficient alternative to the standard Bluedroid-based BLE library for ESP32 and Nordic nRF5 series microcontrollers, significantly reducing flash and RAM usage.
NimBLE HID Keyboard and Mouse Example for ESP32
A Bluetooth Low Energy (BLE) HID keyboard and mouse implementation for the ESP32 using the Apache Mynewt NimBLE stack. It demonstrates GATT server creation, HID report mapping, and GPIO button integration for sending keyboard scan codes and mouse movements.
n-able Arduino Core
An Arduino Core for ARM-based BLE microcontrollers, specifically targeting the Nordic nRF51 and nRF52 series. It features a complete open-source BLE stack via NimBLE, integrated FreeRTOS with tickless idle for low-power operation, and support for custom compile-time configurations.
Nesper: Nim Wrappers for ESP-IDF
Nesper provides Nim language wrappers for the ESP-IDF SDK, enabling developers to program ESP32 microcontrollers using Nim. It leverages Nim's ARC garbage collector and provides high-level interfaces for FreeRTOS, LwIP, and various ESP32 hardware peripherals.
InfiniTime
An open-source firmware for the PineTime smartwatch based on the nRF52832 microcontroller. It utilizes FreeRTOS for task management, LVGL for the user interface, and NimBLE for Bluetooth Low Energy connectivity. The project provides a complete suite of applications, watch faces, and OTA update capabilities for the PineTime hardware.
Bayesian Disease Mapping Code Examples
A comprehensive collection of code examples for fitting hierarchical Bayesian models to small area health data. The repository covers multiple statistical frameworks including Win/OpenBUGS, Nimble, CARBayes, and INLA for spatial and spatio-temporal applications.
Develop your own Bluetooth Low Energy Applications
A comprehensive collection of Bluetooth Low Energy (BLE) application examples for Raspberry Pi, ESP32, and nRF52. It demonstrates BLE functionality including advertisements, connections, security, and power optimization using Python (Bleak), Arduino (NimBLE), and the Zephyr RTOS.
DIY Smart Coffee and Espresso Scale
A high-precision smart coffee scale project featuring ESP32 firmware written in Rust and a Svelte-based Progressive Web App. It utilizes an HX711 load cell with Kalman filtering for real-time weight tracking and communicates via Bluetooth Low Energy to provide live extraction curves and timer functionality.
ESP32 BLE OTA Arduino
A project enabling Over-the-Air (OTA) firmware updates for ESP32 microcontrollers using Bluetooth Low Energy (BLE). It supports both the standard ESP32 BLE library and the more memory-efficient NimBLE-Arduino, providing Python scripts and an Android app for the update process.