Firebeetle ESP32 C6 battery level

userHead Peter.Robinson 2024-06-30 13:30:59 394 Views1 Replies

I'm using the Firebeetle ESP32 C6 with Micropython and a LiPo battery.  Analog input A0 is supposed to read the battery voltage level, but it's always zero.  I've tried different attenuation settings, with the same result.  Has anyone succeeded in resading the battery voltage level, and if so how?

 

Here's a snippet of the code I'm using (I've omitted the imports):

 

bat = ADC(Pin(0))
bat.atten(ADC.ATTN_11DB)      #Full range: 3.3v
battery = bat.read() * 3.3 / 4096
print(f"Battery {battery}")

 

All advice gratefully received.

2024-07-21 23:06:30

An update: the same procedure works perfectly if I program it using the Arduino ecosystem rather than MicroPython, so perhaps it's an issue with MicroPython.

userHeadPic Peter.Robinson