I'm trying to measure the resistance of water. My first attempt was to just use a voltage divider and measure the voltage between the water and a known resistance using the ADC on a microcontroller. The resistance of the water changed while measuring, probably because the electrodes are displacing the ions.

I think using a PWM signal with a virtual ground will solve this, though I have to filter out the PWM signal before measuring with the ADC. The problem is that the filter circuit affects the voltage divider, and always stabilizes at 2.5V no matter the resistance of the water.

The circuit I'm testing:

Voltage divider with RC filter

Is there another way to filter out the frequency of the PWM after the voltage divider, so I can measure the DC level on the ADC?

  • \$\begingroup\$ What's the separation between your probes? \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 10:09
  • \$\begingroup\$ 1cm, but I can my setup if that will solve any problems \$\endgroup\$ Jun 14, 2021 at 10:40
  • 1
    \$\begingroup\$ Here are some videos showing the 3 main conductivity measurement methods: youtube.com/watch?v=5qxenj3NpE0 youtube.com/watch?v=sVcG65dMZfk \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 10:46
  • \$\begingroup\$ How are you establishing your virtual ground? \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 10:49
  • \$\begingroup\$ From a output pin on the microcontroller set to 2.5V. In my defense, I read somewhere else that it was "okay" to create an AC signal using a microcontroller. \$\endgroup\$ Jun 14, 2021 at 10:52

3 Answers 3


The ‘resistance of water’ isn’t exactly a thing, in the sense that current isn’t always proportional to voltage. You’ll need to decide under what conditions you want to make the measurement - AC vs DC, what distance between the electrodes, what kind of electrodes do you want to use, etc. You may well be measuring more about the electrodes than you are about the water. What are you trying to achieve? If you want to measure the level of ionic solutes then you may want to use relatively inert electrodes (carbon perhaps) and AC with no DC offset to minimise the deposition of ions on the electrodes.

  • \$\begingroup\$ Right now I'm using copper rods with a distance of 1 cm. I'm trying to determine the water level by measuring the resistance of the water at a given height. It doesn't have to be super precise, just good enough to give a rough estimate. \$\endgroup\$ Jun 14, 2021 at 10:39
  • \$\begingroup\$ If you use DC you’ll rapidly corrode one of the rods. In addition, the conductivity depends on impurities in the water. Perhaps consider measuring capacitance using two insulated plates or rods that dip into the water - if you set up an RC oscillator that uses a fairly small capacitor (10 to 100pF) with the immersed plates in parallel you’ll see a drop in frequency as the water level rises. \$\endgroup\$
    – Frog
    Jun 14, 2021 at 19:51
  • \$\begingroup\$ I agree with @Frog -- if you want to measure water level try a capacitive sensor. Just two strips of aluminum foil on the outside of the container like described here: soulysolar.mudventions.com/?p=681 \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 23:13

There are many flaws in your design. A PWM shall not be used, rather a +/- bipolar square pulse voltage. The RC filter as you depicted of course affects the measurement, you need to buffer the input signal with Opamp, first.

You can use a dual voltage PSU, then use and ADC with chopper and external chopper driver, for example AD7730. It drives the external AC excitation bridge and does the filtering and conversion.

You can use analog switches to generate bipolar square pulse or H-bridge. Then you do reverse switch with analog switches the input signal to the opamp buffer/amplifier and do the math in the MCU.

If you don't need the AC excitation, then you can stay with single supply PSU, but without square pulse generator, only DC.


The resistance of the water changed while measuring, probably because the electrodes are displacing the ions.

If you keep the voltage applied I'm sure you'll notice the current change over time.

I think I'd just try something like this:

GPIO1-o ~~~water~~~ o-/\/\/-o-GPIO2
  1. Apply 5V to GPIO1 and 0V to GPIO2, measure the voltage at the point ADC.
  2. Apply 0V to GPIO1 for a while.
  3. Apply 5V to GPIO2, measure the voltage at the point ADC.
  4. Apply 5V to GPIO1 for a while.
  5. Repeat 1 - 4 for as many cycles as you wish.

The ions will be pulled towards the electrodes during the readings. Steps 2 and 4 zero out the potential between the probes allowing the ions to reset back to equilibrium.

Reversing the potential on the probes has the benefit of reducing corrosion.

From the voltage readings you can work out current and then resistance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.