@All,
Thanks to Chris from the support team, I think we have a fix for this issue. Here is what happened in case this helps someone else.
-
I have been playing with settings for Solar Power and the Boron device. I had set too high a charge current for my 3.5W / 6V solar panel and the current theory that this caused the PMIC to go into the state where battery was reported as “-1” as you see above.
-
To bring the PMIC back to its factory defaults, Chris provided the following command. This command, and the correct setPowerConfiguration API commands resolved this issue.
System.setPowerConfiguration(SystemPowerConfiguration()); // To restore the default configuration
- With this reset command and the correct settings for solar power, the code was rewritten. Please see amended code below which works:
// Program Variables
char batteryString[64] = "Null";
// setup() runs once, when the device is first turned on.
void setup() {
System.setPowerConfiguration(SystemPowerConfiguration()); // To restore the default configuration
takeMeasurement(); // Test the battery state of charge
Particle.publish("State",batteryString,PRIVATE);
SystemPowerConfiguration conf;
conf.powerSourceMaxCurrent(550) // Set maximum current the power source can provide (applies only when powered through VIN)
.powerSourceMinVoltage(5080) // Set minimum voltage the power source can provide (applies only when powered through VIN)
.batteryChargeCurrent(512) // Set battery charge current
.batteryChargeVoltage(4210) // Set battery termination voltage
.feature(SystemPowerFeature::USE_VIN_SETTINGS_WITH_USB_HOST); // For the cases where the device is powered through VIN
// but the USB cable is connected to a USB host, this feature flag
// enforces the voltage/current limits specified in the configuration
// (where by default the device would be thinking that it's powered by the USB Host)
int res = System.setPowerConfiguration(conf); // returns SYSTEM_ERROR_NONE (0) in case of success
}
void loop() {
}
// Utility Functions Area
void takeMeasurement() {
const char* batteryContext[7] ={"Unknown","Not Charging","Charging","Charged","Discharging","Fault","Diconnected"};
// Battery conect information - https://docs.particle.io/reference/device-os/firmware/boron/#batterystate-
snprintf(batteryString, sizeof(batteryString),"Battery SOC: %.1f and State: %s", System.batteryCharge(), batteryContext[System.batteryState()]);
}
Now, I have a way to reset devices which are mis-behaving. Next step is to test with sleep and deploy to a solar powered device to confirm this fix.
Thanks, Chip