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

nrf52 Battery Measurement 4*AA batteries

Hello,

I need to measure battery on my nrf52 beacon. My input voltage is 4*AA batteries(each 1.2V so in total 4.8V). The schematic provided by the hardware developer is as follows

Now I read few posts about battery measurements and looks like I need to add some additional hardware? Kindly tell me whether its possible to measure voltage using existing hardware, if so please describe, the calculations or at least point me to the right direction.

Thank You

Regards

Bilal

Parents Reply Children
  • So I took reference voltage , vdd/4 (my vdd is 3.3V), gain = 1/5 and resolution 12 bit, here is my initialization for it

    err_code = nrf_drv_saadc_init(nullptr,saadc_callback);
    APP_ERROR_CHECK(err_code);
    nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN7);
    channel_config.gain = NRF_SAADC_GAIN1_5;
    channel_config.reference = NRF_SAADC_REFERENCE_VDD4;

    err_code = nrf_drv_saadc_channel_init(0, &channel_config);
    APP_ERROR_CHECK(err_code);
    nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_12BIT);
    err_code = nrf_drv_saadc_buffer_convert(m_buffer, 1);

    while I convert it as follows:

    constexpr double REF_VOLTAGE_IN_VOLTS = 0.825; // Maximum Internal Reference Voltage
    constexpr double VOLTAGE_DIVIDER_IN_VOLTS = 0.2; //Internal voltage divider
    constexpr double ADC_RESOLUTION_12BIT = 4095;
    #define RESULT_IN_VOLTS(ADC_VALUE) (ADC_VALUE*REF_VOLTAGE_IN_VOLTS)/(VOLTAGE_DIVIDER_IN_VOLTS*ADC_RESOLUTION_12BIT)

    The measurement from my voltage divider is feeded to AIN7 but it measures 0.9V on the battery while my input is 5.2V and 0.7V when my input 4.5V. Can you suggest what am doing wrong in here

  • Hi,

    Can you try using the internal reference instead of VDD? I would expect that to be more stable, even though you must have a regulator in your power supply circuit since the battery power is too high.

    Then there is also the point that depending on your circuitry and battery etc the voltage will probably drop a bit when you do ADC sampling compared to when you measure on the battery when the nRF does not draw much current (if that is what you are ding). Therefor you should have a capacitor in the circuit as well, as described here.

    Depending on what I have mentioned above, your result might not be that far from expected.

    The voltage out of the voltage divider in your case is 5.2 V / (470+110)*110 = 0.986 V.

    Then you put that into

    RESULT = [V(P) – V(N) ] * GAIN/REFERENCE * 2^(RESOLUTION - m)

    So for single ended it is:

    RESULT = V * GAIN/REFERENCE * 2^RESOLUTION

    And get something like:

    RESULT = 0.986 * 1 / 5 * 2^12 = 808.

    Is that roughly the sample value you get?

    Then you swap around so that you solve for V you get back the same result:

    V = RESULT / (GAIN/REFERENCE * 2^RESOLUTION)

    V = 808/(1 / 5 * 2^12) = 0.986

    Then you have to remember that this is the voltage you measure over R2 in the voltage divider, so you have to account for that as well, and find that the voltage you measure is 5.2 V in this example.

  • Yes, my measurements are close to what you said, now we need to map our voltage divider measurement to input voltage?

Related