FuelGauge Not Accurate AT ALL

Here’s the code ; it ALWAYS generates THIS output:

batinfo Voltage 0.00 State 256.00

(This Electron has a LiPo battery ONLY on board at the moment - I’m trying to see how long it’ll last)

float vcell = fuel.getVCell();
float soc = fuel.getSoC();
char batinfo[64];
sprintf(batinfo, "Voltage %02.2f State %03.2f", vcell, fuel.getSoC() );
Particle.publish("batinfo", batinfo );
String output = "{\"batt-value\": \"" + String(vcell) + "\"}";
Particle.publish("fuel-level1", output);

For me it works just as expected

fuel-level1{"batt-value": "3.843700"} May 5th at 7:24:23 pm ScruffyG3
{"data":"{\"batt-value\": \"3.843700\"}","ttl":"60","published_at":"2016-05-05T17:24:23.746Z","coreid":"<deviceID>","name":"fuel-level1"}
batinfoVoltage 3.84 State 74.88 May 5th at 7:24:23 pm ScruffyG3
{"data":"Voltage 3.84 State 74.88","ttl":"60","published_at":"2016-05-05T17:24:23.536Z","coreid":"<deviceID>","name":"batinfo"}

That’s my complete code for this

FuelGauge fuel;

void setup()
{
}

void loop()
{
  delay(2000);

  float vcell = fuel.getVCell();
  float soc = fuel.getSoC();
  char batinfo[64];
  sprintf(batinfo, "Voltage %02.2f State %03.2f", vcell, fuel.getSoC() );
  Particle.publish("batinfo", batinfo );
  String output = "{\"batt-value\": \"" + String(vcell) + "\"}";
  Particle.publish("fuel-level1", output);
}
2 Likes