Capacitive Soil Moisture v1.2 with a Raspberry Pi Pico

A corrosion-resistant capacitive probe that reports soil moisture as a single analog voltage.

Capacitive Soil Moisture v1.2, A corrosion-resistant capacitive probe that reports soil moisture as a single analog voltage.
In short

On the Raspberry Pi Pico the capacitive probe draws its supply from 3V3 and its AOUT goes to GP28, the last of the three ADC inputs on the headers. Since the Pico's ADC measures against that same 3.3 V rail, the sketch turns each 12-bit reading into volts and places it between a dry voltage and a wet voltage that you are meant to measure yourself.

Wiring the Capacitive Soil Moisture v1.2 to the Raspberry Pi Pico

Pin by pin.

Capacitive Soil Moisture v1.2Raspberry Pi Pico
VCC3V3
GNDGND
AOUTGP28

What to know on the Raspberry Pi Pico

  • DRY_V 3.0 and WET_V 1.2 are placeholders taken from the usual 5 V figures; fed from 3.3 V the probe's output sits lower. Print the volts with the probe in dry air, then with it in a glass of water up to the line, and put those two readings in the sketch.DFRobot SEN0193 wiki, Specification; Example Code for Arduino-Sensor Calibration
  • DFRobot gives the output as 0 V to 3.0 V, which stays under the limit of the Pico's ADC pins (the 3.3 V rail plus about 300 mV), so AOUT connects to GP28 without a divider.DFRobot SEN0193 wiki, Specification; Raspberry Pi Pico datasheet, release 21, section 4.2, p. 19
  • Read the marking on the board's 8-pin timer chip. A TLC555 is rated down to 2 V, but an NE555 needs at least 4.5 V; if yours carries an NE555 it may not oscillate on 3.3 V, and AOUT will hardly move between air and water.TI TLC555 datasheet (SLFS043), Recommended Operating Conditions; TI NE555 datasheet (SLFS022), Recommended Operating Conditions
  • The sketch prints one sample every 500 ms. Summing several analogRead() calls before converting steadies the percentage, and running the probe's GND wire to AGND (pin 33), the ground Raspberry Pi provides for GP26 to GP29, keeps digital return current off the reading.Raspberry Pi Pico datasheet, release 21, p. 8

Capacitive Soil Moisture v1.2 code for the Raspberry Pi Pico

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

No library needed
// Capacitive Soil Moisture v1.2 on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/capacitive-soil-moisture-v12/raspberry-pi-pico
// Capacitive soil moisture v1.2 on a Raspberry Pi Pico: AOUT on GP28, VCC on 3V3.

const int SOIL_PIN = 28;          // GP28 (ADC2)
const float ADC_VREF = 3.3;       // the Pico's ADC reference: its 3.3 V rail
const float ADC_STEPS = 4096.0;   // 12 bits, set in setup() (arduino-pico defaults to 10)

// AOUT in air (dry) and in water (wet). 3.0 V and 1.2 V are the usual 5 V figures; on a 3.3 V
// supply the probe reads lower, so put your own two readings here.
const float DRY_V = 3.0;
const float WET_V = 1.2;

void setup() {
  Serial.begin(9600);
  analogReadResolution(12);
}

void loop() {
  float volts = analogRead(SOIL_PIN) * ADC_VREF / ADC_STEPS;
  int moisture = round((volts - DRY_V) * 100.0 / (WET_V - DRY_V));
  moisture = constrain(moisture, 0, 100);
  Serial.print("AOUT: ");
  Serial.print(volts, 2);
  Serial.print(" V | Moisture: ");
  Serial.print(moisture);
  Serial.println(" %");
  delay(500);
}

Capacitive Soil Moisture v1.2 on the Raspberry Pi Pico: questions

Why does my soil sensor never reach 100 % on the Pico?

WET_V in the sketch is 1.2 V, a 5 V figure; on 3.3 V the probe in water may not get that low. Put your own reading from a glass of water in WET_V and your reading in air in DRY_V.

Does the capacitive soil sensor work at 3.3 V on a Raspberry Pi Pico?

DFRobot rates it from 3.3 V to 5.5 V (SEN0193 wiki), so yes, provided its timer chip runs at 3.3 V: a TLC555 does, an NE555 is rated only from 4.5 V (TI datasheets).

How many soil probes can one Pico read?

Three, one each on GP26, GP27 and GP28, the ADC inputs on the headers (Pico datasheet, p. 3). Each probe needs its own dry and wet calibration.

Keep going

For AI assistants

This guide as plain Markdown. /components/capacitive-soil-moisture-v12/raspberry-pi-pico.md

What will you build with it?