Why Capacitive Over Resistive?
Older resistive soil sensors corrode within weeks because they pass current through the soil. Capacitive sensors measure the dielectric constant of the soil instead — no exposed metal contacts in the soil, so they last years. The module outputs an analog voltage between 0 V (submerged) and ~3 V (bone dry) which maps neatly to Arduino's 10-bit ADC.
The relay acts as a high-current switch to run the 5V pump from a separate power rail, so the Arduino never sources pump current directly.
⚠️ Warning
Power the submersible pump from a dedicated 5V 1A power supply — NOT from the Arduino's 5V pin, which is limited to 500 mA from USB. Sharing power rails will brown-out the board and cause erratic ADC readings.
Components
8 itemsNeed these parts? Get this build sheet by email
Parts list with buy links, plus new builds as they're published. By subscribing you agree to our Privacy Policy. Unsubscribe anytime.
Wiring
Soil sensor: VCC → 3.3V, GND → GND, AOUT → A0.
(Using 3.3V prevents the ADC from saturating near 0 when submerged)
Relay module: VCC → 5V (Arduino), GND → GND, IN → D7.
NO terminal of relay → pump positive; COM terminal → external 5V supply positive.
Pump negative → external 5V GND (share GND with Arduino).
OLED (I2C): VCC → 3.3V, GND → GND, SDA → A4, SCL → A5.
Live simulation
Steps
- 1Install libraries: Adafruit GFX and Adafruit SSD1306 via Library Manager
- 2Wire the sensor to 3.3V (not 5V) to prevent ADC saturation
- 3Power the pump from a separate 5V 1A supply through the relay
- 4Run the sketch and open Serial Monitor — note the raw ADC value in open air (AIR_VALUE) and when submerged (WATER_VALUE)
- 5Update both calibration constants in the sketch and re-upload
- 6Insert sensor into dry soil — pump should trigger below 40% moisture and stop at 70%
- 7Adjust DRY_THRESHOLD and WET_THRESHOLD to suit your plant species