Raspberry Pico (RP2040) + Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
anglerfish27
 
Posts: 44
Joined: Thu Dec 15, 2022 3:26 pm

Raspberry Pico (RP2040) + Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor

Post by anglerfish27 »

Hey team,
This product, the Adafruit LC709203F LiPoly / LiIon Fuel Gauge, and Battery Monitor. Really caught my eye as something handy that I could use. I ordered up 5 of them. I will admit that I didn't catch the part that stated that I2C clock stretching is needed. I know that I2C Clock Stretching is not supported on the Pico. So...what am I to do? Is there a way around this? I am working to take the Arduino code bits and build my own C++ library for this product as I do not program in Python or Arduino's version of C++. I use traditional C/C++ in Visual Studio code.

There is a pretty famous guy in the Pico/Arduino world Phil something (apologies!!) who ported a bunch of Arduino functions for use with MS VC. However, I think that project has since died and not everything works in the Pico or other MCUs. I have the big ticket items working ( I say working because they compile with no errors and for example the millis function works. I can include <Arduino.h>, and <wire.h> and I'm hoping to get the I2cbus modules working even if I have to re-write some by hand using the Pico C SDK. That I hope will allow me to interact with the LC709203F and get data from it using I2c and allowing to program the rest of my code in my normal C / PicoSDK style. Any thoughts on this or is it a lost cause and it's never going to work?

About the clock stretching, what do I do, is there a way to cheat I2C into thinking it has what it needs? I'm no expert by any means. I read online you can "slow it down" more, but honestly outside of the original init 100x1000 I do for other sensors I'm not sure what they mean. I read a book dedicated to I2c and it actually shows you how to implement a software-based master/slave I2C, I really hope I don't have to go down that road. Plus I don't know if that code supports clock stretching.

Another roadblock is the battery size you set the register to. I typically use the "blue wrapped" batteries you see on this site in a pack of 2 or 3 for about 4400 or 6600mAh's. I have some homemade parallel power banks that use 3400mAh batteries. I don't see in the datasheet or the code how to set it to read as if it's a 3400 mAh battery, or even a 3300 mAh one. I know it's treated as one cell but the choices seem to end at 3000mAh. Thoughts?

I'm going to buy the MCU + screen listed on the page for the LC709203F. So I can set one up and test it by simply using the supplied code(copy paste mode). Doesn't help my Pico situation but I want to at least tinker.

If anyone can suggest how I could get this to work in an RP2040 that would be awesome (in C/C++, not Ardunio). I would love to be able to know when my voltage is getting too low and take action to recharge it or shut down the Pico.

Lastly and this one is a hail mary ask, but it would be epic if the Adafruit team would provide example code for their products in pure c/c++ for the Pico and other MCUs that use those languages without Arduino in the picture. Some vendors offer it and it helps us crazy people who don't use Python (I know it's so much easier to program in Python). I spend a fortune on products from you guys, I'm a loyal customer I love your products and little video snips of them plus the individualized websites. If we could just get some c/c++ (pure) code help man, a lot of people would be happy. For now, I'm just interested if I can hack my way into getting this to work on a Pico (RP2040).

Respectfully,
Me.

User avatar
barshatriplee
 
Posts: 200
Joined: Wed Mar 22, 2023 10:11 am

Re: Raspberry Pico (RP2040) + Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor

Post by barshatriplee »

it may be possible to modify the existing Arduino code to work with the Pico. Alternatively, you may need to write your own C/C++ library for the LC709203F based on the datasheet and example code provided by Adafruit.
the LC709203F datasheet specifies that it can be configured to work with batteries with capacities from 100mAh to 6000mAh.

User avatar
anglerfish27
 
Posts: 44
Joined: Thu Dec 15, 2022 3:26 pm

Re: Raspberry Pico (RP2040) + Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor

Post by anglerfish27 »

Yeah I’m going to mess around and see if I can get it working. I can create a software based I2C that supports clock stretching most likely but this is an enormous waste of resources. I must have missed the part in the data sheet that had the values for say 6000mAh. I can get by with 3000 since it’s documented and I have a set of 8x18650 batteries that are 3000mA I can put in parallel to keep the current the same and voltage the same just a lot more current saved up!

Slightly off topic is there a way in code to turn the pico off? Basically I want if battery voltage = 2.8 shutdown power. I don’t want the batteries to fall below the recommended thresholds.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”