Capacitive liquid level sensing and shielding using arduino

Hello,

I have been working on a project for a while now where I want to measure the level of fluid in a cup using capacitive measurements.
The way I have managed to do it so far is by using 2 digital pins on the arduino and Gnd.
One pin is controlled by a pwm and goes through a resistor to an electrode made of copper tape attached to the side of a plastic cup. From there a wire is connected to the other digital pin.
The other electrode is just connected to gnd.
For the software I used the library: GitHub - PaulStoffregen/CapacitiveSensor: Detect touch or proximity by capacitve sensing
You can read more about how the concept works here: Arduino Playground - CapacitiveSensor

The problem with this is even though I get capacitive changes when I pour water into the cup, the measurements are very receptive against parasitic capacitance such as a hand that gets nearby or other environmental capacitance affecting the sensor.

When you make 2 electrodes like this it creates an electric field around the electrode which indicates the sensing area. This area needs to be directed into the cup. This way the sensor will only detect the capacitance from that area which in this case would be the water.

I have read about a way to shield these parasitic capacitance by placing another electrode on top of the 2 electrodes already attached and sending an opposite clock into those electrodes. Its called AC-shielding. So far I have managed to make the clock but it doesn't seem to work. Does anyone have any experience in this area or know how to setup a shield to get more accurate measurements?

Thanks in advance! :slight_smile:

Most tricky problems in electronics can be improved by going to a differential scheme. Differential
signals tend to cancel out unwanted interference from the surroundings nicely.

It does mean more hardware, so two strips and two wires, driven in antiphase. It may be the
ac-shielding you mention is a form of differential cancellation too.

To work, the shield must be at the same potential as the sensor.

See also this thread. I haven't continued the experiments since, at the time lack of proper parts in my tool kit, and since forgotten.

You have to drive the shield through an OpAmp wired as voltage follower, so it is always at the same potential as the probe itself. That cancels the electrical field on that side and shields it from external factors such as your hand, the wires to the probe, etc.

Okay. I know it's been a while since you did your experiment and may seem a little far behind now.
But I see you mentioned early in the thread you linked to that u tried using the capSense library from Poul Badger.
This is the library I am trying to use. I'm interested in the way you did it hardware wise. The timer, I believe, was just to make a frequency and then you use an opamp to keep the voltage at the same potential. I have tried to do that through the Capsense library and when I use a scope to measure the output my shield pin and send pin on my arduino, I get 2 clocks with 180 degree phase to each other.
As I understand it through reading about the fdc1004, this is the way to make proper shielding, but it still doesn't work. I have attached a picture of how my test experiment looks like. Also, I have attached the code, which is the CapSense library but with a few changes, in order to make the shield.
I'm not sure if it is the code or if I have misunderstood how the active shielding works. Or maybe both.

I don't remember using the capsense library, but it's been a long time. The hard part is to actually keep the shield at the same (falling!) potential as the test plate, which is where the OpAmp comes in play. As said, I never had the active shielding actually working.

About your experiment, I can't say much. No idea what that scope picture shows (it completely lacks annotation), no code, no schematic.

I'm sorry.
The scope picture was just to show you that I made a 180 deg phased signal through the capSense library. Not really important though. I couldn't attach my code because it was to long, so instead I have linked to a github, where you should be able to find it. If not, please let me know.: GitHub - MolleD/Capacitive-Liquid-level-Sensing

As far as schematic, I have an illustatration of how I made my setup which should be attached to this post, but unfortunately I don't have any actual schematic scheme to show you.

That image shows me two capacitive sensors, placed in parallel close together. No active shield in sight, and with this arrangement you can count on them affecting each other big time.

The arrows indicate that they are on top of each other. I drew it this way because it was easier to draw. There is dielectric material between the 2 sensors (Shield and Level). I was just trying to illustrate to you how my setup was made and what my idea was. But if you haven't worked with the capSense library then nevermind. I was just hoping to get some ideas of some kind on how to fix it. :slight_smile:

It also misses a proper circuit: no active shield in sight.

The whole point of active shielding is to keep the shield at the same potential as the sensing strip - where that potential is changing during the measurement! Just taking two capacitive sensors and plunking one on top of the other is not going to give you good results. The two will be at different potential, and as a result they start to interact with each other, and that's exactly what a driven active shield is trying to prevent.