[RAK3172-RUI3] Get VRef

How to get VRef like in HAL ST Low Level Programming?

I’m trying to measure battery voltage, implementing a voltage divider into ADC1, but I don’t know how to get the voltage reference provided by STM32WL55.

Welcome to RAK forum @rodrigobueno ,

In RUI3 API, there is no way for you to read the configured voltage reference. But you can set it using AnalogReference API. However, take note that there is a current bug in STM32WL RUI3 firmware so that analog reference stays at VDD as default.

Thank you @carlrowan ! My goal is to measure the battery of my device. You know another way to do it, with low power consumption?

If you can have a fix 3.3V then you can use it as voltage reference. What is your battery?

I’ll explain my current case, allow me to extend a little:

  1. I have a project in production, using ESP(32/8266) as Endnode communicating via ESPNOW with another ESP Gateway;
  2. In ESP it is possible to make a voltage divider and use a method from the library itself to measure the battery.
  3. I am using 3.7v 18650 battery as ESP uses more power.

Therefore, I am wanting to migrate this project to use the RAK3172 with LORA WAN protocol, as the battery consumption is much lower, and the signal range is greater, but there were some items to be resolved, such as:

  1. Measure the battery charge (initially 18650 of 3.7v) but being able to change the battery type to one with less charge. The data send pulses are every 3 minutes, and we expect a lifespan of over a year (ESP on the battery shown above lasts around 1 year);
  2. Get a unique identifier via RUI3, I saw that in low level programming of STM32WL55 via STM32 CUBE IDE is possible.

I believe that by solving these 2 items above, I will be able to migrate my project to RAK3172.

PS: I was able to successfully develop my project in low-level programming using the STM32 CUBE IDE, but the consumption in StandBy is running around 300uA, and I couldn’t get it down to around 1 to 3uA as I can in RUI3, is there any tip?

Hi @rodrigobueno ,

RAK3172 is a good choice in moving to LoRaWAN.

To answer your questions:

  1. If you use a Li-Po then a buck converter, you can easily have a fix 3.3V vdd level for your RAK3172. You just need to have a voltage divider to do the battery voltage measurement.
  2. RUI3 doesn’t provide the DEVEUI. It is on the sticker on the device itself. It is not hardcode in the device.
  3. Regarding sleep current of the STM32CubeIDE LoRaWAN SW Package, we cannot provide much support because it is a code developed by STM32 itself for the STM32WL SoC. Few things you can check is (a) are there other peripherals connected to the RAk3172? even debuggers like STLINK or JLINK? (b) are all peripherals already in sleep mode? (c) are there any pins active? Actually, there are lots of source where the extra few uA can come from - depending on the circuit or the code itself.

Thank you @carlrowan !

Before I close this topic, one last question:

Can I change the TX Power in LORAWAN (dB)?

Hi @carlrowan , this bug is in the backlog for resolution? “However, take note that there is a current bug in STM32WL RUI3 firmware so that analog reference stays at VDD as default.”

Hi @rodrigobueno ,

I just got an update on this issue and found out that configurable ADC reference is only available on RAK4630 RUI3 (based on NRF52840). The RAK3172 (based on STM32WL) has no configurable ADC reference. Sad to say but VDD will be the only ADC Vref for RAK3172.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.