porrey / max1704x

Arduino library for the MAX17043/44 and MAX17048/49 LiPo Battery Fuel Gauge.
GNU General Public License v3.0
23 stars 7 forks source link

Battery never shows more than 90% charge #16

Closed cservidoctavian closed 2 years ago

cservidoctavian commented 2 years ago

Hello and thanks for all your work!

I want to open a discussion on lipo battery that I am using with MAX17043.

The battery never charges to 4.20, realistically it will charge to 4.15 or 4.18 and that means the MAX17043 will never say the battery is 100% but it actually is because lets be honest 0.05-0.010v means nothing really.

Is pretty annoying because I am using it in my project and when it powers on, voltage will drop FOR SURE even if is 4.20v. (~200mA current draw, with 2000mAh lipo battery)

Solution:

For now I think I will just ignore the percentage reading from the MAX17043 itself, and I will just implement an if range statement that will only look at the voltage and based on that I will generate percentage.

Can we fix this issue? I can help out on testing if that helps.. I think is a real issue because users will never see a battery with more than 90%

porrey commented 2 years ago

What is the enhancement you are requesting?

cservidoctavian commented 2 years ago

Create a side logic to handle the batteries that charge only up to ~4.10v to be seen as 100%

porrey commented 2 years ago

Can you run the Debug sketch and show your output here? It can be found in the examples folder.

BhargavVadaliya commented 2 years ago

Hello @porrey. I'm facing the same issue. the percentage never shows more than 91%. Have any side logic to show battery percentage 100%?

Here is my debug sketch output:

Serial port initialized.

Searching for a device...
A MAX1704x device was found at address 0x36
Resetting device...
Initiating quickstart mode...
Reading device...

RAW VALUES
----------------------------------------
ADDRESS............: 0x36   (54)
VCELL HIGH BYTE....: 0xCD   (205)
VCELL LOW BYTE.....: 0xC0   (192)
SOC HIGH BYTE......: 0x5B   (91)
SOC LOW BYTE.......: 0x04   (4)
MODE HIGH BYTE.....: 0x00   (0)
MODE LOW BYTE......: 0x00   (0)
VERSION HIGH BYTE..: 0x00   (0)
VERSION LOW BYTE...: 0x03   (3)
CONFIG HIGH BYTE...: 0x97   (151)
CONFIG LOW BYTE....: 0x1C   (28)

COMPUTED VALUES
----------------------------------------
PERCENT............: 91.02%
ADC................: 3292
VOLTAGE (MAX17043).: 4115.00 mV
VOLTAGE (MAX17044).: 8230.00 mV
SLEEPING...........: No
ALERT..............: No
ALERT THRESHOLD....: 4%
COMPENSATION.......: 0x97
porrey commented 2 years ago

You could try the map() function.

https://www.arduino.cc/reference/en/language/functions/math/map/

BhargavVadaliya commented 2 years ago

You could try the map() function.

https://www.arduino.cc/reference/en/language/functions/math/map/

Okay. Thanks for the help.

cservidoctavian commented 1 year ago

Here is a decent fix, indeed is not easy to measure a battery by the book:

fun measureBattery() {

// I use sleep(); in my code, use the below if you do so too if (FuelGauge.isSleeping()) { FuelGauge.wake(); delay(250); }

batteryVoltage = FuelGauge.voltage(); int batteryPercentageFromIC = FuelGauge.percent();

// this is because when battery is charging the voltage reads above 4100mV so we reset it every time is above that // because we have a fresh start, at it is very accurate, per my tests error is around 0.050mV if(batteryVoltage >= 4100) { FuelGauge.reset(); delay(250); }

// here we map the voltage based on this graph: image

// if you look in the above graph, when disconnecting the charger the battery will fall eventually to 4.0V so I did the logic below //based on that. if(batteryPercentageFromIC >= 79) { batteryPercentage = map(batteryPercentageFromIC, 79, 100, 100, 100); } else { batteryPercentage = map(batteryPercentageFromIC, 0, 79, 0, 100); }

}