Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery charge % #32

Open
alfwro13 opened this issue Sep 19, 2022 · 6 comments
Open

Battery charge % #32

alfwro13 opened this issue Sep 19, 2022 · 6 comments

Comments

@alfwro13
Copy link

Hi,
I have LILYGO® TTGO T5 V2.3 2.13 Inch E-Paper Screen and I have connected 3.7v 300mAh battery to the onboad battery connector.
I can see that on the board text written next to the battery connector BAT_TEST_35. What is it and can I use that to calculate battery % charge?

@lewisxhe
Copy link
Contributor

Yes, IO35 can collect battery voltage

@alfwro13
Copy link
Author

and is there a way to calculate the battery % charge ?

@lewisxhe
Copy link
Contributor

@BatsIhor
Copy link

BatsIhor commented Dec 7, 2022

float voltage = analogRead(35) / 4096.0 * 7.46; uint8_t percentage = 100; if (voltage > 1) { // Only display if there is a valid reading Serial.println("Voltage = " + String(voltage)); percentage = 2836.9625 * pow(voltage, 4) - 43987.4889 * pow(voltage, 3) + 255233.8134 * pow(voltage, 2) - 656689.7123 * voltage + 632041.7303; if (voltage >= 4.20) percentage = 100; if (voltage <= 3.50) percentage = 0; Serial.println("Percentage = " + String(percentage)); }

@BatsIhor
Copy link

BatsIhor commented Sep 5, 2023

@lewisxhe I checked your link but it's not clear how to use XPowerLib and what is the purpose of it. Do you have any documentation on what it is and when to use it? I was not able to find anything on the internet yet.

@lewisxhe
Copy link
Contributor

lewisxhe commented Sep 6, 2023

No, I'm just giving you a rough calculation of the percentage. Although it's not accurate, it can achieve the desired effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants