Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.
Soil Moisture Sensor Arduino: Complete Guide to Garden Monitoring
Keeping plants properly watered has always been more art than science for most gardeners. After integrating dozens of soil monitoring systems into automated greenhouse projects, I can tell you that a Soil Moisture Sensor Arduino setup transforms guesswork into precise data-driven irrigation.
These sensors measure the volumetric water content in soil and output signals that any microcontroller can interpret. Whether you’re protecting a single houseplant from neglect or managing an entire vegetable garden, understanding how to properly interface and calibrate these sensors makes the difference between thriving plants and disappointment.
This guide covers everything from basic sensor theory to building a complete automatic watering system. By the end, you’ll have the knowledge to select the right sensor for your application and implement reliable garden monitoring with Arduino.
How Soil Moisture Sensors Work
Soil moisture sensors exploit the relationship between water content and electrical properties of soil. Two primary measurement methods exist: resistive and capacitive. Understanding both helps you choose the right sensor for your project.
Resistive Soil Moisture Sensors
Resistive sensors use two exposed metal probes that function as electrodes. When inserted into soil, they measure electrical resistance between the probes. Water conducts electricity, so wet soil has low resistance while dry soil has high resistance.
The sensor module includes an LM393 comparator chip that processes the raw resistance measurement and outputs both analog and digital signals. The analog output provides continuous voltage proportional to moisture level, while the digital output triggers HIGH or LOW based on a threshold set by the onboard potentiometer.
The problem with resistive sensors is electrolysis. Current flowing between the probes causes the metal to corrode over time, especially when the sensor remains powered continuously. Most resistive sensors degrade noticeably within 6-12 months of regular use.
Capacitive Soil Moisture Sensors
Capacitive sensors measure the dielectric constant of surrounding soil rather than its conductivity. The sensor PCB has copper traces that form a capacitor, with soil acting as the dielectric material between them. Since water has a much higher dielectric constant than dry soil (~80 vs 2-6), moisture significantly affects capacitance.
A 555 timer circuit on the sensor board generates a square wave and measures how quickly a capacitor charges. Higher soil moisture means higher capacitance, which produces lower output voltage. The electronics remain sealed, with no exposed metal contacting the soil directly.
This design eliminates corrosion issues and typically lasts 2-5 years. The tradeoff is slightly higher cost and sensitivity to factors beyond moisture, including soil density, temperature, and nearby electromagnetic interference.
Resistive vs Capacitive Sensor Comparison
Feature
Resistive Sensor
Capacitive Sensor
Price
$2-5
$5-15
Lifespan
6-12 months
2-5 years
Accuracy
±5-10%
±3-5%
Corrosion
Significant issue
Minimal
Output Type
Analog + Digital
Analog only
Response Time
Instant
Instant
Temperature Sensitivity
Moderate
Low
Salinity Sensitivity
High
Low
Power Consumption
Higher
Lower
Best For
Short-term projects, learning
Long-term installations
For hobby projects and learning, resistive sensors work fine. For any installation you expect to run more than a few months, invest in capacitive sensors.
Soil Moisture Sensor Arduino Specifications
Here are typical specifications for common sensor models:
Resistive Sensor (YL-69/FC-28) Specifications
Parameter
Value
Operating Voltage
3.3V – 5V DC
Operating Current
~35 mA
Output Voltage
0V – 4.2V (analog)
Digital Output
HIGH/LOW (adjustable threshold)
PCB Dimensions
30mm x 16mm
Probe Dimensions
60mm x 20mm
Detection Depth
Up to 38mm
Interface
4-pin (VCC, GND, AO, DO)
Capacitive Sensor (v1.2/v2.0) Specifications
Parameter
Value
Operating Voltage
3.3V – 5.5V DC
Operating Current
~5 mA
Output Voltage
1.2V – 3.0V (analog)
Output Type
Analog only
PCB Dimensions
98mm x 23mm
Insertion Depth
Up to 70mm
Interface
3-pin (VCC, GND, AOUT)
Onboard Regulator
3.3V LDO
Note that some cheap capacitive sensors replace the voltage regulator with a resistor, causing output to vary with supply voltage. Check your sensor board before assuming stable operation.
Soil Moisture Sensor Arduino Wiring
Both sensor types connect easily to Arduino, though pin configurations differ slightly.
Resistive Sensor Wiring
Sensor Pin
Arduino Pin
Function
VCC
5V or D7*
Power supply
GND
GND
Ground
AO
A0
Analog output
DO
D8
Digital output (optional)
*Powering through a digital pin allows you to turn the sensor on only when taking readings, significantly extending lifespan.
Capacitive Sensor Wiring
Sensor Pin
Arduino Pin
Function
VCC
3.3V or 5V
Power supply
GND
GND
Ground
AOUT
A0
Analog output
For capacitive sensors, 3.3V power provides better ADC resolution since the output range (1.2V-3.0V) stays within the reference voltage.
Basic Soil Moisture Sensor Arduino Code
Here’s tested code for reading analog soil moisture values:
Upload this code, open Serial Monitor at 9600 baud, and observe how readings change when you insert the sensor into dry versus wet soil.
Calibrating Your Soil Moisture Sensor
Raw analog values (0-1023) mean nothing without calibration. You need to determine what values correspond to “dry” and “wet” for your specific sensor and soil type.
Calibration Procedure
Measure Dry Value: Hold the sensor in open air (completely dry). Record the reading.
Measure Wet Value: Submerge the sensor in a glass of water (just the probe area for capacitive sensors). Record the reading.
Calculate Range: Note minimum and maximum values for mapping.
For resistive sensors, dry readings are typically HIGH (800-1023) and wet readings are LOW (200-400). Capacitive sensors work inversely—dry produces higher values (~600) and wet produces lower values (~300).
If you’re using resistive sensors, these techniques significantly extend their usable life:
Power Control Method
Instead of keeping the sensor constantly powered, supply voltage only during readings:
// Soil Moisture Sensor Arduino – Power Control
// Powers sensor only when reading to reduce corrosion
const int sensorPin = A0;
const int sensorPower = 7; // Control sensor power
void setup() {
Serial.begin(9600);
pinMode(sensorPower, OUTPUT);
digitalWrite(sensorPower, LOW); // Start with sensor OFF
}
void loop() {
// Power ON sensor
digitalWrite(sensorPower, HIGH);
delay(100); // Allow sensor to stabilize
// Take reading
int moistureValue = analogRead(sensorPin);
// Power OFF sensor immediately
digitalWrite(sensorPower, LOW);
Serial.print(“Moisture: “);
Serial.println(moistureValue);
delay(60000); // Wait 1 minute before next reading
}
This approach can extend resistive sensor life from months to years by minimizing electrolysis exposure.
Optimal Sensor Placement for Gardens
Proper placement dramatically affects reading accuracy and usefulness:
Plant Type
Recommended Depth
Placement Notes
Houseplants
2-3 inches
Center of pot, mid-root zone
Vegetables
4-6 inches
Between plants, not at edge
Lawn/Turf
3-4 inches
Multiple sensors for coverage
Trees/Shrubs
6-12 inches
Near drip line, not trunk
Raised Beds
4-6 inches
Center of bed, away from edges
Avoid placing sensors near irrigation drip points, in compacted soil, or where water pools. These locations give misleading readings that don’t represent the overall root zone moisture.
Troubleshooting Common Problems
Readings stuck at maximum or minimum: Check wiring connections. Verify sensor isn’t damaged. For capacitive sensors, ensure the probe portion (below warning line) is inserted into soil, not the electronics portion.
Erratic or jumping readings: Add a small delay after powering the sensor before reading. Average multiple readings:
int getAverageMoisture(int samples) {
long total = 0;
for (int i = 0; i < samples; i++) {
total += analogRead(sensorPin);
delay(10);
}
return total / samples;
}
Readings drift over time: For resistive sensors, this indicates corrosion. Clean probes with fine sandpaper or replace sensor. For capacitive sensors, recalibrate—temperature and soil composition changes affect baseline readings.
Capacitive sensor not responding to moisture changes: Some cheap sensors have manufacturing defects. Test by measuring output voltage directly—it should change between air and water. If not, the sensor is defective.
Different readings in same soil: Soil moisture varies significantly over small distances. This is normal. Use multiple sensors and average readings for better accuracy.
No special library required—sensors use analogRead()
LiquidCrystal: For LCD display projects
EEPROM: For storing calibration values
WiFi/ESP8266: For IoT monitoring projects
Project Resources
SparkFun Soil Moisture Sensor Hookup Guide
Last Minute Engineers Capacitive Sensor Tutorial
Seeed Studio Grove Soil Sensor Documentation
Recommended Sensors
DFRobot SEN0193 Capacitive Sensor
SparkFun Soil Moisture Sensor (SEN-13322)
Grove Capacitive Moisture Sensor (Seeed Studio)
Frequently Asked Questions
How often should I take soil moisture readings?
For most garden applications, reading every 30-60 minutes provides sufficient resolution without excessive data. Houseplants can be checked every few hours since their moisture changes slowly. For automated watering systems, check every 10-30 minutes during active watering periods, then reduce frequency. Taking readings too frequently wastes power and, for resistive sensors, accelerates corrosion.
Can I use multiple soil moisture sensors with one Arduino?
Yes, each sensor connects to a separate analog input pin. Arduino Uno has six analog pins (A0-A5), supporting up to six sensors. For more sensors, use an analog multiplexer (like CD4051) or upgrade to Arduino Mega with 16 analog inputs. When using multiple capacitive sensors, space them at least 6 inches apart to prevent electromagnetic interference between units.
Why do my sensor readings differ between different soil types?
Soil composition dramatically affects readings. Sandy soil drains quickly and has lower baseline capacitance than clay-heavy soil. Organic matter, fertilizer content, and mineral composition also influence electrical properties. Always calibrate your sensor in the actual soil you’ll be monitoring, and recalibrate if you change soil mix or add significant amendments.
Should I choose a resistive or capacitive soil moisture sensor?
For learning projects, classroom demonstrations, or installations lasting less than six months, resistive sensors work fine and cost less. For any long-term garden monitoring, automated watering systems, or outdoor installations, capacitive sensors are worth the extra cost. Their corrosion resistance and longer lifespan provide better value over time, and you won’t need to replace them mid-season.
How do I protect my soil moisture sensor from water damage?
For capacitive sensors, keep everything above the marked waterproof line dry. Apply clear epoxy or use heat-shrink tubing around the upper electronics portion. For resistive sensors, the probe is designed for soil contact, but keep the comparator module dry. In all cases, use weatherproof enclosures for the Arduino and route cables to prevent water ingress. For permanent outdoor installations, consider conformal coating on all exposed PCB areas.
Building a Reliable Garden Monitoring System
The Soil Moisture Sensor Arduino combination provides an accessible entry point into precision gardening. Starting with basic moisture readings and progressing to fully automated watering systems, these sensors enable you to understand exactly what’s happening in your soil rather than relying on guesswork.
Success depends on three factors: choosing the right sensor for your timeframe, proper calibration for your specific soil, and thoughtful placement in the root zone you care about. Get these right, and you’ll have reliable data that helps your plants thrive.
For permanent installations, invest in capacitive sensors despite the higher initial cost. For temporary projects or educational purposes, resistive sensors teach the same concepts at lower investment. Either way, the techniques covered here will help you build monitoring systems that actually work in real-world garden conditions.
Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.