Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Battery Service for nRF52832

Hi Everyone,

I'm currently working on a project which uses the nRF52832 and nRF52DK.

In this project, I have to broadcast my battery level when the development kit is connected to nRF Connect App.

From my understanding, I could easily add the ble_bas.c and ble_bas.h into my programming and use ADC to read the battery voltage and convert them into percentage. (similar to the example: ble_app_proximity.)

In this scenario, does it mean that the battery level value shown on the Connect App is equivalent to the voltage of the battery (example : 100% - 3V, 75% - 2.5V)? Or it actually refers to the "State of Charge" of the battery? 

If it refers to "state of Charge" of the battery, how does the ble_bas.c file determine the battery's total capacity and remaining capacity.

Apologies if my question sounds a little silly as i'm very new to Nordic development kit. 

Thanks!

Parents
  • Hello,

    Apologies if my question sounds a little silly as i'm very new to Nordic development kit. 

    No need to apologize at all, we were all new to Nordic development at some point! :) 
    Please do not hesitate to ask if you should encounter any issues or questions along the way.

    You can indeed see the Battery Service demonstrated in the Proximity example from the SDK.
    The measurements are not based on state of charge, but rather on the battery's voltage as measured by the SAADC peripheral. The voltage is then matched to the discharge curve of the specific CR2032 battery used for our DK's.
    Therefore, if your application will be using another battery than the one supplied with the DK you will have to implement your own voltage-to-percentage mapping function for it to be accurate.

    Best regards,
    Karl

  • Hi Karl,

    thank you for the fast reply and encouragement.

    The measurements are not based on state of charge, but rather on the battery's voltage as measured by the SAADC peripheral. The voltage is then matched to the discharge curve of the specific CR2032 battery used for our DK's.

    Will these measurements provide an precise reading (E.g. adc value 1000 = 100%, 999 = 99%) or sample/range reading (E.g. adc value from 900 to 1000 = 100%, 750 to 899 = 80%, etc etc). Is there any blog post regarding the 'voltage matching up to discharge curve' so that i can understand further.

    Therefore, if your application will be using another battery than the one supplied with the DK you will have to implement your own voltage-to-percentage mapping function for it to be accurate.

    How can I implement my own voltage-to-percentage mapping function?

    Thank you for your time and help!

Reply
  • Hi Karl,

    thank you for the fast reply and encouragement.

    The measurements are not based on state of charge, but rather on the battery's voltage as measured by the SAADC peripheral. The voltage is then matched to the discharge curve of the specific CR2032 battery used for our DK's.

    Will these measurements provide an precise reading (E.g. adc value 1000 = 100%, 999 = 99%) or sample/range reading (E.g. adc value from 900 to 1000 = 100%, 750 to 899 = 80%, etc etc). Is there any blog post regarding the 'voltage matching up to discharge curve' so that i can understand further.

    Therefore, if your application will be using another battery than the one supplied with the DK you will have to implement your own voltage-to-percentage mapping function for it to be accurate.

    How can I implement my own voltage-to-percentage mapping function?

    Thank you for your time and help!

Children
  • Zachary16 said:
    Thank you for your time and help!

    No problem at all, I am happy to help! :) 

    Zachary16 said:
    Will these measurements provide an precise reading (E.g. adc value 1000 = 100%, 999 = 99%) or sample/range reading (E.g. adc value from 900 to 1000 = 100%, 750 to 899 = 80%, etc etc). Is there any blog post regarding the 'voltage matching up to discharge curve' so that i can understand further.

    In the CR2032 battery's case the discharge curve is non-linear, so the mapping function is broken down into 4 linear pieces that approximate the charge level based on the voltage.
    If you look into app_util.h you can see the battery_level_in_percent function and how it is implemented.
    There is no separate blogpost for this, but if you find the datasheet for the specific battery you are working with it will usually list its discharge curve as one of the first things.
    From there, you can make a function that approximates the discharge curve sufficiently, so that you may get accurate estimates for the remaining battery charge.
    Please keep in mind that this is estimates for the remining state of charge, so it is not as accurate as if you had actually measured the state of charge. This would however require a separate component, such as a Fuel Gauge, to keep track of the spent charge. The estimation of remining charge is good enough for most BLE application, but if your application has specific, rigid requirements for the accuracy of the battery level you might have to include a fuel gauge.

    If you are working with a Li-Po battery it might be helpful to have a look at our Li-Po measurement guide, and to be aware of our newest Power Management IC.

    Best regards,
    Karl

  • Thank you so much Karl. Really appreciate your time and effort to explain everything in detail for me!

  • It is no problem at all, I am happy to help you! :) 

    Please do not hesitate to ask if you should encounter any other issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related