Wireless stick lite - reading battery level

I have been trying to read the battery voltage on the wireless stick lite…

The schematic shows this but I always get 4095 when reading pin 13

There might be a couple of things going on here.

A simple one is that GPIO21 output controls whether the voltage divider in front of GPIO13 is active. It also controls when the 3.3v power supply is available on the Vext pin. Try doing pinMode( 21, OUTPUT ); digitalWrite( 21, LOW ); delay(10); before reading the battery voltage.

I do not know if this circuit conflicts with pin 21 use as SDA and so you might have to be careful reading the battery voltage while also connecting GPIO21/GPIO22 to an I2C device.

Another possibility is I think I read running the ESP32 WiFi radio disables all of ADC2. GPIO13 is wired as ADC2_4 in analog mode and thus it might not work if you have WiFi going. This happened to me on GPIO12 (ADC2_5) and I ended up shifting to GPIO36 (ADC1_0). I’ve only just started playing with this board and didn’t research the interaction too much once I made my test rig work. It would be nice to know whether this is really true.

Thanks for that.

Tried with GPIO21 low and high. -> still getting 4095.
Tried with wifi on/off -> still 4095
Tried with a battery LiPo battery at 3.0 -> still 4095

Think I will just build a voltage divider separately :sweat_smile:

Tested with my own voltage divider and sensing voltage on pin 39 and battery level is as expected - i.e. it works.

One issue to consider is that when the wireless stick lite is plugged in to usb -> the battery is charging so the voltage that I am sensing may be higher

I’m having a battery with the wrong connector (JST PH instead of SH) and therefore plug it into the regular 5V pin. Is it possible to measure the available current anyway?