porrey / max1704x Goto Github PK
View Code? Open in Web Editor NEWArduino library for the MAX17043/44 and MAX17048/49 LiPo Battery Fuel Gauge.
License: GNU General Public License v3.0
Arduino library for the MAX17043/44 and MAX17048/49 LiPo Battery Fuel Gauge.
License: GNU General Public License v3.0
Hi,
I tried the basic example and it runs perfectly, just reports percentage as 256% presumably because I have the FuelGauge connected to non-default pins. So been trying to initialize my own Wire.h specifying the required pins but I get the following panic error:
19:24:38.226 -> A2 : 0x00000000 A3 : 0x00000036 A4 : 0x00000000 A5 : 0x00000100
19:24:38.319 -> A6 : 0x3ffb8a28 A7 : 0x00000000 A8 : 0x80088830 A9 : 0x3ffb2720
19:24:38.413 -> A10 : 0x3ffc18c0 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000001
19:24:38.460 -> A14 : 0x00060f20 A15 : 0x00000001 SAR : 0x0000001c EXCCAUSE: 0x0000001c
19:24:38.600 -> EXCVADDR: 0x00000134 LBEG : 0x4008649d LEND : 0x400864ad LCOUNT : 0xfffffffa
19:24:38.694 ->
19:24:38.694 ->
19:24:38.694 -> Backtrace:0x400d13a3:0x3ffb27600x400d1508:0x3ffb2780 0x400d1128:0x3ffb27a0 0x400d1148:0x3ffb27c0 0x400d1185:0x3ffb27e0 0x400d10e6:0x3ffb2800 0x400d2309:0x3ffb2820
19:24:38.836 ->
19:24:38.836 ->
19:24:38.836 ->
19:24:38.836 ->
19:24:38.883 -> ELF file SHA256: 0000000000000000
19:24:38.929 ->
19:24:38.929 -> Rebooting...
19:24:38.929 -> �9ZO"⸮P
19:24:38.929 -> YP[4L⸮%p⸮Battery percentage is Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
My code is:
#include <MAX17043.h>
const int pinSDA = 22;
const int pinSCL = 19;
void setup()
{
Serial.begin(9600);
Wire.begin(pinSDA, pinSCL);
FuelGauge.begin(false);
}
void loop()
{
Serial.print("Battery percentage is ");
Serial.println(FuelGauge.percent());
}
How would you force "begin" to use Wire1 instead of Wire?
Line 52 in d0fef77
To make this work with ESP32, change this line (and coresponding in .h) to something as:
#if defined(ESP8266) || defined(ESP32)
Now I need somehow calibrate it, I have two modules, one somehow works and 2nd return ADC zero
I do not know why most of Arudino libraries trying do something what they should not do.
Here you initialize i2c bus. That is problem if you want to use I2C on different pins (you cannot pass begin(sda,scl). Also if you have bus initialized from outside, you reinitialize it by own and break other I2C libraries
I suggest to add another constructor with I2C reference class, so it will NOT break up old behaviour and also it introduce way how to reuse initialised I2C interface from code.
Line 33 in 99644a0
Hi,
this is not an issue in your library, but maybe you are able to help me, because you have more experience with the MAX17043.
I'm using an nodemcu esp-12F and without the MAX17043 connected the power consumption is around 0.01 mA in deep sleep. I connected the Fuel Gauge in parallel to my battery and I receive readings from the gauge and everything works well. Except, that the power draw is very high. In deep sleep of the esp8266 the current that is being drawn is around 0.9mA. When i disconnect the positive battery wire from the fuel gauge, the power consumption drops to around 0,05 mA. This would match my expectation, as the MAX17043 has an active current from 0.05 mA to 0.075 mA - Putting the MAX17043 device to sleep has no effect. Fun fact, if i reconnect the power lead to the MAX17043, the power consumptions stays at 0.05 mA. I have no idea what could be causing this.
I tried differend nodemcu boards, but all show the same behaviour. Do you have an idea, why the power consumption is so high?
Best regards
Christian
Hey, I recently tried keeping the reader sleeping and waking only for reading the current battery... still, it was returning only 0. Does the MAX require a delay before reading info when I call wake?
int getPercent()
{
if(init_fault)
{
return -1;
}
maxDevice.wake(); //<--- WAKE
float percent = maxDevice.percent(true); //<--- READ
maxDevice.sleep(); //<--- SLEEP
lastPercent = (int)percent;
return (int)percent;
}
Example: Max17044
Board: NodeMCU 1.0
Arduino IDE throwing Error when compiling Max17044 example for Esp8266 board.
Error:
"C:\Users\TECHNO~1\AppData\Local\Temp\arduino_build_883167\libraries\MAX1704X\MAX1704X.cpp.o"
C:\Users\TechnoML3\Documents\Arduino\libraries\MAX1704X\src\MAX1704X.cpp: In member function 'bool MAX1704X::begin(uint8_t)':
C:\Users\TechnoML3\Documents\Arduino\libraries\MAX1704X\src\MAX1704X.cpp:70:1: error: no return statement in function returning non-void [-Werror=return-type]
70 | }
| ^
cc1plus.exe: some warnings being treated as errors
Using library MAX1704X at version 1.2.7 in folder: C:\Users\TechnoML3\Documents\Arduino\libraries\MAX1704X
Using library Wire at version 1.0 in folder: C:\Users\TechnoML3\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\Wire
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
X750 is raspberry pi ups module.
It's integrated with max17040 chip that shears same i2c line as raspberry has.
I need to access battery infos from it with arduino
It's ok to use this library?
Hello
I just received this and try to make it work, it's just a test settings with a nano and the fuel jauge
got it connected and uploaded your library
the result seems inconsistent :
20:19:03.158 -> Version: 3
20:19:03.158 -> ADC: 3923
20:19:03.158 -> Voltage: 4903.75 v
20:19:03.158 -> Percent: 190.84%
20:19:03.158 -> Is Sleeping: No
20:19:03.158 -> Alert: No
20:19:03.158 -> Threshold: 4
20:19:03.158 -> Compensation: 0x97
I measure the battery with a controler => 4.2V (it's fully charged, it's a lipo 3.7 250mAh cf. https://www.gotronic.fr/pj2-09941-1983.pdf)
the result is identical if the battery is there or not
apparently it recognises it since when i disconnect the jauge i get
0:24:29.086 -> Version: 65535
20:24:29.086 -> ADC: 4095
20:24:29.086 -> Voltage: 5118.75 v
20:24:29.086 -> Percent: 256.00%
20:24:29.086 -> Is Sleeping: Yes
20:24:29.086 -> Alert: Yes
20:24:29.086 -> Threshold: 1
20:24:29.086 -> Compensation: 0xFF
also when I connect the battery after a certain while the Voltage shows about 4200 V (could be coherent with a factor 10³ but then it grows continuously and the Percent is inconsistent eg 200% but some time 150 or any other value)
any idea where I could search ?
thanks
dom
Hello and happy year 2022
This is not an issue about your lib but a question. Do you have an idea of how to stop the charge when the fuel jauge says it's over ninety-ish or a bit more. I'm using the Max 1703 fuel jauge plus a lipo charger (https://www.dfrobot.com/product-2068.html).
thanks, regards
dom
So, for the last month I've been using this code and the module that someone suggested to and everything in your code works, except one thing that's quite crucial to my project. Which is showing the percentage of the battery through my LCD. I've made sure everything was connected properly and everything else worked properly which it does fortunately. I can show the voltage on the LCD but the percentage constantly stays at 0.00% which is rather strange to me.
You'll see that I have a voltage going through, but no percentage. I've tested the other properties in your code and they work properly.
I'm currently doing this through a Serial monitor on Arduino fyi
Would it be possible to support the Aliexpress clone boards that have 0x32 address? They seem to work, but work differently. And i expect that there are more of these than there are of the original ones around. Someone must have gotten these to work properly.
There is one post here, that shows how it works:
https://forum.arduino.cc/t/max17043-fuel-gauge-not-working-at-all/329534/17
I tested this (after changing the I2C address in the MAX1704X.h file) , by rapidly putting it to sleep, waking it up and then reading. This way it gets a reading, other than that it seems to not read the voltage. The percentage is still wrong though.
Also, seems the voltage reading is wrong. I measured the cell at 4.158v. But at least it gives some sort of reading.. though the max is 5v, so maybe its just giving the max value. But the person on arduino forum did manage to get it working.
After testing more, quick start or reset works also. After that you can read it once in a really short time period. I tested using a ledlight, and the voltage reading drops like it should. And right around when it hits 4.2v the percentage is 100%. So the readings are just too high, but otherwise correct.
So this was the quickest way to read, using the example code:
FuelGauge.quickstart();
delay(100);
displayReading();
Just quickstart it before reading. It seems to need 100ms delay between the quickstart & reading.
Just the voltages & percentage now needs to be calibrated to match correct values. Maybe the percentage is using the 1/256 reading, instead of the 1/100%? Full cell reports 195%. And around 4.9 volts.
Hi
Is there a way to calibrate readings got clone chip that reads address as 0x76 but getting wrong readings.
Baterry is charged to 3.8v but reads as 2.2v and capacity is 0
Can you help here please
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%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.