This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Battery Service Good Practice

I am adding a Battery Service and am searching for advice on good practice. Can you advise?

In the SDK examples, many include the battery service but only ble_app_proximity makes real battery measurements (others simulate the battery voltage). If I understand this example, it starts a timer to perform regular battery measurements if and when the Battery Service notifications are enabled. The measurements are then given to ble_bas_battery_level_update()

Do I understand that the device will then send notifications to the Central device, containing the battery level? If so, does this happen on every connection or only if the level has changed?

What should I do with ble_bas_battery_lvl_on_reconnection_update()? The only code example I see with this is for a device operating as a Central device.

Is it good practise to write an app that reads the battery level characteristic from time to time, or is it better for the app to respond to notifications?

Presumably the battery level characteristic value is the value placed in it by the previous ble_bas_battery_level_update() call - is that right? So it is up to me to call ble_bas_battery_level_update() at some appropriate times, to provide a recent reading?

The timer in ble_app_proximity makes a battery reading every 2 minutes. Is this reasonable? Perhaps every 2 days might be more appropriate for a device with an intended life of years? Is there a battery life implication of the timer period?

Can I rely on the various constants defined in ble_app_proximity? especially DIODE_FWD_VOLT_DROP_MILLIVOLTS  270

Any other tips?

At the hardware level, the Texas Instruments White Paper SWRA349 examines real CR2032 cells and shows big differences between manufacturers. They suggest using large capacitors across the battery to improve life. Does Nordic have similar studies you can share?

Given TI's results that show the battery voltage drops when the processor wakes up - it seems important to understand when the battery measurement is made in ble_app_proximity. Does the conversion take place while the processor is wake or sleeping? If while sleeping then the code might be reporting too optimistically. Have you conducted real-world tests on CR2032 battery life with the ble_app_proximity code?

BTW, if you have not done so, a tutorial on this topic might be an idea.

  • Do I understand that the device will then send notifications to the Central device, containing the battery level? If so, does this happen on every connection or only if the level has changed?

     The example will not send the battery level on every connection interval, that would be a waste of lot of power. The sampling like you said is done based on the configurable timer expiry callback and if the sampled value is different than the one sampled before, then a notification is sent on the next connection interval. If it is same as before, then no notification is sent, as it is assumed that the central will remember the last notification value sent.

    What should I do with ble_bas_battery_lvl_on_reconnection_update()? The only code example I see with this is for a device operating as a Central device.

     This infocenter page says that this function can be used to send an battery level update for the bonded peers. This will be a bit faster first time update than to do the whole procedure again. 

    Can I rely on the various constants defined in ble_app_proximity? especially DIODE_FWD_VOLT_DROP_MILLIVOLTS  270

    These are given as a reference only, these values should be adapted to your application needs. For example look at this thread

    Any other tips?

     All your concerns and questions are well discussed in this forum, I would recommend you to search the forum a bit to find the answers. We at Nordic take great effort to encourage the forum members to discuss things clearly, so that others like you can be benefited with that information. But to find that information, you need to put some effort to search the forum. If you have already done that, It might be tedious if you are a beginner in this forum, but trust me, there is a lot of information you can pull out once you get used to it.

Related