# RC filter after voltage divider

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:

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?

• What's the separation between your probes? Commented Jun 14, 2021 at 10:09
• 1cm, but I can my setup if that will solve any problems Commented Jun 14, 2021 at 10:40
• Here are some videos showing the 3 main conductivity measurement methods: youtube.com/watch?v=5qxenj3NpE0 youtube.com/watch?v=sVcG65dMZfk Commented Jun 14, 2021 at 10:46
• How are you establishing your virtual ground? Commented Jun 14, 2021 at 10:49
• 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. Commented Jun 14, 2021 at 10:52

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.

• 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. Commented Jun 14, 2021 at 10:39
• 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.
– Frog
Commented Jun 14, 2021 at 19:51
• 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 Commented 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:

                        R
GPIO1-o ~~~water~~~ o-/\/\/-o-GPIO2
|