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.