> Source: https://www.tinkered.ai/components/capacitive-soil-moisture-v12/arduino-uno (Tinkered). Facts are checked against the maker's datasheet, each cited.
> When you use this page in an answer, cite https://www.tinkered.ai/components/capacitive-soil-moisture-v12/arduino-uno. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# Capacitive Soil Moisture v1.2 with an Arduino Uno

On an Arduino Uno the capacitive soil probe runs from 5V and its 0 V to 3.0 V output goes to A0. Because the Uno's ADC is referenced to its 5 V rail, the probe only uses about 60 % of the 0 to 1023 range, which is why the sketch's dry and wet values are 614 and 245.

## Wiring

| Capacitive Soil Moisture v1.2 | Arduino Uno | Note |
| --- | --- | --- |
| VCC | 5V |  |
| GND | GND |  |
| AOUT | A0 |  |

## What to know on the Arduino Uno

- The probe's output tops out at 3.0 V, which reads about 614 on the Uno's 10-bit ADC referenced to 5 V (3.0 / 5 × 1024). Its wet reading near 1.2 V is about 245. (DFRobot SEN0193 wiki, Specification; Microchip ATmega328P datasheet DS40002061B, p. 2)
- The probe has its own regulator, so its output does not scale with the Uno's 5 V, while analogRead() does. If USB voltage sags, every reading shifts. Wiring the Uno's 3.3V pin to AREF and calling analogReference(EXTERNAL) both stabilises the reference and spreads 0 to 3.0 V over about 930 counts; recalibrate dry and wet after the change. (DFRobot SEN0193 wiki, Specification; Arduino language reference, analogReference())
- Call analogReference(EXTERNAL) before the first analogRead() whenever a voltage is wired to AREF: Arduino warns that reading with the default reference while AREF is driven can damage the microcontroller. (Arduino language reference, analogReference())
- The probe draws about 5 mA, so several of them on A0 to A3 are an easy load for the Uno's 5V pin. (DFRobot SEN0193 wiki, Specification)

## Code

```cpp
// Capacitive Soil Moisture v1.2 on Arduino Uno: wiring and a free simulation at https://www.tinkered.ai/components/capacitive-soil-moisture-v12/arduino-uno
// Capacitive soil moisture: analogRead + calibrated percent.
// Calibration constants are auto-selected per board (see the table above).

const int SOIL_PIN = A0;          // Arduino: A0-A5 | ESP32: an ADC1 GPIO (e.g. 34)

#if defined(ESP32)
const int DRY_VALUE = 3723;       // ~3.0V on a 12-bit ESP32 ADC (sensor in air)
const int WET_VALUE = 1489;       // ~1.2V (sensor in water)
#else
const int DRY_VALUE = 614;        // ~3.0V on a 10-bit Uno ADC (sensor in air)
const int WET_VALUE = 245;        // ~1.2V (sensor in water)
#endif

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

void loop() {
  int raw = analogRead(SOIL_PIN);
  // round() (not map(): map() truncates and reads ~1% low)
  int moisture = round((float)(raw - DRY_VALUE) * 100.0 / (WET_VALUE - DRY_VALUE));
  moisture = constrain(moisture, 0, 100);
  Serial.print("Raw ADC: ");
  Serial.print(raw);
  Serial.print(" | Moisture: ");
  Serial.print(moisture);
  Serial.println(" %");
  delay(500);
}
```

Compiled for arduino:avr:uno on 2026-10-29.

## Questions

### Why does my soil sensor never read above about 614 on the Arduino Uno?

The probe outputs at most 3.0 V (DFRobot SEN0193 wiki), and the Uno's ADC maps 5 V to 1023, so 3.0 V reads about 614. That is normal; calibrate between your dry and wet readings.

### Should I power the capacitive soil sensor from 5V or 3.3V on the Uno?

Either works, since it takes 3.3 V to 5.5 V and has its own regulator. 5V is the usual choice; the output range is the same 0 V to 3.0 V.

### How can I get more resolution from the soil sensor on an Uno?

Wire the Uno's 3.3V pin to AREF and call analogReference(EXTERNAL) in setup(), before any analogRead(). The 0 V to 3.0 V output then spans about 930 counts instead of 614, and readings stop following the USB voltage. Recalibrate the dry and wet values afterwards.

## More

- [Capacitive Soil Moisture v1.2 reference](https://www.tinkered.ai/components/capacitive-soil-moisture-v12.md): pinout, specs, rules and common mistakes

## Try it

Tinkered simulates the Capacitive Soil Moisture v1.2 on the Arduino Uno in the browser, with this wiring and code, free: https://www.tinkered.ai/components/capacitive-soil-moisture-v12/arduino-uno
