Battery Status
Answer
8/22/18 9:33 AM

Hello ,

I am Using Uart to tranmitt all sensor Values continously, and want to have the Status of Battery in percent . is it any example how I could get  this Status in Percent by each transmission?

Kind regards,

Bush

 

 

 

0 (0 Votes)
RE: Battery Status
Answer
8/22/18 3:06 PM as a reply to Bush Ngouateu Donfack.
Hello Bush,

First, I would like to welcome you to the XDK community.

The functionality to monitor the battery voltage and to return it into percentage would need to be implemented on your own. For that, you can use the BatteryMonitor.h interface, which provides the measurement of the analog battery voltage in millivolts.

You can find the interface by navigating through the following folderpath:

SDK > xdk110 > Common > include

For receiving the value in percentage, you could then divide the battery voltage through 4300.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Battery Status
Answer
8/31/18 7:16 AM as a reply to Franjo Stjepandic.

Hi Franjo,

I have the following code, which is providing me with a battery of 0 constantly:

uint32_t mvoltage = 0, battery = 0;
BatteryMonitor_MeasureSignal(mvoltage);
// Max = 4.3V, Min = 3.3V
battery = (mvoltage - 3300.0) / 1000.0 * 100.0;

 

Ignoring the issues of likely going above 100% or below 0%, why would it just have a value of 0? I have of course included '#include "BatteryMonitor.h"'.

In the previous version of the workbench I was using the function 'BSP_Charger_BQ2407X_MeasureSignal(0, &mvoltage);', which is also providing me with a value of 0.

0 (0 Votes)
RE: Battery Status
Answer
8/31/18 1:06 PM as a reply to Kallum Burgin.
Hello Kallum,

Unfortunately, the outline of your source code is missing the initilization for the battery monitor interface.

The first thing I have to ask is, if you called the BatteryMonitor_Init() function, before you attempted to use the battery monitor interface?

This function initializes and enables the battery monitor interface to be able to measure the battery voltage.

Without the initialization, the actual measurement function will not work and only provide zeros as output.

In addition to the measuring function BatteryMonitor_MeasureSignal() , you need pass the variable mvoltage for storing the battery voltage as reference (pointer). Otherwise only a copy of the variable mvoltage inside the function is used, but not returned and deleted after the function finishes.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Battery Status
Answer
9/3/18 12:27 PM as a reply to Franjo Stjepandic.
Ah that's great. Silly pointer mistake. Battery percent now reporting correctly. Thank you.
0 (0 Votes)
RE: Battery Status
Answer
9/3/18 2:55 PM as a reply to Kallum Burgin.
Hello Kallum,

I am always glad to help and to hear that you were able to solve the issue.

Please feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Battery Status
Answer
6/24/19 8:52 AM as a reply to Franjo Stjepandic.

Hi Kallum,

I am in front of the same issue but I don´t get it running.

What did you change in detail?

0 (0 Votes)