This blog is to mention how to add the battery service and read the VDD through SAADC module. Also, the most important is to optimize the current consumption.

SAADC (Successive approximation analog-to-digital converter)

The SAADC is a differential successive approximation register (SAR) analog-to-digital converter. It supports
up to eight external analog input channels, depending on package variant. It is an analog module. For example, it is the most common used to detect the battery level.

For example, if we need to use SAADC module, it needs to run the HCLK either NRF52832 or NRF52840.

nRF52832 Product Specification

nRF52840 Product Specification

Battery detection on the VDD

By select the SAADC to use the VDD pin as below,

In order to save the current consumption by using the SAADC, the SAADC can be only active when it is running for battery detection.

For example, it creates the app_timer for battery every 120 seconds.

#define BATTERY_LEVEL_MEAS_INTERVAL     APP_TIMER_TICKS(120000)                 /**< Battery level measurement interval (ticks). This value corresponds to 120 seconds. */

On every battery handler timeout,

It tries to initialize the SAADC module.

After received the NRF_DRV_SAADC_EVT_DONE, the SAADC would be uninitialized.

Given advertising interval = 1000ms, VDD = 3 V with DCDC enable, we run the firmware at the NRF52840 DK board.

By using the init / uninit approach, the SAADC is only switched on every 120 seconds.

Keep to run the SAADC all the time,

By comparing two difference configurations as above, you can find that around 480 uA keeps to run as the background.

The source code of this example can be found at https://github.com/jimmywong2003/nrf5-ble-bidirection-throughput-test/tree/master/ble_app_its_bas .

Welcome to give any comment on this blog. Please remember to give a like if you think it is good.

Thanks for your interests on my blog. Since 2019, I have created this blog and shared the idea how to do some funny stuffs. I am very pleasure that I get quite a lot of positive feedback. I really hope that this blog helps your own embedded solution development. May I get support from you to keep it in order to maintain the wordpress host service? Your appreciation would be very helpful.


https://jimmywongiot.com/2021/05/26/asking-for-support/