We have a IOT design that runs its normal operation with 12 V DC. Without the 12 V DC, we have a 2-cell Li-ion battery pack which outputs 6-8.4 V.
As a Li-ion charger we use Microchip's MCP73213.
We are also reading the battery voltage on ESP32's SENSOR_VP port. This port is using for ADC voltage reading.
When we are running the card with a battery, we can read the ADC value between 6-8.4 V correctly.
With 12 V DC connected to the board, the ADC readings between 8.0-8.4 V are correct, but between 6-7.9 V they are inconsistent. The voltage the ADC reads varies and gives us wrong values. Can anyone tell us what is wrong?



It could be sensitive to noise but while the battery charge between 8.0-8.4V it is consistent. I think It doesn't explain the situation.
@Finbarr we already charging the battery with 12V which is in the voltage range of MCP73213 datasheet. Charging period has no problem
– torosluadam Oct 05 '22 at 05:54