Fuel Gauge issue

Our Electrons sleep most of the time with the modem still active. They wake up for approx 5 seconds to do some house keeping then go back to sleep for about 10 minutes. What we’ve noticed during this cycle is that the reported battery voltage level doesn’t change. Resetting the Electron results in the fuel gauge reporting a much lower voltage than before the reset.

I have tried the following calls after the CPU has woken up.

  FuelGauge fuelGauge;
...
...
  fuelGauge.sleep();
  delay(1000);
  fuelGauge.wakeup();
  delay(1000);
  fuelGauge.reset();
  delay(1000);
  fuelGauge.quickStart();

None of the calls result in a correct reading from the fuel gauge. The fuel gauge reports VCell value of 5 after a reset. I never see this default value when running the commands above.

Is there a way to completely reset the fuel gauge without resetting the Electron?

ping @rickkas7

What sleep mode are you using, and what system firmware version?

I’m using SLEEP_NETWORK_STANDBY with 0.8.0rc10.

And:

  • stop mode sleep (pin + time) where execution continues after the sleep command or
  • SLEEP_MODE_DEEP where the processor is reset?

The exact command I’m using to sleep is

sleepResult = System.sleep({RI_UC, WKP}, RISING, 600, SLEEP_NETWORK_STANDBY);

I’m waking from different events - a button, accelerometer and modem data.

If I deep sleep and reset, the battery levels are updated and report correctly.

OK, I’ll have to do some experimenting then. It’s not a known problem but something like that could happen if the I2C interface is not reinitialized properly after stop mode sleep.

Great. thanks.

Hi Rickkas.

Any luck reproducing this issue? For me it’s completely reproducible. If I sleep with the modem on, the fuel gauge no longer works when I wake up.

Let me know if you need any more info.

Have you tried throwing in a fuelgauge.reset() or a fuelgauge.quickStart() ?

@HEng - Yes, I’ve tried both together and separately and neither fixes the issue.

I wasn’t able to reproduce this problem. Here’s the event log:

You can see the SoC and voltage going down through the whole log. The upper and middle sections are after a sleep. The bottom section is after reboot.

I tested using an Electron 3G U260 and 0.8.0-rc.11. Here’s the code:

#include "Particle.h"

SerialLogHandler logHandler;

const unsigned long SLEEP_TIME_SEC = 30; // 30 seconds
const unsigned long WAKE_TIME_MS = 5 * 60 * 1000; // 5 minutes
const unsigned long PUBLISH_TIME_MS = 30 * 1000; // 30 seconds
const int WAKE_PIN = D2;

unsigned long lastWakeTimeMs = 0;
unsigned long lastPublishMs = 0;

void setup() {
	Serial.begin();
	pinMode(WAKE_PIN, INPUT_PULLUP);
}

void loop() {

	if (millis() - lastWakeTimeMs >= WAKE_TIME_MS) {
		lastWakeTimeMs = millis();

		if (Particle.connected()) {
			Particle.publish("electronTest", "about to sleep", PRIVATE);
		}
		Log.info("about to sleep");

		System.sleep({RI_UC, WAKE_PIN}, FALLING, SLEEP_TIME_SEC, SLEEP_NETWORK_STANDBY);

		Log.info("wake");
	}
	if (millis() - lastPublishMs >= PUBLISH_TIME_MS) {
		lastPublishMs = millis();

		FuelGauge fuel;
		char buf[256];
		snprintf(buf, sizeof(buf), "SoC=%d VCell=%.03f %s", (int)fuel.getSoC(), (float)fuel.getVCell(), Time.timeStr().c_str());
		if (Particle.connected()) {
			Particle.publish("electronTest", buf, PRIVATE);
		}
		Log.info(buf);
	}
}

I left it running and also tried resetting. The fuel gauge still seems to be working in my test case.

1 Like

I have a 2/3G electron doing same, after waking from sleep fuel gauge “sometimes” gives 5.1 & 255

running 1.0.1