Hi,
Does nRF52832 use normal ADC input to detect battery level (ex. AIN0, AIN1...)? or nRF52832 have other method to do this job?
Thank you,
Chianglin
Hi,
Does nRF52832 use normal ADC input to detect battery level (ex. AIN0, AIN1...)? or nRF52832 have other method to do this job?
Thank you,
Chianglin
Hi,
The SAADC on the nRF52 has a direct connection to VDD, so you do not need to use any of the external AIN pins if the battery is directly connected to VDD on the nRF. This is selected by setting the PSEL register to VDD.
Note that measuring the battery voltage like this has a few disadvantages. For instance, the measurement operation will affect the measurement, since it is part of the circuit. You can minimize that effect by following these guidelines, but that requires you do use an external pin (AIN0,...) to do it. Even his approach gives quite course results though, so if you need very accurate battery data, the best option may be to use a dedicated battery gauge IC.
Hi,
The SAADC on the nRF52 has a direct connection to VDD, so you do not need to use any of the external AIN pins if the battery is directly connected to VDD on the nRF. This is selected by setting the PSEL register to VDD.
Note that measuring the battery voltage like this has a few disadvantages. For instance, the measurement operation will affect the measurement, since it is part of the circuit. You can minimize that effect by following these guidelines, but that requires you do use an external pin (AIN0,...) to do it. Even his approach gives quite course results though, so if you need very accurate battery data, the best option may be to use a dedicated battery gauge IC.
Hi,
If I don't need get a accurate battery level, then I can direct connect battery with Vcc pin. Does it correct?
How to set PSEL register?
Would you please give me a sample code?
Thank you
Hi,
Please refer to the Proximity Application example in SDK 15.3. There you can see how the SAADC driver is configured for VDD measurement in line 283-297 of <SDK15.3>\examples\ble_peripheral\ble_app_proximity\main.c. You can refer to the other ADC related code in the file to see a complete example of battery measurement (and even how to use the standard Bluetooth battery service if that is relevant).
Hi,
Thank you for your explain.
VDD is define in "H7" and "A7" pin of nRF52832, it is used as power input of MCU. Does it also can detect battery level?
Thank you,
chianglin said:VDD is define in "H7" and "A7" pin of nRF52832, it is used as power input of MCU. Does it also can detect battery level?
Yes, but only if you have connected VDD directly to the battery, as mentionned in my initial reply.
Hi,
If I want to use two ADC at the same time, one for "ADC Sensor input", and the other one for "Battery level detect". How can I modify following source code?
void saadc_init(void) { ret_code_t err_code; // ---------- Initialize ADC for Pressure-Sensor ---------------- // 變更 ADC 的 bit 數 nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG; saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT; nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0); // 變更 ADC 倍率 & 參考電壓 channel_config.gain = NRF_SAADC_GAIN1_4; channel_config.reference = NRF_SAADC_REFERENCE_VDD4; err_code = nrf_drv_saadc_init(&saadc_config, saadc_Sensor_callback); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_channel_init(0, &channel_config); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER); APP_ERROR_CHECK(err_code); // ---------- Initialize ADC for Battery detect ---------------- #if 1 err_code = nrf_drv_saadc_init(NULL, saadc_Battery_event_handler); APP_ERROR_CHECK(err_code); nrf_saadc_channel_config_t config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD); err_code = nrf_drv_saadc_channel_init(0, &config); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[0], SAADC_SAMPLES_IN_BUFFER); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[1], SAADC_SAMPLES_IN_BUFFER); APP_ERROR_CHECK(err_code); #endif }
System will crash when "second nrf_drv_saadc_init() execute".
Thank you