Battery voltage monitor and AD conversion for XIAO_ESP32C

One source of inaccuracy is the tolerance of the resistors. A typical tolerance would be 5%. Say in the worst case one resistor is off from its nominal value by +5%, and the other is off by -5%.

Then the voltage result you get will be off by 5% as well:

V_pin = V_true * R_2 / (R_1 + R_2)

R_1 = R_nominal + 5% = R_nominal * 1.05
R_2 = R_nominal - 5% = R_nominal * 0.95

V_pin = V_true * 0.95 / 2

V_result = 2 * V_pin = 0.95 * V_true