Hi msfujino.
I have stumbled on your post and wanted to replicate what you were doing on a XIAO ESP32-S3, using the A9 analog pin. I tried it with a battery pack I assembled using 2 Li-Ion batteries in parallel with ~10800mAh capacity, so the voltage was (at the time of testing, measured with 2 different measuring instruments) 4.11V. The measured voltage from A9 pin was 4.02V (average over 100 measures, with 100ms between every measurement). I used your code, only modified to measure 100 different values, instead of 15, to get a more realistic average and I added a function that sends the result from the measurement to Slack, as I already had code ready for that and the ESP wasn’t connected to a serial port.
My question is, why is there a 90mV error during measurement and what can I do to avoid it. I tried measuring different voltages from a programmable power supply, and the measurement error is not linear, so adding an offset is not plausible.
Thank you in advance!