Below is my setup for reading the USB voltage and battery voltage.
Do I need to worry about any current leak here through the battery voltage divider which may impact battery life?
I was considering adding a transistor connected to an output pin which would enable the battery voltage divider only when the voltage needs to be read. I am not sure if it is really required though.
You can use an NPN transistor or an N-channel MOSFET to connect/disconnect the ground side of the voltage divider.Turn on the transistor only when measuring the battery voltage.
@cgwaltney@liaifat85 As it stands, with the 200K of resistance, there would be a current leak of around 18.5 uA. I’m not sure if this is considered negligible or not in such a case.
The sleep current of XIAO_ESP32C6 is 14.3uA. The current consumed by the voltage divider resistor is 18.5uA, which is as small as the sleep current.
However, if we change the way we think about it, connecting a voltage divider resistor doubles the total sleep current to 32.7uA.
If this is a problem, then increase the value of the resistor, or use a voltage divider only when necessary.