Voltage divider is not giving correct voltage

no it's not powered one. on gnd and io are connected to the esp.
I think this might be the cause. can you explain that input clamping thing?

Oh Dear!
Just because its not powered doesnt mean you can connect something and expect it to behave like an open circuit!
Its a complex bit of silicon junctions. 1.1V is around 2 diode drops at the current you are providing.
Try it again with the supply connected.

Hello
What you are doing?

supply connected to the esp32?

@paulpaulson i am trying to measure a battery voltage

yes. to the esp32.

Over-voltage (ESD) protection.
Google "clamping diodes".
They prevent I/O voltage exceeding VCC/GND of the ESP chip.
You must power the ESP if you're going to put a voltage on the pin.
Leo..

@johnerrington i powered the esp, and i got the same voltage on the IO line, around 1.2v.

@Wawa now i think it's not the cause.

I thought the ESP boards have an existing voltage divider built-in as the ADC is 1.2V max - so you have to allow for that divider network when adding an external divider...

I might be wrong but this rings a bell for me.

Can you switch back and forth between the two states and get repeatable results? If so it would difficult to see how R1 would change. Is R1 a normal two leaded resistor?

My guess it Vin changing as a result of the different ground.

yes, i am getting repeatable results. it's a normal 1206 size 100k resistor.

any one can try it with a breadboard and a esp32 and 2 same resistor. use a power supply instead of 18650 battery.

I am confused about your circuit configurations(s).

  1. Vin is not connected, ONLY GROUND is connected. Vout = 1.1 . Is Vout connected to the esp32? Or only ground as stated?

  2. When the ground is NOT connected Vout = 1.8. So in this case ONLY the Vout to esp32 is connected?

  1. both Vout and gnd is connected.
  2. this time, only GND is connected and Vout is not connected. the divider gives 1.8v

Have you tried using 10K or even 1K for your potential divider circuit resistors. That will make a difference.

Ok then you have current going into the esp32 input, causing additional load on your divider.

As stated by MarkT, you are exceeding the max input on the ADC input pin of the esp32

What are you connecting the ground pin of your multimeter to. Normally all voltages are referenced to ground, if not then explicitly state the two points.

I have simulated your test using an ESP32 Devkit C and the circuit shown in the schematic.

The pot is set to midway so similar to a chain of 2 5k resistors, giving a source resisitance of 2k5.
I measured the voltages with a "chinese" DVM So Vcc was 3,178V;
The midpoint voltage was measured as 1.607 volts.
I connected the 1M so the cct is now as shown on the fig. except that (S1 closed) the 1M is also connected to pin IO34 (ADC) and the midpoint voltage remained at 1.607 volts
The voltage at the ADC pin (pin GPIO34) was measured as 1.474 volts.
"now I can calculate Rin for the ADC. " Ri = 1M * 1.474 / (1.607 - 1.474) = 11 Mohm.

NO.

I disconnected the DMM. the ADC readings jumped from 1600 to 1790.

So the "chinese" multimeter was affecting the readings.

With the 1M disconnected from the ADC - (S1 open) - I still get the voltage readings as shown.

The DMM has an input resisitance of ABOUT 10M.

OK now connect the 1M to pin 34 with the DMM still attached (close S1).
The measured voltage stays at 1.474

So to the level of accuracy to which I can measure, the input resistance of the ADC (on pin IO34) is virtually infinite.

@rahmanshaber - are you making these measurements on the simple circuit as I have shown - or on your board as shown in your schematic? If the latter there MUST be something on your board that is affecting the voltage.

Thanks a lot for testing it. my board is like the schematic, i printed the pcb and testing the board.

i did not soldered anything in the board other than 2 resistor and the battery.

I assume you only have used electronics-grade resin-cored solder.
Leo..

why does it matters?

i tried the same circuit with different pins of the ESp32, but with 1k resistor. gives me this
pin 13,21 =1.8, v
pin 34,22 = 1.4v
pin 19,20 = 0.7v

no idea why. using 1k resistor increased the v from 1.1 to 1.4 guess