Blogs
Capacitive Soil Moisture Sensor
Capacitive Soil Moisture Sensor
Corrosion-Resistant Humidity Detection for Plants and Agricultural Applications
Introduction
The Capacitive Soil Moisture Sensor measures water content in soil by detecting changes in capacitance rather than resistance (like traditional probes). This makes it resistant to corrosion and provides more accurate, long-lasting measurements for smart gardening and agricultural systems.

Key Features
Corrosion Proof
No exposed metal electrodes
Accurate Measurement
0-100% volumetric water content
Easy Interface
Analog or digital output
Plant Safe
Low power consumption
Technical Specifications
Operating Voltage | 3.3V – 5.5V DC |
---|---|
Output Signal | Analog 0-VCC (also digital option) |
Measurement Range | 0% (dry) to 100% (water) |
Probe Material | Corrosion-resistant PCB |
Current Consumption | <5mA during measurement |
Interface | 3-pin (VCC, GND, OUT) |
Dimensions | 60mm × 20mm × 5mm |
Cable Length | 1.5m (standard) |
Pin Configuration

Wire Color | Function | Arduino Connection |
---|---|---|
Red | VCC | 3.3V/5V |
Black | GND | GND |
Yellow | OUT | Analog Pin (A0-A5) |
Wiring with Arduino
1 2 3 4 |
// Basic Connection: // Red → Arduino 5V // Black → Arduino GND // Yellow → Arduino A0 |
Basic Reading Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
const int sensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(sensorPin); int moisturePercent = map(sensorValue, 0, 1023, 0, 100); Serial.print("Raw Value: "); Serial.print(sensorValue); Serial.print(" | Moisture: "); Serial.print(moisturePercent); Serial.println("%"); delay(1000); } |
Calibration Procedure
- Dry Calibration: Measure sensor in completely dry soil (record value as 0%)
- Wet Calibration: Measure sensor submerged in water (record value as 100%)
- Update Code: Adjust map() function with your calibration values
1 2 |
// After calibration: int moisturePercent = map(sensorValue, dryValue, wetValue, 0, 100); |

Advanced Usage
Auto Watering System
1 2 3 4 5 |
if(moisturePercent < 30) { digitalWrite(relayPin, HIGH); delay(2000); digitalWrite(relayPin, LOW); } |
Data Logging
1 2 3 4 |
#include <SD.h> File dataFile = SD.open("datalog.txt", FILE_WRITE); dataFile.println(moisturePercent); dataFile.close(); |
Wireless Monitoring
1 2 3 4 |
#include <ESP8266WiFi.h> WiFiClient client; client.print("GET /update?field1="); client.print(moisturePercent); |
Troubleshooting
Inconsistent Readings
- Ensure good soil contact around probe
- Check for air pockets near sensor
- Re-calibrate for your soil type
Always Shows 100%
- Verify wiring (possible short circuit)
- Check sensor for physical damage
- Test with different power supply
No Response
- Confirm power supply connections
- Check analog pin assignment
- Test with multimeter for output voltage