RAK3172EVB Battery

Hi, my experiment about RAK3172 needs to monitor the voltage change of the battery. Do you have any relevant code example to read the battery voltage value periodically?

On the EVB’s you can use the api.system.bat.get() function.


	float battery_reading = 0.0;
	// Add battery voltage
	for (int i = 0; i < 10; i++)
		battery_reading += api.system.bat.get(); // get battery voltage

	battery_reading = battery_reading / 10;

Thank you very much for the code. However, I found that the board connecting to the battery while using USB to connect to the computer charges the battery, which makes it impossible for me to monitor the power consumption of the board. Is there any operation I can do to keep the board on battery power without charging the battery?

The battery is connected to the charger and the charger is connected to USB, so as long as you have USB plugged in it is charging. The only way to use USB and not charge the battery is to cut the 5V in your USB cable.

So there’s no other way to monitor battery drain in real time?

Not over USB output. But you can send the battery voltage over LoRaWAN if you need to monitor it.

I did not find the code example. Could you provide the code for the uplink voltage value, much appreciated.

It is in nearly every example I posted in RUI3-Best-Practice, like here RUI3-RAK13011-Alarm.ino#L241

Thank you so much for your help. I have successfully uplinked the battery voltage data to the gateway.
There is now a new issue where the gateway web page periodically asks me to re-enter my password to log in, causing me to be unable to view any of my previous session logs and unable to download the full session log when I look at the End Device Packet Capture screen again. My gateway is RAK7289 V2. My network server is built-in network server.
Is there any way to keep it logged in, or retrieve the full record of the current session?

Gateways are not my strength, but as far as I know there is no possibility to stay logged in or get historical information.