Hi, I am trying to update the battery level through an example of the HID keyboard of nrf52832.I'm trying to connect 3.3V battery to SAADC AIN0, but as shown in the picture above, the Bluetooth screen keeps saying 0%. Is there a problem with my code? The (+) portion of the battery holder was connected to the board GPIO P0.02.
void saadc_init(void)
{
// SAADC config & calibrate
nrfx_saadc_config_t saadc_config = NRFX_SAADC_DEFAULT_CONFIG;
APP_ERROR_CHECK(nrfx_saadc_init(&saadc_config, saadc_event_handler));
APP_ERROR_CHECK(nrfx_saadc_calibrate_offset());
while (nrfx_saadc_is_busy())
sd_app_evt_wait();
// Channels config
nrf_saadc_channel_config_t battery_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
APP_ERROR_CHECK(nrfx_saadc_channel_init(AIN_BATTERY, &battery_config));
// double buffering
APP_ERROR_CHECK(nrfx_saadc_buffer_convert(buffer[0], INPUTS));
APP_ERROR_CHECK(nrfx_saadc_buffer_convert(buffer[1], INPUTS));
// start SAADC timer
APP_ERROR_CHECK(app_timer_create(&saadc_timer, APP_TIMER_MODE_REPEATED, saadc_timeout_handler));
APP_ERROR_CHECK(app_timer_start(saadc_timer, APP_TIMER_TICKS(TIMER), NULL));
}