Raphael Profile picture

Mar 3, 2021, 13 tweets

Here’s the fascinating way these capacitive soil moisture sensors work.

If we stick them in the ground, we can monitor the moisture level in the soil via its analog output. It spits out a voltage that is proportional to how wet the soil is.

At its heart, it packs a humble resistor and capacitor circuit, like this one.

If we apply a positive voltage to the input, the capacitor C starts to charge up. In an RC circuit like this one, the voltage across the capacitor keeps increasing until it reaches the input voltage. It always follows this characteristic exponential curve:

We can control how fast or slow the capacitor charges up by varying the values of the resistor and capacitor. For example, if we keep the same resistor and try out two different capacitor values, we get:

Intuitively, the larger capacitor (with larger capacitance) requires more charge units to reach the input voltage, and so it takes longer to charge up.

Back to the sensor board. The astonishing part is that the capacitor C in the sensor is not a "real" capacitor. It is, instead, a very crude one, formed by just two copper traces on the board. If we look at it at just the right angle, we can make the large traces out:

If we apply a voltage between these two copper traces, positive charge will start accumulating on the positive side, just like in a regular capacitor, until it reaches the applied voltage.

This parasitic capacitance is usually tiny and undesirable, but this type of sensor cleverly exploits this cool phenomenon by making these copper traces deliberately big.

The last piece of the puzzle is the actual capacitance value of this ghost capacitor. It turns out that the capacitance is a function of the shape of the capacitor (the fixed copper traces) _and_ the material around it. You guessed it - vary the material, vary its capacitance:

When surrounded by water, the parasitic capacitance is larger - it needs more charges to charge up, so its voltage increases slowly, exactly like the slow sketch curve above.

Additionally, instead of a single pulse, the sensor inputs an alternating square signal to the RC circuit, which is why we see the capacitor charging and discharging multiple times in the scope.

The remaining components in the sensor board are responsible for generating the alternating input signal (a 555 IC) and extracting the peak values from the capacitor charging curve - which is what the sensor ultimately outputs.

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling