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

how to measure the coin cell battey voltage in real

Hello Everyone,

I am trying to measure the (3v)battery voltage by having proximity example as reference but intially it is showing 100percent later it is going to 13(percent) voltage approxmiatelry (after 120seconds) i dont understand why it is happening like this can anyone suggest me some possible ways to measure out by using multimeter how much voltage available on ADC pin ? so that i can able to make some idea about the battery level measurement§?

  • The proximity example in SDK 11 uses a app timer to measure the battery level. The first measurement is not performed until the first time it times out, and the timeout is 120 second (thus measurements are performed every 120 seconds). You can modify BATTERY_LEVEL_MEAS_INTERVAL and set it to a lower value in order to measure more often. You can also do the first measurement at startup, rather than waiting the full measurement interval before doing the first measurement.

    Also, if you are not using the DK you may have to change the value of DIODE_FWD_VOLT_DROP_MILLIVOLTS to reflect your hardware.

  • Thank you so much for your reply am using the NRF51DK(SDK10) providing 3V supply from the battery to the DK my aim is to see the exact battery value in the MCP but am not getting alteast around somewhere 90 percent but is is dropped to 12 percent so i configured the ADC something like this

    nrf_adc_config_t adc_config = NRF_ADC_CONFIG_DEFAULT;

    adc_config.scaling = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD;
    nrf_adc_configure(&adc_config); 
    
    nrf_adc_int_enable(ADC_INTENSET_END_Msk);
    
    NVIC_EnableIRQ(ADC_IRQn);
    NVIC_SetPriority(ADC_IRQn, 3);
    
    nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_2);
    

    after doing this i checked the voltage present on the ADC PIN number(p0.02i by using mulimeter it is showing 0 only alwyas can you suggest what mistake in my approach how can i checkt he voltage on the analo pin?and alos i changed the BATTERY_LEVEL_MEAS_INTERVAL from 120000 ticks(120seconds) to 1200 ticks but still seems it take quite long for the first time out is ther any other modifications do i have to do for changing the first time out?

  • Why don't you use the configuration function, adc_configure(), from the example? You do not need to select a analog input pin and connect it to the battery, as the chip can connect VDD to the ADC input internally, as is done in the example.

    How are you measuring the voltage on the ADC input pin with a multimeter? If you use a analog input pin you have to connect it to the battery, and then measure directly. However you cannot measure the voltage after scaling using a multimeter, as that is done internally in the chip.

  • is there is any possible way to debug and see the voltage availble on the ADC pin i have tried with the printf statements and see the output value of (adc_sample) it is showing 11758 i dont understand what is the value of that ? how can i make sure that the real time battery vtolage my aim is to send the battery percent value to the MCP terminla but it reamins always 100 and i try to modify the nattery measinterval value to 1200 and i have checked it is showing 10percent in the Mcp So its hardly cofusing for me

  • To interpret the value of the ADC sample you have to take into account how the ADC is configured with regard to prescaling (voltage divider) and resolution. This post has a good description of how it works.

    The proximity example use the ADC with a 10 bit resolution, so 1024 is the sample value for the highest voltage. In order to calculate the battery voltage the following macro is used:

    #define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)\
            ((((ADC_VALUE) * ADC_REF_VBG_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_INPUT_PRESCALER)
    

    Then the example use the battery_level_in_percent() function to convert it to a percentage (not that this is not a percentage of the voltage relative to 3 V, but a estimate of battery life).

Related