Author Topic: Help with a capacitive wave height sensor  (Read 1266 times)

0 Members and 2 Guests are viewing this topic.

Offline maysTopic starter

  • Contributor
  • Posts: 12
  • Country: ca
Help with a capacitive wave height sensor
« on: July 15, 2026, 01:19:12 am »
Hi! I don't know if this is the right forum for this but my project has some electronics in it. I am an absolute beginner in electronics. I am making a capacitive wave height sensor for a wave flume. I am encountering some problems with what I believe is a temperature drift or something of the sort.

For the electronics, I am using a relaxation oscillator that charges and discharges a capacitor (the probe) and I measure the frequency of the signal by counting the number of signal wave fronts with a Raspberry Pi Pico 2. The frequency is pretty high, in the 200 to 800kHz range (It gives me a better resolution). I compare the measurement with two other reference capacitors to find the "real" capacitance of the probe. I then calibrate it with two points (high and low water level).

Recently I noticed that when I lower the water level and then fill the container up again, the capacitance changes by about 10pF (570 to 560) for the same level. The same thing happens when I leave the container overnight without any changes to the water level. When I come back the next morning it has changed. I'm guessing it's the temperature of the water, since my setup is in a garage and since the water filling up the container is a different temperature from the water already in it. The reference signal wave front counts don't change, only the probe one does, so I don't think the temperature drift is coming from the electronics. I also want to mention that I tried counting the period with the Pi internal clock, which was working well, but I found that there was an even bigger drift (when I was counting the period, the oscillator frequency was way lower, about 20-80kHz, if that's relevant). It could also be something else that's causing this that I haven't thought of.

Obviously, this is a complete flop for a probe that will be used outside where the environment is constantly changing. I'm open to any ideas regarding this problem, or advice for my circuit.
 

Online MariuszD

  • Frequent Contributor
  • **
  • Posts: 682
  • Country: pl
Re: Help with a capacitive wave height sensor
« Reply #1 on: July 15, 2026, 08:13:09 am »
Show us how your probe is constructed. Is it connected with a long cable? What is the maximum and minimum capacitance for the maximum and minimum level you want to measure?
« Last Edit: July 15, 2026, 08:16:32 am by MariuszD »
 
The following users thanked this post: mays

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: au
Re: Help with a capacitive wave height sensor
« Reply #2 on: July 15, 2026, 08:47:54 am »
The reference signal wave front counts don't change, only the probe one does, so I don't think the temperature drift is coming from the electronics.

Do you have a LCR meter where you can measure the capacitance actually seen at the probe?
You can also make some reference caps, with either lengths of shielded cable, or precise caps soldered into plugs, to confirm your Hz-per-pf is not changing.
Humidity can also vary capacitance.
 
The following users thanked this post: mays

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5348
  • Country: nl
Re: Help with a capacitive wave height sensor
« Reply #3 on: July 15, 2026, 09:10:19 am »
How did you build the oscillator? 800kHz may be a bit much, depending on how it's build. I would probably use a much lower frequency, anything between a few hundred Hz and a few kHz. The lower frequency does not make it "less accurate". The relative capacitance change will be the same, no matter which frequency you are using. Frequency can also be measured very accurately with a microcontroller.

Some oscillators are quite sensitive to supply voltage changes.

To test whether water temperature is an important factor. just fill it up with hot water, and keep logging while it cools down. Do note that water contracts when it cools down.
You can also build an overflow. in the bucket, Then you can top it off with either hot or cold water to change the temperature quickly.

Another way to measure water level is with a bubbler. For this, you put a hose in the liquid, and you pump air though it (for example from a blood pressure meter) Then you can measure the air pressure. This method does not have any contact with the liquid. You need the pump to compensate for (small) leaks, and the air dissolving in the water etc. You can also use a pressure gauge at the bottom of the tank (assuming the top is open), but this requires a really good hermetic seal in the pressure sensor.
 
The following users thanked this post: mays

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4163
  • Country: us
Re: Help with a capacitive wave height sensor
« Reply #4 on: July 15, 2026, 09:30:30 am »
Can you post a pic of your setup?

The frequency is pretty high, in the 200 to 800kHz range (It gives me a better resolution).

It seems you are measuring frequency by counting the number of wave fronts in a fixed period of time, eg 1 second. You can also measure frequency by timing how long it takes for a fixed number of wave fronts to occur.

Update: Here's a relatively recent thread on capacitive liquid level sensing:

https://www.eevblog.com/forum/metrology/millimeter-range-water-level-sensor/
« Last Edit: July 15, 2026, 10:17:23 am by ledtester »
 
The following users thanked this post: mays

Online MariuszD

  • Frequent Contributor
  • **
  • Posts: 682
  • Country: pl
Re: Help with a capacitive wave height sensor
« Reply #5 on: July 15, 2026, 10:08:32 am »
The oscillator is not the best circuit for measuring capacitance. Better are circuits that are resistant to parasitic capacitances to ground. In such a configuration, the sensor electrodes can be shielded from external influences and parasitic capacitances.  The effect of the cable's capacitance can also be eliminated.

This circuit has the following properties:

https://www.abcelectronique.com/annuaire/montages/cache/2036/capacimetre.html
« Last Edit: July 15, 2026, 10:10:16 am by MariuszD »
 
The following users thanked this post: mays

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4163
  • Country: us
 
The following users thanked this post: mays

Online MariuszD

  • Frequent Contributor
  • **
  • Posts: 682
  • Country: pl
Re: Help with a capacitive wave height sensor
« Reply #7 on: July 15, 2026, 11:13:39 am »
Another link for this project:

https://nov79.com/cap/cnt.html
That's exactly what I was looking for, but I had trouble finding it.

On this page, there was a description of the experiment using this meter to measure distance:
https://nov79.com/cap/transd.html
However, using it to measure water levels can be difficult.

I didn't build this circuit, but I used the same measurement method. To one electrode, I connected a triangular voltage, and to the other, a transimpedance amplifier. It was possible to measure a capacitance of 60fF between the two electrodes, even tho the capacitance of each to ground was about 10pF. This shows the advantages of the method.

« Last Edit: July 15, 2026, 11:31:10 am by MariuszD »
 
The following users thanked this post: mays

Offline maysTopic starter

  • Contributor
  • Posts: 12
  • Country: ca
Re: Help with a capacitive wave height sensor
« Reply #8 on: July 15, 2026, 01:26:58 pm »
Show us how your probe is constructed. Is it connected with a long cable? What is the maximum and minimum capacitance for the maximum and minimum level you want to measure?

I drew the probe because it won't let me upload a picture. It's a 1.5m insulated wire (first electrode) held by a metallic frame (ground electrode). A coaxial cable connects it to the oscillator. For this probe the capacitance range is about 150pF to 600pF for 0cm to 118cm.
 

Offline maysTopic starter

  • Contributor
  • Posts: 12
  • Country: ca
Re: Help with a capacitive wave height sensor
« Reply #9 on: July 15, 2026, 01:31:37 pm »
The reference signal wave front counts don't change, only the probe one does, so I don't think the temperature drift is coming from the electronics.

Do you have a LCR meter where you can measure the capacitance actually seen at the probe?
You can also make some reference caps, with either lengths of shielded cable, or precise caps soldered into plugs, to confirm your Hz-per-pf is not changing.
Humidity can also vary capacitance.


I don't have an LCR meter unfortunately. For the reference caps, do you mean like a mini probe that would stay in the water? I already have reference capacitors in my circuit, but they are not in the water.
 

Offline maysTopic starter

  • Contributor
  • Posts: 12
  • Country: ca
Re: Help with a capacitive wave height sensor
« Reply #10 on: July 15, 2026, 01:45:30 pm »
How did you build the oscillator? 800kHz may be a bit much, depending on how it's build. I would probably use a much lower frequency, anything between a few hundred Hz and a few kHz. The lower frequency does not make it "less accurate". The relative capacitance change will be the same, no matter which frequency you are using. Frequency can also be measured very accurately with a microcontroller.

Some oscillators are quite sensitive to supply voltage changes.

To test whether water temperature is an important factor. just fill it up with hot water, and keep logging while it cools down. Do note that water contracts when it cools down.
You can also build an overflow. in the bucket, Then you can top it off with either hot or cold water to change the temperature quickly.

Another way to measure water level is with a bubbler. For this, you put a hose in the liquid, and you pump air though it (for example from a blood pressure meter) Then you can measure the air pressure. This method does not have any contact with the liquid. You need the pump to compensate for (small) leaks, and the air dissolving in the water etc. You can also use a pressure gauge at the bottom of the tank (assuming the top is open), but this requires a really good hermetic seal in the pressure sensor.

I attached a picture of my circuit. The reason why I'm using such a high frequency is because I need to measure fast waves (around 1Hz), and if I reduce the frequency, I get less counts for the same measuring time, which gives me a lower resolution (and more noise). I could count for longer, but then it would reduce my sampling rate. I think I could reduce the frequency a bit but I couldn't go as low as a few kHz.

For what you said about the supply voltage change, is using a decoupling capacitor enough?

I only have access to a water point and I can't change the temperature, but I will try filling up the container with new (colder) water and then waiting for it to heat up while measuring the temperature and capacitance.

For the bubbler, I'm not sure this would work in a wave flume, since the water is moving a lot.
 

Offline maysTopic starter

  • Contributor
  • Posts: 12
  • Country: ca
Re: Help with a capacitive wave height sensor
« Reply #11 on: July 15, 2026, 02:17:34 pm »
Can you post a pic of your setup?

The frequency is pretty high, in the 200 to 800kHz range (It gives me a better resolution).

It seems you are measuring frequency by counting the number of wave fronts in a fixed period of time, eg 1 second. You can also measure frequency by timing how long it takes for a fixed number of wave fronts to occur.

Update: Here's a relatively recent thread on capacitive liquid level sensing:

https://www.eevblog.com/forum/metrology/millimeter-range-water-level-sensor/

That's something I already tried, and it seemed to work better (less noise) until I noticed the drift I was talking about. It was a lot bigger than when I was counting the number of wave fronts. I would leave one night to 590pF for 118cm and come back the next morning to 630pf for the same level. The value would then go back down during the day to about 610pF. That's why I assumed it was the temperature, since my setup is in a garage and the temperature would change by about 5 degrees C during the day. I really don't understand why the drift was so much bigger with this method. Thanks for the thread link!
 

Offline KrudyZ

  • Frequent Contributor
  • **
  • Posts: 336
  • Country: us
Re: Help with a capacitive wave height sensor
« Reply #12 on: July 16, 2026, 03:28:21 am »
For what you said about the supply voltage change, is using a decoupling capacitor enough?
It's very easy to measure your sensitivity to supply voltage at least near DC.
I'm assuming you have a variable power supply so you can change your 5 V supply up and down a bit.
Simply measure by how much your frequency readings change as you do this.
RC relaxation oscillators are not great at rejecting power supply variations.
You definitely want to add a regulator or maybe even a reference depending on your drift requirements.
Then add a CMOS buffer between the comparator output and the feedback that is powered from the reference voltage.
This will get you very clean rail to rail switching. The pull-up in the hysteresis bias Tee should also be coming from the reference.
Fast comparators usually have push pull outputs rather than open collector and they won't need the pullup which makes the drive asymmetrical (less of a concern if you add the buffer).
Additionally if the receiver is farther away, then you want a line driver, NOT powered from the clean supply to avoid noise on the transmission line coupling into the measurement.
 
The following users thanked this post: mays

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 17241
  • Country: de
Re: Help with a capacitive wave height sensor
« Reply #13 on: July 16, 2026, 07:33:53 am »
The simple drive and rectifier system also has some weaknesses. E.g. it can be more sensitive to mains hum and other EMI.

The drift problem is likely more from the probe itself. There is not just capacitance to the water, but also to the environment / walls. Here humidity on the surfaces can change things. Also the isolation on the wire can take up some humidity and this way change it's dielectric constant. Over long time there would be a bio-film growing on the sensor wire, that could become an issue. One may need regular cleaning of the wire.

For detecting wave hight the dift may not be that bad, as the drift would be more a DC background.
 
The following users thanked this post: mays

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: au
Re: Help with a capacitive wave height sensor
« Reply #14 on: July 16, 2026, 09:40:39 am »
I don't have an LCR meter unfortunately. For the reference caps, do you mean like a mini probe that would stay in the water? I already have reference capacitors in my circuit, but they are not in the water.

Your variations seem excessive/unexpected, so you should try to duplicate everything except the water, for a zero reference / calibrate path, at least until it becomes predictable.
eg make an identical probe (same cables and dimensions) but mount it above the water as your zero cal.

I attached a picture of my circuit. The reason why I'm using such a high frequency is because I need to measure fast waves (around 1Hz), and if I reduce the frequency, I get less counts for the same measuring time, which gives me a lower resolution (and more noise). I could count for longer, but then it would reduce my sampling rate. I think I could reduce the frequency a bit but I couldn't go as low as a few kHz.
You can also use a reciprocal counter approach to lowering the jitter on the waves.
That counts whole cycles in some minimum gate time, and also captures the time for those whole cycles. you then use Cycles/time calculation.
eg you might count ~ 1Hz for 5 seconds, so 0.9Hz would be captured as 6 cycles in 5.40 seconds, and 1.1 Hz would be captured as 5 cycles in 5.50 sec



 
The following users thanked this post: mays

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 3164
  • Country: gb
  • Recovering Electrical Engineer
Re: Help with a capacitive wave height sensor
« Reply #15 on: July 27, 2026, 09:37:39 am »
The sensor is very susceptible to environmental factors as you say.
See the attached article on how to eliminate some of them.
FDC1004 is great little IC.
It communicates its data over an I2C bus so you need to connect it to a micro controller platform of some sort.

Lots of projects and tech support. Interface to arduino's pi's etc.
Here is a simple project:https://www.hackster.io/team-protocentral/non-contact-capacitive-liquid-level-sensing-using-fdc1004-9333c7
eg see https://protocentral.com/product/protocentral-fdc1004-capacitance-sensor-breakout-board/docs/getting-started/?srsltid=AfmBOorBdXc7n6JpOmIdnA1DN84rpFWFUv5JXq_mCEw1Gwua6BARom-X


I'd also be having a look at LIDAR. Lots of interesting stuff including maritime wave height sensing.
Low cost IR distance sensors abound. eg VL53L8CXV0G, TMF8805, TF-Luna LiDAR Range Sensor etc.
Maybe have a look here: https://www.digikey.co.uk/en/products/filter/distance-measuring/542?s=N4IgTCBcDaIJIDkBiAlAgigogEQATbgGUAVNBAYUxAF0BfIA
« Last Edit: July 27, 2026, 01:55:06 pm by Terry Bites »
 
The following users thanked this post: mays

Offline SteveThackery

  • Super Contributor
  • ***
  • Posts: 3352
  • Country: gb
  • 50 year novice
Re: Help with a capacitive wave height sensor
« Reply #16 on: July 27, 2026, 05:00:46 pm »
I'm sorry if this isnt helpful, but have you considered a different type of sensor? Perhaps an ultrasonic range-finder might be worth looking into.
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1405
  • Country: lt
Re: Help with a capacitive wave height sensor
« Reply #17 on: July 27, 2026, 09:29:33 pm »
I didn’t read the whole thread, but years ago I was working on some capacitive water level sensors and yes, water permittivity is highly dependent on temperature. Basically you also need a thermistor or a thermocouple for temperature measurement and compensation. And even then it will not be 100% stable, cause water might have layers of different temperatures and one point measurement is not perfect.
 
The following users thanked this post: mays


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->