Hi everyone,
I am having problems reading the battery level using the SAADC. The main problem is that the reading is not consistent from when the device is booting to once the device has boot completely an is stable/IDLE.
During the initialization the reading is around 4.2 V for battery totally charged while later it drops to around 3.6 V.
Hardware Configuration:
To read the battery, I have a voltage divider connected to the AIN0 pin for reading the battery voltage. The resistor pulled to ground is 51K ohms while the one pulled to VBAT is 100k ohms. I had checked the voltage across both resistor with a multimeter and it stays consistent the whole time. So, it seems like a software problem.
Software Configuration:
For reading the battery, I am using a simple blocking approach using the SAADC in single mode in the pin AIN0. The SAADC is configured as:
// SAADC configuration nrf_drv_saadc_config_t saadc_config; saadc_config.low_power_mode = true; saadc_config.resolution = SAADC_RESOLUTION; saadc_config.oversample = SAADC_OVERSAMPLE; // SAADC CHANNEL configuration channel_config.gain = NRF_SAADC_GAIN1_6; channel_config.reference = NRF_SAADC_REFERENCE_INTERNAL; channel_config.acq_time = NRF_SAADC_ACQTIME_20US; channel_config.burst = SAADC_BURST_MODE; err_code = nrf_drv_saadc_channel_init(0, &channel_config); // Init SAADC channel
and then use the simple function `nrf_drv_saadc_sample_convert()` to read the battery, like:
nrf_saadc_value_t value; ret_code_t err_code; saadc_init(false); err_code = nrf_drv_saadc_sample_convert(0, &value); APP_ERROR_CHECK(err_code); saadc_uninit();
The oversampling and burst are currently disable, but I had tried those to with same result. I had also tried calibrate before the reading, use a buffer to get an average value or increase the acquisition time but none of those helped at all. I still got the same results.
One thing worthy to mention is that, the battery read changes after the LCD is turned on and the system uses SPI for communicate with the LCD hardware. This makes me wonder if there is a possibility that the SPI could cause problems with the SAADC somehow.
Regards,
spw.