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?