Hello,
I’m trying to switch off the red battery light when the battery is disconnected, while enable it when the battery is reconnected.
Based on documentation and post I’ve find on the subject, I written the following code:
FuelGauge fuel;
boolean isBattery;
void setup() {
fuel.reset(); //added in a second phase to trouble shoot the problem to no avail
Serial.println(fuel.getVCell());
if ( fuel.getVCell() < 1 ) {
_pmic.disableCharging();
isBattery = false;
Serial.println( "Battery not installed: DISABLE BATTERY CHARGING" );
} else {
_pmic.enableCharging();
isBattery = true;
Serial.println( "Battery installed: ENABLED BATTERY CHARGING" );
}
}
void loop() {
//I've added a timer to 1s (not shown here)
fuel.reset(); // added at a later stage to try to solve the voltage issue.
Serial.println(fuel.getVCell());
if ( fuel.getVCell() < 1 && isBattery) {
_pmic.disableCharging();
isBattery = false;
Serial.println( "Battery removed: DISABLE BATTERY CHARGING" );
} else if ( fuel.getVCell() > 1 && !isBattery ){
_pmic.enableCharging();
isBattery = true;
Serial.println( "Battery installed: ENABLE BATTERY CHARGING" );
}
}
When I run this code, I always get 0.00 voltage whenever the battery is connected or not. What could be wrong in my code? I’m running firmware 0.6.0-rc.1.