Voltage divider is not giving correct voltage

This is the circuit

see here the vin is not connected to the esp32-s2, only ground is connected and the io line should have ~1.8v but i am getting ~1.1v. when the gnd is not connected to esp i get the correct value in the IO line.
r1 & r2 both are 100k, Vin is 3.7v at the time of measuring, as it's a 18650 battery. Source is DC.
I measured using a muiltimeter, one lid in ground another is in Vout.

Here is the Schematic, Pls note that all the values are not correct.
kk.pdf (79.7 KB)

Don't know how we are supposed to comment without knowing the values of the resistors and Vin. Also the tolerances of the resistors.

Is io an analog input?

Measured how?

To get a proper answer for this question please provide the resistor values (as already requested), a description of the power source, and a picture of the actual circuit.

You have an advantage you can see the project and where you connect the test leads. Our eyes (at least mine) cannot see that. Without the values of R1 and R2 along with Vin there is no way we can answer your question. Also you did not state AC or Dc, that also has a bearing on the readings. How do you know you are to get 1.8V, that is also a mystery to me. Is this a homework question by chance?

Use a multimeter instead.

1 Like

The equation for Vout (assuming the esp is not connected).

Vout = Vin * R2/(R1+R2) It cannot be wrong. So if you are not getting the calculated result and your result changes when you connect it to the esp32 ground then one of the variables has changed, OR you measurement method is incorrect.

Remember there is not such thing as "ground" on a circuit. There is usually a common where supplies and circuits are all connected. So perhaps where you are measuring from is not the common of your resistor divider.

Is the power supply for the ESP32 and the voltage source you are measuring connected in any way besides the Vin and gnd shown in the schematic?

Do note that Vout is not always Vin * R2 (R1+R2) in this case because the internal resistor of ESP32 is in parallel with R2. So if R2 is close enough to the internal resistor of ESP32 you do not get the expected value.
How to check?
Disconnect the esp32 and measure the voltage with a multi meter. Then reconnect and do the same measurement.
Best Regards,
Johi.

Hence the qualification.

Sorry for the missing values,
r1 & r2 both are 100k, Vin is 3.7v at the time of measuring, as it's a 18650 battery. Source is DC.
I measured using a muiltimeter, one lid in ground another is in Vout.
@gilshultz i'ts not a homework question. It's my project called mutantC https://mutantc.gitlab.io/.
@JOHI i told before if the io or gnd is not connected to the voltage divider circuit i get 1.8v in io line.
@JohnRob i think R1 is changing some how.

@david_2018 @er_name_not_found Here is the Schematic, Pls note that all the values are not correct.

kk.pdf (79.7 KB)

Hello
Post your sketch and a picture of the hardware setup.

I assume you have the ESP32 powered, otherwise clamping current will flow into the I/O pin.
I assume you use a modern DMM with 10Megohm impedance, not an old 20kohm/V analogue meter.
Leo..

1 Like

I added that in the last commit.
@Wawa i am using a pocket muiltimeter. it works fine enough for this simple measurements .

LCD or analogue. What is it's impedance.
The multimeter has some resistance of it's own, which alters the bottom resistor of your divider.
Leo..

digital. it show the correct value (3.7/2 v) when the esp is not connected. and i am measuring both circuit at the same points. so it's not a muiltimeter issue.

1: You should not be applying negative voltages to the ADC. Your schematic is very complex so I'm assuming you did not intend to show them as negative???
2: You will need to show the code you are using to take readings on the ESP32; the ESP32 is a tricky beast with which to measure voltages.
3: your schematic shows BAT/M connects to IO18. Are you sure that can be used as an ADC input and is it configured as such?

Thing is i am not using esp32 to measure the voltage. i used the muiltimeter. and meter is not giving me correct value.
also as i told before esp32's VCC is not connected to the battery, only the gnd and the io.
ADC is connected to the battery's +, i don't think goes to negative.

And where the ESP gets power?

esp gets power from the boost converter. that boost the li-on battery to 5v.
but i did n't soldered those to see if the voltage divider is working or not. but it's not.

Is the ESP32 chip powered while you are making the measurements with the multimeter? It was pointed out in reply #12 that current will flow through the input clamping circuit if the voltage on the input pin exceeds Vcc - essentially you would be trying to parasitically power the ESP32 via the voltage divider.