BLE Battery Service Example¶
The BLE Battery Service Example demonstrates how to use the Battery Service module. This module implements the Battery Service with the Battery Level characteristic.
The application includes the two services:
- Battery Service
- Device Information Service
When the application starts, the BSP is initialized. Next, a timer for generating battery measurements is started. When notification of Battery Level characteristic is enabled, the Battery Level is notified each time the Battery Level measurement timer expires.
Before you start building, remember to set up the nRF5 SDK development environment first. See Setup the nRF5 SDK for details.
Building the example¶
You can find the source code and the project file of the example in the following folder: examples/nrf5-sdk/ble_app_bas.
Open terminal and navigate to the directory with the example Makefile:
make merge to build the application and merge with the Softdevice:
Programming the firmware¶
If compiled successfully, the firmware is located in
ble_app_bas/armgcc/_build with the name
Connect the debugger USB port to your PC using the provided USB-C Cable. A disk drive called M2-DOCK will be automatically detected by the computer.
Run the following command in
ble_app_bas/armgcc to program the board:
See Programming section for details about how to program the nRF52840 M.2 Module.
You can test the application with the LightBlue app by performing the following steps:
Download the LightBlue app from App Store or Google Play.
Connect a 3.7V Li-Po battery with 2-pin JST-PH 2.0 connector to the Battery connector.
Connect to the device from LightBlue (the device is advertising as nRF52840 M.2).
Observe that Battery Service and Device Information are shown in the connected device.
Tap Battery Level and listen for notifications. The Battery Level notifications are received.
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: