RAK3172 module and Vbat

Dear Rak team,
im going to use RAK3172 module in own design and i should measure the voltage/battery.
I will use 2 batteries AA in series for supply.
My questions is - is internally Vbat connected to VDD? so i measure voltage without any external voltage divider.

2nd question:
which pins i could use for DAC signal generation

3th question:
which pins i could use for PWM generation

Thanks a lot!

I have the same question.

I see have an example code read Vbat, but I don’t know where is pin Vbat.

Hi @Vladimir @Nam

  1. ADC for vbat is based on the battery connection of the WisBlock Base board. If you use the RAK3172 Evaluation Board, AT+BAT command will give the actual voltage of the battery attached on the evaluation board. If you are making your own board and want to use the vbat API, ADC_VBAT is connected to PB3/PIN_A0 and this is the voltage divider (based on base board).

image

  1. RUI3 doesn’t support DAC out on any pin.
  2. You can use IO pins of RAK3172 to have PWM output.

Note that putting R3/R4 voltage divider across a 3V power rail (2x AA cells) results in a constant current drain of 1.2uA in addition to the MCU STOP current of around 2uA.

If you’re using the same 3V Vbatt for the MCU, there’s no problem with exceeding the rail, so you might consider removing the divider and measuring the voltage directly.

If you’re using Vdd as the ADC reference (as the MCU does) then you’re in a predicament, right? You’ll always read full-scale on the ADC because the reference is the same as the value you’re measuring. Never fear, ST thought ahead for this: there’s an internal calibrated reference in the MCU around 1.2V IIRC. So you read the calibrated reference and do some math (explained in the STM32WLxx documentation) to figure out what the Vdd rail is.

This means you don’t need any pin to measure Vbatt, you just measure the internal reference and calculate Vdd from that. Note that this calibration is required anyway when reading external voltages. This also eliminates inaccuracy due to component tolerance of R3/R4.

I don’t know if RUI does that or supports doing this, but it’s easy to do with STM32Cube.

Warning: I just thought this up before having the first cup of coffee for the day. I might have missed a detail (but pretty sure I didn’t).

1 Like

Thanks for sharing your insights @danak6jq . Those are very helpful to the community. I am discussing now with the R&D team the possibility of using the internal VBAT pin of STM32WL to measure VDD level. No promises but I will give update/s whenever there is/are good news in this front.

1 Like

Hello, I have same problem and without the knowledge of the circuit of the module it is impossible to do it right. Do you have update? Thanks

All issues have been clarified, what is your problem?

Thanks for reply. I would like to know whether we can use VBAT to measure VDD battery level. You wrote that you will give us update

No promises but I will give update/s whenever there is/are good news in this front.

On an RAK WisBlock Base Board, the battery VBAT is regulated through an LDO to produce VDD and usually exceeds the VDD value. That’s why a voltage divider is required. If you’re using an RAK3172 in an application where you’re only using a 3V lithium cell, you dispense with the LDO and don’t need the voltage divider. because VBAT == VDD.

So the only time you can use VDD to measure the battery voltage accurately is when it is directly connected to the battery.