Regarding FuelGauge update I was facing similar issue, VCell read was always resulting the same value.
For me it seems that something is not ok when waking up Fuel Gauge.
So I went into MAX1704x datasheet and found:
The A/D calculates the average cell voltage for a period of 125ms after IC POR and then for a period of 500ms for every cycle afterwards. The VCELL register requires 500ms to update after exiting Sleep mode. The result is placed in the VCELL register at the end of each conversion period.
My code was already waiting more than 500ms after waking up before VCELL read so I went into conclusion that VCELL register is not being updated after system waking up at all.
So I went into different approach where I issue a POR to the Fuel Gauge and then read values.
Take a look at simple code snippet:
fuel.reset(); //reset the Fuel Gauge chip
delay(500); // ToDo test 125ms from datasheet
batteryVCELL = fuel.getVCell(); //read VCELL into variable for later publish
And it solved the problem with Fuel Gauge after waking up from sleep mode.
So this shed some light on a problem and I went further with an idea that maybe just this gauge.wakeup() within Sleep procedures is not working because it was too early for an I2C interface or MAX chip (1ms). (didn’t analyse error handling)
And I did tests with:
//before there is a code for like 200-300ms after wake up from sleep.
fuel.wakeup(); //wake up the Fuel Gauge chip
delay(500); // As datasheet says
batteryVCELL = fuel.getVCell(); //publish at later stages
batterySOC = fuel.getSoC(); //publish at later stages
This also solves the problem.
I could recommend for engineers to take a look at I2C traces with some external logic analyser close to waking up procedure. Eventually add public method to read Fuel Gauge register to determine its state.
Also taking a look into:
Holding both SDA and SCL logic-low forces the MAX17043/MAX17044 into Sleep mode. While in Sleep mode, all IC operations are halted and power drain of the IC is greatly reduced. After exiting Sleep mode, fuel-gauge operation continues from the point it was halted. SDA and SCL must be held low for at least 2.5s to guarantee transition into Sleep mode. Afterwards, a rising edge on either SDA or SCL immediately transitions the IC out of Sleep mode.Alternatively, Sleep mode can be entered by setting the SLEEP bit in the CONFIG register to logic 1 through I2C communication. If the SLEEP bit is set to logic 1, the only way to exit Sleep mode is to write SLEEP to logic 0 or power-on reset the IC.
It may seem depending on I2C line state in a NRF’s sleep mode it is not needed to power down Fuel Gauge by its config bits during system’s Sleep() procedure.