RAK3172 ADC Functionality


We wish to measure battery voltage with ADC.

We are using RAK3172 module + RUI3

Here we try to set internal reference voltage of ADC to the 1.8V or 2.4V by using functions



When we read ADC mode back with function “udrv_adc_get_mode()” it gives UDRV_ADC_MODE_3_3 (ie. Mode value - 1)
It seems that internal voltage is not getting set to the desired voltage level.

Please guide us to resolve this issue.


Hi @UsernameMadhavML ,

The internal reference of RAK3172 can’t be changed an fixed to VDD level. We have to update the docs to indicate this as added note :spiral_notepad: :pushpin:

Hi @carlrowan

Thank you for update.
I think it should get reflected in library files also. So that it will not be selected by the developer if RAK3172 board is selected.

Hi @carlrowan,

So if you want to accurately measure the analog value you are better of using an external Vref connected on a ADC channel and then compensate for the unknown Vin ??

Hi @carlrowan , I have also a question about the ADC. iam trying to read the battery voltage. Iam using a voltage divider of 1M and 1.5M ohm as recommended. So my max voltage on the ADC pin is 2.29V when iam using a 3.6V battery. But when i change the value on the ADC pin the analog value is not changing. Iam using ADC2 → WB-A1 for reading. When i turn the power supply voltage to 2.3V its still the same value as before… Really strange. Do you have some suggestion what the problem would be?


void setup() {


void loop() {
float raw_adc = analogRead(WB_A1);
 Serial.printf("Voltage value = %f V\r\n", 3.0*(((float)raw_adc)/4096)*(5.0f)/(3.0f));

Kind regards Marnick

@NAS1975 ,

Having external voltage rerference for the module will not the improve accuracy on the built-in ADC. If can have fixed VDD level on RAK3172, you can use its ADC (vdd as reference) else it might be worth considering to check for an externa one or use RAK4631 (with programmable ADC reference.)

Hi @Marnick The Vref of RAK3172 is based on Vdd, if you lower your vdd, it will just follow the raw reading.

Your signal of interest must be lower than Vdd. If the signal you want to check is 2.29V, your vdd (for rak3172) must be above it.

Hello @carlrowan ,
My vdd is a battery (3.6V max). So when the battery is getting empty the Vref is getting lower. That means that i cant make a battery measurement?

Yes. That is correct. We are looking if there are ways for us to implement internal voltage monitoring.

For now, to do monitoring continuously the battery voltage even if it drops 3.3v, you might need extra hardware.

  1. Use boost converter to maintain 3.3V.
  2. Use ultra low power ADC or comparator that can indicate low battery threshold voltage.