I'm using ESP32 to read an analog value of a liPo battery (3.7v-4.2v).
Since ESP32 DAC's is 3.3v I'm using a voltage divider ( 2x10K resistors ), to split bat's voltage into ESP's GPIO36. So far nothing new or not well documented on the web.
Using the voltage divider, splits the 4.0v into 1.97v (measured using a volt-meter). Battery's negative pole is connected to ESP's Gnd to get a common ground. GPIO36 is connected to the 1.97v line ( and this value is tested using a volt-meter also on ESP's pin to make sure ).
I was expecting to get a digital value of 1.97 (2444 )
BUT NO!,
when using analogRead(36) I'm getting a digital value of 2180 which correlates to 2180/4095*3.3 = 1.75v.
1) I tried to make a 100 samples over time - to make sure it is not a power up issue. No change.
2) I tried to read its value during loop() and not setup(). No change.
Is DAC's resolution is that poor ( roughly 12% off ), or am I doing something wrong ?