VBAT LEVEL for RAK3172

I have one, it’s an HT7333, I didn’t show it on the shemat, that’s it.

I set the flag to (VDD) for the VDD pin of rack2172

I run a quick test with the equipment I have
WisBlock Base Board RAK19007
WisBlock Core module RAK3382

This provides a regulated 3.3V for the RAK3372 (RAK3172) and has the same resistor network on Ain0.
I am getting a 0.2V difference between voltage measured at the battery connector and the reported voltage over LoRaWAN packet. My application is using api.system.bat.read().

I am not sure why it doesn’t work on your setup.

Thank you for your help, if your assembly is equivalent to mine, then this is probably due to an ancillary problem, I will redo a PCB with the minimum of components and see if it still works, thank you.

Here is my solution:
image

V_BAT connected to PB4/ADC 2

Source code:

uint16_t getBatteryLevel() 
{
  //430 =3v, 395= 2.15v
  int16_t percent = map(analogRead(adcBatteryPin),  430, 395, 100, 0);

  if(percent < 0)
  {
    return 0;
  }

  if(percent > 100)
  {
   return 100;
  }

  return percent;
}

hello ,I will modify the wiring of the rak for testing yours, but a strange thing happened twice, I wanted to measure the consumption in standby mode, it completely blocks the rak, I don’t dare try it anymore, because it has to be reflashed with Cubeprogrammer??? I mean measuring manually with a multimeter.

Hello! Can you please help with one issue with ultra-low ADC resolution on voltage?

I have following schematic:

V_BAT connected to PB4.

When I measure ADC on PB4 with 3.4v and 2.9v the difference only 11 points:

It looks like something wrong, but I am not sure what exactly.

Appreciate any ideas. Thank you!

Your problem might be related to a (strange) limitation of the ADC input of the STM32WLE5 MCU itself.
The analog inputs work only reliable with a external input impedance of 50kOhm:

STM32WLE5 datasheet:

RUI3 function api.system.bat.get() is applying some calculations to get the 1M/1.5M resistor divider to work but limits the accuracy.

Thank you! I checked RAK3172 with TP index and it looks like the MAX/MIN (435/418) values a little be better, but I am not sure.

Whether the RAK3172 is a (P), (I), (TI) or (TP) version shouldn’t matter.
The difference between (x) and (Tx) versions is only that the (x) is using a crystal and the (Tx) versions are using a TCXO instead.

IF you are using the RAK3172 and you need to measure the battery you need to add a low drop voltage regulator, because by default the RAK3172 doesn’t allow to have an internal constant vref, this module uses the VDD as reference, so if the battery level drops the vref changes, so you can´t estimate the correct battery level.
My solution was to use a LDO regulator and a controlled voltage divider to save current consumption, something like next image.

hello, thank you for the help, so you use a mosfet for the separation? what is its specification and value?

Hello, I´m using the Mosfe to improve the power consumption, this mosfet acts as a switch to isolate the voltage divider in order im not using always, just when the RAK wakes up, I´m using the DMP3099 this refference has a low Vgth, just apropiate to be triggered with GPIO from RAK 3172

hello, sorry for the late response, I will test it next week when I get home, thank you for the information.

I know this thread is old but a voltage divider (I built the 1M/1.5M one as depicted above) works for me on a rak3172 stamp module. I use the map function as someone above said as well, and it just works with analogRead. No voltage regulator needed. No api.system.bat call (doesn’t work for me, always the same value).

Just in case someone discovers this thread and thinks he needs a voltage regulator. With a divider it’s not necessary.

1 Like