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

nRF52840 Lithium Ion battery monitor

Hi Devzone!

I'm trying to monitor the battery level of Lithium Ion battery.

I'm using SAADC to check the voltage of 3.7v 3500mAh Lithium Ion battery.

The battery is connected to some module and this module has the pin which I can use for checking the voltage of the battery. (This pin has no problem, I checked it with digital meter.)

So, I wired that pin to AIN1(which is P0.03) and flame sensor to AIN0 (which is P0.02). 

saadc_init is like below.

void saadc_init(void)
{
    ret_code_t err_code;
    
    nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
    saadc_config.resolution = NRF_SAADC_RESOLUTION_14BIT;

    ch_config_flame.gain = NRF_SAADC_GAIN1_4;
    ch_config_flame.reference = NRF_SAADC_REFERENCE_INTERNAL;
    ch_config_bat.gain = NRF_SAADC_GAIN1_4;
    ch_config_bat.reference = NRF_SAADC_REFERENCE_VDD4;

    err_code = nrf_drv_saadc_init(&saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(FLAME_CHANNEL, &ch_config_flame);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(BAT_CHANNEL, &ch_config_bat);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
}

But, there is some problem.

If I disconnect the battery from the DK, then the value of the flame sensor is correct. It varies from 0 to 16,384 by the lightness of fire.

But, If I connect the battery, then both values become strange.

I can see the value of the battery which is about 11632(I don't know this is correct value) and the value of flame sensor is fixed with  the range of 11520 ~ 11710.

The value of the flame sensor wasn't changed in spite of the varying lightness of fire.

DK is powered by PC USB cable which is 5V 1A,

1. What would be the problem?

2. And I saw that many people use the voltage divider to monitor the battery. I wonder why they should use voltage divider.

Best regards,

Baek

Related