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

why proximity example shows always 100 battery

Hello,

I am trying to make battery service in my application so i refer the proximity example in SDK 9 and i flashed into my kit it showing always 100percent in the nordic app what needs to be done inorder t monitor the exact battery voltage interms of percentage in nordiac app ? i am new to this field so any sugeestion will be useful for me

Thank you

Parents
  • Look at the code. It probably says like this:

    static void adc_configure(void)
    {
        ...
        nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
        ...
    }
    

    Change adc input pin to NRF_ADC_CONFIG_INPUT_0 ~ NRF_ADC_CONFIG_INPUT_7 properly and test again.

Reply
  • Look at the code. It probably says like this:

    static void adc_configure(void)
    {
        ...
        nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
        ...
    }
    

    Change adc input pin to NRF_ADC_CONFIG_INPUT_0 ~ NRF_ADC_CONFIG_INPUT_7 properly and test again.

Children
  • i did not see any lines like that in the ADC configure function

    /**@brief Function for configuring ADC to do battery level conversion.
     */
    static void adc_configure(void)
    {
        uint32_t err_code;
        nrf_adc_config_t adc_config = NRF_ADC_CONFIG_DEFAULT;
    
        // Configure ADC
        adc_config.reference  = NRF_ADC_CONFIG_REF_VBG;
        adc_config.resolution = NRF_ADC_CONFIG_RES_8BIT;
        adc_config.scaling    = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
        nrf_adc_configure(&adc_config);
    
        // Enable ADC interrupt
        nrf_adc_int_enable(ADC_INTENSET_END_Msk);
        err_code = sd_nvic_ClearPendingIRQ(ADC_IRQn);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_nvic_EnableIRQ(ADC_IRQn);
        APP_ERROR_CHECK(err_code);
    }
    
  • can you tell me do i have add any information in the ADC configure function?

  • Sorry for the confusion, it was my fault for using the example of SDK 10.0.0.

    You should use void nrf_adc_input_select(nrf_adc_config_input_t input) before nrf_adc_start().

    For example:

    static void battery_level_meas_timeout_handler(void * p_context)
    {
        UNUSED_PARAMETER(p_context);
        nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_0);
        nrf_adc_start();
    }
    

    Happy coding... :)

  • Thanks for your reply but still in the nordic app am getting only 100 percent response and i have connected and tested with battery and usb power supply to see the measurementS am getting 100 only

  • I see. Look at adc_config.reference = NRF_ADC_CONFIG_REF_VBG; In this case, adc measurement range is from 0 to 3.6V. If battery voltage is exceeds 3.6V you have to use voltage divider with resistors.