Vext control and Battery level detect

Hi I would like to know how to use I2C and Battery level detect with pin 21 as pin 21 is SDA

I cannot use pin 13 ADC2_4 while Wifi is beibg used. I am programming in Arduino IDE

I2C Example:

Battery detects and measures example:

The reading battery power example don’t work for me.

The battery level is over 100% when only a lipo battery is connected.
I believe the following variable is wrong float XS = 0.00225;
It seems calculated considering that 3.3V is the max value that internal ADC can read.

Reading other posts the max ADC value is 2.5V. Considering that: float XS = 0.001953 make it works. Battery level 100% when the battery is fully charger.

1 Like

When ESP32 uses WI-FI, the internal ADC2 is occupied. Therefore, the application can only use ADC2 when the Wi-Fi driver is not started.

https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/adc.html

3 Likes