Skip to content

Commit

Permalink
Add force workingOnExternalPower true unless hasBattery is true Bette…
Browse files Browse the repository at this point in the history
…r. battery/external power detection and handling on different devices #235
  • Loading branch information
melkati committed Jun 20, 2024
1 parent c911541 commit d46a0f8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CO2_Gadget_Battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ void readBatteryVoltage() {

// If battery voltage is more than 6% of the fully charged battery voltage (~4.45V) or if battery voltage is less
// than 1V (no battery connected to sense pin), then assume that the device is working on external power.
const float workingOnExternalPowerThreshold = batteryFullyChargedMillivolts * 1.06 / 1000;
workingOnExternalPower = ((batteryVoltageNow) > workingOnExternalPowerThreshold) || (batteryVoltageNow < 1);
if (!hasBattery) {
workingOnExternalPower = true;
} else {
const float workingOnExternalPowerThreshold = batteryFullyChargedMillivolts * 1.06 / 1000;
workingOnExternalPower = ((batteryVoltageNow) > workingOnExternalPowerThreshold) || (batteryVoltageNow < 1);
}

// workingOnExternalPower = (batteryVoltageNow * 1000 > batteryFullyChargedMillivolts + (batteryFullyChargedMillivolts * 6 / 100)) || (batteryVoltageNow < 1);
// publishMQTTLogData("-->[TFT ] Battery Level: " + String(batteryLevel) + "% Battery voltage: " + String(batteryVoltageNow) + "V External power: " + String(workingOnExternalPower));
Expand Down

0 comments on commit d46a0f8

Please sign in to comment.