Using Capacitance For Extremely Sensitive Proximity Sensing

A man's hand is holding a thin wooden board, which runs between two vertical metal plates. On the board are two glasses, one filled with water. A computer screen is behind all this, showing a series of white bars. The series of bars shows two peaks.

Capacitive displacement sensors span a wide range of resolution, from the touchscreen sensors which can only detect displacement as a binary state, all the way to the sensors in semiconductor fabs which measure down to nanometers. The sensor [Matthias Wandel] built with a Raspberry Pi Pico lands somewhere in the middle, providing both sensitive measurements and an absolute scale.

The idea is that the amount of overlap between two metal plates should be detectable by measuring the capacitance between them. Reaching any kind of usable resolution would require a very precise measure of capacitance, around the picofarad range. [Matthias] realized that the Pico’s GPIO pins have an inherent capacitance, and can have a pull-down resistor set, essentially creating an RC circuit. [Matthias] would set a pin to a high-level output, then switch it to an input. The amount of time the pin takes to switch from high to low indicates the RC constant, which includes the capacitance attached to the pin.

When attached to a metal plate, the Pico was sensitive enough to detect the plate’s capacitive coupling to [Matthias]’s hand through a thick wooden floor. To measure capacitance between two metal plates, the Pico measured how well a voltage signal applied to one plate was coupled to the other plate. This was sensitive enough to measure the slight change in the dielectric constant when [Matthias] waved a piece of ABS pipe between the two capacitor plates. Making actual position measurements was tricky, since capacitance changed with both X- and Z-axis shifts in the plates.

Digital calipers use similar capacitive sensors to make their measurements, as [Matthias] knows from his experiments in hacking them. If you’re interested in more details, check out this teardown of some cheap digital calipers.

Thanks to [H Hack] for the tip!

17 thoughts on “Using Capacitance For Extremely Sensitive Proximity Sensing

  1. Very hacky – I like it!
    And somewhat related I had this idea but not the motivation to do anything with it (and it’s based on prior work):
    1. Using two large touch “plates” (capacitive touch screen thingies without the screen) to detect conduits, pipes, etc. in walls (no, drywalls are not walls in this context, I meant stone/brick walls).

    Or maybe two metal plates producing an electric filed (DC, AC, sweeping, square???) inside the wall from the same side and one touch “plate” in between to visualize how the field de-forms?
    One metal and one touch sensor “plate” and the sensor plate is the other electric pole (metal plate behind it?).

    There’s a commercial product that does half of 1. but I think only for drywalls (last time I checked).
    And I think there was a HaD article on this idea a bunch of years back. Basically a RaspberryPi + a touch sensor plate + the software reading and visualizing the raw data from that sensor plate.

    I have no idea if any of that would work but considering how sensitive this hack here seems to be….

    1. Thanks for sharing. I’m wondering if I could use it to measure the level in my wine and/or beer keg. It’s only 5 gallons though?

      1. It’s not difficult to do, you can basically get away with a piece of twin-lead wire inside the keg. If the keg is not metal, even taped to the outside of the keg. The challenge is interpreting the results correctly, since the dielectric properties of whatever is in the keg will vary.

        If it’s always the same stuff, like diesel fuel in a tank, then you can get away with simple temperature compensation. If it might be water or wine, you need a reference electrode at the bottom to figure out how a full/empty keg should measure.

      2. you might have trouble measuring a conductive liquid, since the material being measured in this case is acting as the dielectric — wine would be conductive enough that your capacitor would act more like a resistor. you could measure resistance, but in so doing you would be causing electricity to flow through your, say, wine, and ions from the two copper plates would dissolve into the wine, making it taste different among other things.

        1. The copper doesn’t need to be in contact with the liquid.

          If your electrodes are covered with something, like a thin layer of plastic, and you dunk them in a perfectly conductive liquid, this acts as if the dielectric you’re measuring is only the thickness of the covering plastic. In fact, what you would be measuring is the dielectric properties of the plastic and not the liquid.

          It’s as if you brought the “plates” closer together, which actually makes it easier to detect the liquid because there’s more of a contrast between air and the liquid you’re measuring.

          But you need to know how much the liquid will change your capacitance reading, which is why proper liquid level sensors have an extra electrode at the bottom to measure a known unit volume of the liquid. If we call this capacitance C_r and the capacitance measured from the actual probe C_p, then the liquid level in the container should be roughly C_p / C_r relative to the size of the reference electrode.

      3. if the container is non conductive, you can get away with two copper strips glued to the outside of the container. had good results with this setup for water level sensing.

  2. I’m reminded of “rctime” on the BASIC Stamp which utilize the exact same principle as a crude ADC.

    Now I feel old 😅

  3. This isn’t really a capacitance measurement right? To ionize air you need kvs of potential for even like a few millimeters of distances let alone 15cm. I think this is more like an ungrounded antenna picking up on the electric fields near by. I would be curious to see what happens if they removed the vout plate entirely.

    I could be very wrong if course, but I think this is allo about the static electricity of the objects nearest the analog pin. Anyone fresher on their electrostatics than me?

    1. You don’t need to ionize air to measure capacitance. On the contrary, if you do ionize air, you’re measuring something else entirely.

      1. Yea wow I had to open my ancient e&m book. For some reason I thought the dielectric medium had to allow charge transfer. Embarrassing. Thankfully my professor passed away years ago.

    2. Think of the air-dielectric tuning capacitors in classic radios, in which the capacitance is changed by varying the offset between moving and stationary plates. The capacitance can also be varied by changing the distance between plates, such as in compression capacitors; anything in the electrostatic field varies the capacitance. The use of ionization is not necessary.

  4. So they reinvented the theremin. Cool, I wonder if they have tried to use this device for music performance yet.

    To clarify, Lev theremin was originally trying to make a capacitive proximity sensor (for the KGB I think) where one of the capacitor “plates” was a human.

    Then he realized that he could use it as a musical instrument. And since nobody had yet made an electronic music instrument before, he doubled down on that use.

Leave a Reply to Gus MuellerCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.