lewisxhe / TTGO_Vxx

7 stars 30 forks source link

Battery status measurement #8

Open sqaw0 opened 4 days ago

sqaw0 commented 4 days ago

Hi, How can I measure the battery charge on TTGO T4 V1.3, because I tried to do it using analogRead() and the library for IP5306 and I failed? Thank you in advance.

lewisxhe commented 4 days ago

Use analogRead(35) to get the battery reading. Note that it is invalid when the USB is plugged in. It is only available when the battery is connected. image

examples:

            uint32_t v1 = analogReadMilliVolts(32);
            v1 *= 2;  //unit mv
sqaw0 commented 3 days ago

Then I have a question: why when I measure voltage (with battery) in this way, it increases/constantly changing ?

lewisxhe commented 3 days ago

Constantly changing? What is the scope of the change? Can you provide a log?

sqaw0 commented 1 day ago

Yes, I took measurements every 750 milliseconds, +-30 milliamps (if this is not significant, then I apologize for the concern). Logs are attached. batt.log

lewisxhe commented 23 hours ago

You are measuring by plugging in the USB, right? The voltage at this time is invalid because what is detected is the charging voltage, not the battery voltage.

sqaw0 commented 19 hours ago

No, with battery (Li-io) (if I did it with USB, I would have answered faster).

lewisxhe commented 18 hours ago

When using the battery, the voltage should not exceed 4.3V. I see that the log you provided has reached 4.5V, which is incorrect.

sqaw0 commented 14 hours ago

Regarding voltage: I wrote analogRead(35)*2 in the code, so that's it. But this doesn't eliminate the spread. And works on battery.

lewisxhe commented 38 minutes ago

You should use analogReadMilliVolts(35) * 2