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

What is the pin for the battery voltage on nRF52pca1040 DK?

Hello,

I would like to instruct my application to read the battery voltage on my nRF52pca1040 DK, I am intending to do so through the SADC.

I will feed the board with the battery that is on its botton side, so I was wondering what is the PIN to read the battery in such a case, looking into pca1040.h doesn't say that pin.

Thanks in advance,

Regards before after

Parents
  • Hi,

    You can configure the SAADC channel with VDD as input. You don’t have to use a GPIO for this.

    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);
    

    The SAADC result can then be converted into volts, and further calculated into percentage based on a linearized version of the battery's discharge curve. Take look at how this is done in the saadc_event_handler() function in the e.g. the ble_app_proximty example in the SDK.

    Code snippet from the example:

    batt_lvl_in_milli_volts = ADC_RESULT_IN_MILLI_VOLTS(adc_result) +
                              DIODE_FWD_VOLT_DROP_MILLIVOLTS;
    percentage_batt_lvl = battery_level_in_percent(batt_lvl_in_milli_volts);
    
  • If you are referring to the saadc_config symbol not found, it could be that is just goes out of scope. It's a chance you could "fix it" by configuring the optimization level in Project Properties(there is "Code Generation Options" under which there is "Optimisation Level"). But if you are not getting any compiler or linking errors, then there's nothing to fix.

    I also see that you have removed the RETURN_IF_ERROR statements. I recommend checking all error codes with APP_ERROR_CHECK() in order to detect bugs and errors in your code.

    APP_ERROR_CHECK(err_code);
    
Reply
  • If you are referring to the saadc_config symbol not found, it could be that is just goes out of scope. It's a chance you could "fix it" by configuring the optimization level in Project Properties(there is "Code Generation Options" under which there is "Optimisation Level"). But if you are not getting any compiler or linking errors, then there's nothing to fix.

    I also see that you have removed the RETURN_IF_ERROR statements. I recommend checking all error codes with APP_ERROR_CHECK() in order to detect bugs and errors in your code.

    APP_ERROR_CHECK(err_code);
    
Children
No Data
Related