Capacitive soil moisture sensor

The black "Capacitive Soil Moisture Sensor v1.2" stake: three pins at the head, no bare metal in the soil. Aliases: soil sensor, moisture sensor, plant sensor.

The older soil sensor was two bare prongs with a current through them, and it dissolved in a few weeks of wet soil. This one is a capacitor under the solder mask. Wet soil round it raises its capacitance, a 555 on the board runs a megahertz square wave into it, and what is left of the wave is filtered into a DC voltage on AOUT. More water means more capacitance and a lower voltage, which is the opposite of what everyone expects the first time.

Pins

Pin What it does
GND Ground.
VCC Supply, 3.3 V to 5.5 V.
AOUT The reading: about 2.55 V in air, about 1.27 V in water.

Properties

dry is what AOUT reads held in the air, 2.55 V by default. wet is what it reads with the stake in a glass of water, 1.27 V by default. On a 5 V Arduino those come out near 520 and 260, the two numbers every calibration sketch measures first.

While it runs

Drag the slider to water the soil: 0% is the stake in the air, 100% is in water. The earth round the tip darkens as it gets wetter.

What the model gets right

The board has its own 3.3 V regulator, so the reading does not follow the supply: the same soil reads the same voltage on a 5 V Uno and a 3.3 V Pico. Wetter reads lower. Below 3 V the board is not running and AOUT is not driven.

What it does not model

The model is a straight line between dry and wet. A real stake's reading against the soil's actual water content is a curve, it changes from one soil to another, and two sensors from the same bag differ by more than a whole watering. That is why every real project calibrates its own sensor against dry and soaked soil and maps between the two with map(); the slider here is that mapping's scale, not grams of water.

Not modeled either: how slowly the reading settles (the filter on the board takes a second or so after power), temperature, salt in the soil, and the faults of the cheap clones, such as a missing regulator or a 555 that will not run on 3.3 V. AOUT comes out through 10 k, standing in for the filter it passes through.

Common mistakes

Expecting a bigger number for wetter soil. Map it the other way around: map(reading, 520, 260, 0, 100) gives 0% dry and 100% wet.

See it in action

Plant monitor reads this sensor, the rain sensor and the water level sensor on one Uno. Open it at /templates.