I'm using a voltage ladder to determine the position of a rotary switch, which is read by a ESP32 (max 2.5V input on the ADC). (It also switches on/off the gadget, that's why I connect it this way).
In a first attempt, i just fed the divider directly from the LiIon battery, but the values would greatly differ depending on the battery level, and sometimes overlap if battery is very low, or fully charged. If I carefully choose resistor values, the voltage won't overlap.
A better choice would probably be to feed it with a known voltage. I'm looking at both a 2.5V LDO and the TL431.
The v-reg is easy to implement, but how would I go about using a TL431?
And which would be my best choice, considering power usage? The regulator/reference would always be connected to the battery.