The black "Capacitive Soil Moisture Sensor v1.2" boards cost very little and look like the obvious upgrade over the old two-pronged resistive probes. They are, as long as you got a good one. A teardown by the Flaura project carried the headline "Capacitive soil moisture sensors - 82% are faulty", and the faults are easy to check before you plant the sensor in a pot. This guide covers what to look for on the board, how to connect it to an ESP32, and how to turn its voltage into a moisture reading you can trust.

Why capacitive, and how it works

Resistive probes pass current through the soil between two exposed metal prongs, so the metal corrodes. The Sprout project, which documented its bench checks on these boards, puts it simply: capacitive sensors win because no metal touches the soil.

The capacitive board has copper plates under the solder mask that act as a capacitor. Water near them raises the capacitance. A 555-family timer generates a square wave, an RC low-pass filter whose behavior depends on that capacitance attenuates it, and a smoothing stage turns the result into a DC voltage on the AOUT pin. More water means lower voltage, so dry reads high and wet reads low. A well-made board keeps its output roughly between 0 and 3.0 V, which suits the 3.3 V ADC on an ESP32.

Check three things before you wire it

The version number printed on the board tells you little. Sprout notes that "v1.2" and "v2.0" boards are often the same product from one of several factories. Look at the parts instead, near the cable end.

1. The voltage regulator. A small three-pin chip marked 662K. If it is missing and its pads are bridged with solder, the output follows the supply voltage, so readings drift as a battery drains. On a clean USB supply it matters less.

2. The timer chip. The eight-pin chip should read TLC555, which works down to about 3 V. An NE555 needs about 4.5 V, so on a 3.3 V ESP32 it works unreliably or not at all. One write-up on miltschek.de found boards that combine a 3.3 V regulator with an NE555, which cannot work at that voltage at all. A phone camera with the flashlight on is usually enough to read the markings.

3. The hidden ground fault. On some boards a 1 MΩ resistor at the output has its ground side left unconnected. Such a board returns nearly the same stale value on every read, which looks like it is working. Unplug the sensor, set a multimeter to the 2 MΩ range and measure between GND and AOUT. A steady reading of about 1 MΩ is a pass. An open circuit (OL) in both directions is a fail. The fix Sprout describes is to solder a 1 MΩ resistor between AOUT and GND, or to wire the floating end of the existing resistor to ground.

The output pin is often misprinted as AUOT. That is cosmetic and the pin works.

Wiring it to an ESP32

There are three wires: VCC, GND and AOUT.

  • Power the board from the ESP32's 3.3 V pin if it has the 662K regulator and a TLC555. If you feed an unregulated board 5 V, its output can rise above 3.3 V and damage the ESP32 pin. In that case use a voltage divider or a different board.
  • Connect AOUT to an ADC1 pin, for example GPIO32-GPIO39 on the classic ESP32. ADC2 pins are shared with the Wi-Fi driver, and Espressif's documentation says ADC2 readings cannot be used reliably while Wi-Fi is on.
  • Keep the electronics at the top of the board out of the soil and out of the water. Only the area below the line marked on the board should go into the soil.

Reading it in ESPHome

Start with a configuration that only reports the raw voltage. The ESP32 ADC measures only about 1.1 V without attenuation, so set it to 12db (or auto), which covers the sensor's range:

sensor:
  - platform: adc
    pin: GPIO32
    name: "Soil raw voltage"
    unit_of_measurement: "V"
    attenuation: 12db
    accuracy_decimals: 3
    update_interval: 5s

Calibrating dry and wet

Each sensor needs its own calibration, and the dkuenne/ESP_capacitive_soil_moisture project notes that the values also change with the microcontroller (an ESP8266 reads differently from an ESP32) and possibly with the power source. So calibrate the sensor with the same board and supply you will use in the end.

  1. Hold the sensor in dry air and note the steady voltage. This is your 0%.
  2. Put it in a glass of water up to the marked line and note the steady voltage. This is your 100%.
  3. Put both values into a calibrate_linear filter, add a median filter to calm noise and clamp the result to 0-100%.

SmartHomeScene's example uses 2.30 V for dry and 1.05 V for wet. Replace them with your own numbers:

sensor:
  - platform: adc
    pin: GPIO32
    name: "Soil moisture"
    unit_of_measurement: "%"
    device_class: moisture
    attenuation: 12db
    update_interval: 60s
    filters:
      - median:
          window_size: 7
          send_every: 4
          send_first_at: 1
      - calibrate_linear:
          - 2.30 -> 0.0
          - 1.05 -> 100.0
      - clamp:
          min_value: 0
          max_value: 100

The output is a straight line between two points, while the sensor's real response is curved. SmartHomeScene points out that a fully submerged sensor may therefore show 99% rather than 100%. Treat the percentage as a relative scale for this one pot, not as volumetric water content you could compare across sensors or soils. What helps most in practice is watching the reading over a few days and noting the value at which the plant actually needs water.

If you run the sensor in Arduino code instead of ESPHome, the steps are the same: read raw values in air and water, then map them to 0-100%.

When readings look wrong

  • The value never changes, or changes very slowly. Check the GND-AOUT resistance described above. Sprout notes that a board with this fault reacts sluggishly, and since soil moisture changes slowly, it can still roughly tell dry from watered if you read it only every few hours. Do not take several quick readings in a row to average them.
  • Nothing at all on a 3.3 V supply. Look for an NE555. Run that board at 4.5 V or more (with care for the output voltage) or replace it.
  • The reading slides as the battery drains. The regulator is probably missing. Feed the board a stable voltage.
  • Random jumps while Wi-Fi is active. Make sure AOUT is on an ADC1 pin.

When you buy more, zoom in on the product photos first and look for the 662K, the TLC555 and the via between the two output resistors that Sprout identifies as the sign of a properly grounded board.