Closed krupis closed 2 months ago
I'm getting similar weirdness, showing 4095 raw value. Is there a different hw revision of the board that's wired differently or something perhaps?
@nvx The fact that you are seeing 4095 raw value is very strange indeed. Can you measure the voltage using multimeter? Since your ADC tells that there is 4095, that means the maximum value is measured on the ADC pin.
Anyways, I am still waiting for LilyGo to comment regarding this.
@nvx The fact that you are seeing 4095 raw value is very strange indeed. Can you measure the voltage using multimeter? Since your ADC tells that there is 4095, that means the maximum value is measured on the ADC pin.
Anyways, I am still waiting for LilyGo to comment regarding this.
Yeah DMM reads sane values. I got the version in a case, ended up taking it out of the case to see if I could see anything obviously wrong, after giving up I put it back in the case and now it reads a slightly saner voltage, but still much lower than it should be when running from battery, and when running from USB (with or without the battery attached) it seems to go up to 4.6V which is much higher than the DMM reads. I'm not sure if maybe there was a small solder ball or something I dislodged while bucking with it. I'm guessing there's a problem with the voltage reference.
I have uploaded a short example for you to try. Since the code you provided is not included in Arduino, I only used Arduino for testing.
@lewisxhe Hello. Thanks for you reply. I still have a couple of issues regarding measuring battery voltage.
I have run your example code and found out that the example is not able to measure the battery voltage while the USB is plugged in. Why is that the case? Does the BAT_ADC suppose to measure Voltage across the battery terminals? If that is the case, it should be able to measure the voltage even when the USB is connected. When I connect the USB, the voltage accross the battery terminals goes up by about 100mV indicating charging progress.
When the USB is disconnected, the measured Battery voltage displayed on the display is 3400mV. The actual Voltage measured using digital multimeter is 3600mV. 200mV is quite a large error.
@krupis
@lewisxhe Wouldn't it be better and more informative to measure the battery directly across its terminals? This would allow us to measure its voltage even when the USB is plugged in, right?
I dont really understand why would it be done any other way.
- When USB is plugged in, the BAT voltage is taken over by the TP4065 charging IC, so the voltage tested at this time is meaningless.
According to the schematic the ADC is measuring the voltage directly (via a voltage divider), so I'm a little confused why this isn't showing the battery terminal voltage still - even if the TP4065 chip is charging the battery, it should still display the charging voltage (which may be higher than the battery voltage once the charger is disconnected, but still match what a DMM shows when measured across the terminals)
- The ADC of ESP32 is not very accurate, and in the example, I only read the data once and did not do any data processing. In actual circumstances, the internal voltage reference of ESP32 is affected by the external power supply, so it cannot be accurately obtained. Voltage data can only be used as a reference.
Even reading it continuously results in similar errors though. Looking at the schematic the ESP32 voltage reference should be regulated though. Is the schematic accurate? Are the board designs available so we can cross reference it against the schematic to confirm if there's any discrepancies between the two which would allow for compensating in software if discovered.
@lewisxhe Wouldn't it be better and more informative to measure the battery directly across its terminals? This would allow us to measure its voltage even when the USB is plugged in, right?
I dont really understand why would it be done any other way.
There's nothing I can do about it, I'm not the one who designed this circuit.
@nvx This is the current path as I understand it.
@nvx This is the current path as I understand it.
Good catch, but wouldn't that completely bypass the charging circuitry and overcharge the battery which would be quite dangerous if we're not missing something here?
Oh! I overlooked something.
I still cannot wrap my head around why we would not be able to measure the battery voltage when the USB is plugged in. It should measure identically to what the DMM measures across the battery terminals.
I have now started to understand what is the problem. The name of the ADC pin BAT_ADC is very misleading because its not actually measuring the voltage across battery terminals but instead it is just measuring the supply voltage (measuring Battery if USB is not plugged in and when the USB is plugged in it measured 5V).
This in my opinion is not correct for Battery powered application and VUSB_ADC and BAT_ADC should be seperated. Currently, there is no way to know if the battery is charging or not as there is no possible way to measure the battery voltage using ADC when it is being charged.
Oh! I overlooked something.
Except from what I can see that MOSFET would be turned on, and when turned on it will happily conduct in both directions unless I'm missing something
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
I use the following code to measure the voltage on GPIO4
And then in my main.c I call:
I have connected the battery and measuring ADC
When measured with Multimeter, the voltage across battery terminals is 3.9V (while the battery is connected to the board)
When I disconnect the battery, the results are:
My questions:
When battery is plugged in, the ADC voltage is 2.14V (considering that there is a voltage divider 100kOhm and 100kOhm), the battery voltage according to the ADC is 4.3V which is too high. The actual battery voltage is 3.9V
When the battery is not connected, the ADC measures 2.28V and I cannot wrap my head around how is that possible.