Try the same code and the exact same setup with an Arduino too. See if that gives correct readings. (This might be a very unpopular opinion, but in my humble nooby opinion the only thing ESP is good at is being cheap. It's an unreliable toy. It's not worth spending your time figuring out why it's giving out weird reading unless an Atmel chip is doing it)
The voltage on the A0 pin is exactly 3V. Meassured with multimeter.
And what is the UUT (unit under test ) voltage with a meter ?What is R1 ? R2 ?(which is 12k and which is 3.3k) ?If R2=3.3k,R1=12k,and UUT = 12V,.'.12* 3300/(12000+3300)=2.58VGiven above divider,If UUT is UNK(X)X=3V/0.21568 (3300/15300)X=13.9VUUT=13.9VWhat is UUT voltage when A0 voltage =3V ?BTW, Pourduino is right. Always have at least two references, otherwise your data is unreliable.
Reading an analog value with the ESP32 means you can measure varying voltage levels between 0 V and 3.3 V. The voltage measured is then assigned to a value between 0 and 4095, in which 0 V corresponds to 0, and 3.3 V corresponds to 4095.
float voltage = (analogRead(A0) - offset) * 0.01486; // calibrate
How exactly is the signal 'rapidly changing ' if it's a battery or a PSU ? That makes no sense.