ESP32-C3 T-OI Plus. Reading battery level
- 
					
					
					
					
 Hi I'm working on a project where I need to know the charge level of the battery mounted in the ESP32-C3 T-OI Plus (Ver 1.3). 
 From what I see on the schematic, Vbat is connected to the ADC input through a resistive divider made up of two 100K resistors that cut the voltage in half.Building on that assumption, I'm using the following Micropython code: ... 
 #adc
 a0 = 2conversorAD = ADC (Pin(a0)) 
 conversorAD.width (ADC.WIDTH_12BIT)
 conversorAD.atten(ADC.ATTN_11DB)
 ...
 def leerBateria ():
 #Reads the battery charge percentage
 batVolt = 2*(conversorAD.read_uv ()/1000000)
 if (batVolt > 4.2):
 batVolt=4.2
 return (100*(batVolt/4.2))I think it is correct because it reads values consistent with the battery voltage measured with a multimeter. 
 What catches my attention is the variability of the values read, for example if I read every 20 seconds I can have (with USB connected)Bat = 99.57 
 Bat = 98.67
 Bat = 99.57
 Bat = 100.00What could this variation be due to? Thankfully, 
 Ernesto.
- 
					
					
					
					
 @etolocka The ESP32 is notoriously bad at ADC function, so...this is just a rough estimate of your battery life, 'for your information' 
- 
					
					
					
					
 @teastain2 Thank you! Am I interpreting the schematic correctly and is the voltage calculation also correct? Thankfully, 
 Ernesto.
- 
					
					
					
					
 @etolocka Well, Ernesto, if the returned value is saying that the battery is 100% of 4.2 volts...I think you are THERE! 
 I do not use Python, have a board like yours or ever monitored battery voltage, so I am no expert, it looks like you are OK!
 -Terry
