Battery Fuel Gauge readings (data) return a negative number

Hello,

I have a basic project with the Boron that sends the results of the fuel gauge to the events console.

The battery is fully charged and connected to the Boron which powers up and receives the flash. (battery level also checked with a volt-meter)

I keep getting “-1” as the result of the readings (including the system version). The summary code is as follows:

FuelGauge fuel; // declare the library

float voltage = fuel.getVCell();
float percent = fuel.getSoC();
float normal = fuel.getNormalizedSoC();
int ver = fuel.getVersion();
int val = 19; //used as a test number to send

Particle.publish(“TEST volt”, String(voltage) , PRIVATE);
delay (3000);
Particle.publish(“TEST percent”, String(percent) , PRIVATE);
delay (3000);
Particle.publish(“TEST normal”, String(normal) , PRIVATE);
delay(3000);
Particle.publish(“TEST version”, String(ver) , PRIVATE);
delay(3000);
Particle.publish(“TEST value”, String(val) , PRIVATE);

All of the battery results return: -1.000000
The version test returns: -160
The test number of 19 returns: 19

In short, the battery functions are returning a negative number including the fuel version. The test number of 19 returns as a positive number.

I did read in the “fuel gauge documentation” that the functions return -1.0 if the fuel gauge cannot be read.

Any help or comments are appreciated.

Thank you

The values in the fuel gauge are often not available immediately after boot until the MAX17043 adjusts its calibration. If you wait longer, it should return a valid value. Because of this, it’s usually better to do it from your loop, and when the value is < 0, skip publishing and try again later. Maybe wait 10 seconds.

WORKS !!!

It just needed some time to calibrate

Thank you…

1 Like

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