Battery level sensing for ESP32

Thread Starter


Joined Mar 7, 2022
I want to sense the battery voltage of a 3.7 Li ion battery with ESP32

Should I run 3.3V to an Analog enabled GPIO to show when fully charged at 4.2V using a voltage divider from the battery voltage with values 27K and 100K. I also want to sense when the battery is low below 3.5V (module will switch off at 3.2V using buck boost IC.)

I just want to confirm I am on the right track. Thanks

I found another thread on this subject mods can delete if you like.
Last edited:


Joined Jan 29, 2010
Hi trav333,
The 12 Bit ADC of the ESP32 has very poor linearity, to get exact reading you will have to correct the value in software.
I am currently working on a ESP32 using WiFi into my router to PC Web page.
For a 3.3V test voltage, the ADC reads 2.6V. !! [ I have tried 3 ESP32' all give the same error]
Changing the project to use an external ADC, I have some MCP3302/4 IC's


Thread Starter


Joined Mar 7, 2022
Hi Eric thank you great video and you gained a subscriber!

Accuracy is not that important in my application so I will have a play with the code to see if it is sufficient. I did see a comment on the video about how to accomplish that.

Thank you!