Soil Moisture Sensor
Overview
Capacitive soil moisture sensor measures water content in soil. Reads 0-100% (0% = dry, 100% = wet).
Wiring
| Sensor Pin |
ESP32 |
ESP8266 |
Pico W |
| VCC |
3.3V/5V |
3.3V/5V |
3.3V/5V |
| OUT (Analog) |
GPIO34 (ADC) |
A0 |
GP26 (ADC0) |
| GND |
GND |
GND |
GND |
Note: Capacitive sensors work with 3.3V or 5V. Resistive sensors will corrode over time.
Enable in Dashboard
- Go to Device Configuration
- Enable Soil Sensor 1 (and/or Soil Sensor 2)
- Set calibration values:
- Dry value: Reading when sensor in dry soil (air)
- Wet value: Reading when sensor in water
- Save and regenerate firmware
Calibration Guide
Step 1: Get Raw Values
- Flash device with sensor enabled
- Open Serial Monitor (115200 baud)
- Note reading in dry air: e.g.,
- Submerge sensor in water:
Step 2: Enter Values in Dashboard
| Sensor Type |
Dry Value |
Wet Value |
| ESP32 (12-bit) |
4095 |
1500 |
| ESP8266 (10-bit) |
1023 |
400 |
| Pico W (12-bit) |
4095 |
1500 |
Step 3: Verify
Dashboard shows percentage: 0% (dry) to 100% (wet)
Automation Examples
Auto-Watering (Below Threshold)
| Setting |
Value |
| Sensor |
Soil1 |
| Condition |
Below |
| Threshold |
30% (dry) |
| Action |
Turn ON |
| Target Relay |
Pump (Relay 3) |
| Return Value |
60% (wet) |
| Cooldown |
10 minutes |
Soil Too Wet (Above Threshold)
| Setting |
Value |
| Sensor |
Soil1 |
| Condition |
Above |
| Threshold |
80% |
| Action |
Turn OFF |
| Target Relay |
Pump (Relay 3) |
| Return Value |
60% |
Two Sensors (Compare Moisture)
Enable both sensors for different zones:
- Soil Sensor 1: Plant A (threshold 30%)
- Soil Sensor 2: Plant B (threshold 40%)
Troubleshooting
| Problem |
Solution |
| Reading 0% always |
Check calibration, sensor might be dead |
| Reading 100% always |
Short circuit, check wiring |
| Unstable readings |
Add capacitor (100µF) between VCC and GND |
| Resistive sensor corroded |
Replace with capacitive sensor |
Sensor Types Comparison
| Type |
Lifespan |
Accuracy |
Price |
| Capacitive |
Years |
High |
-10 |
| Resistive |
Months |
Medium |
-5 |
Recommendation: Use capacitive sensors for long-term projects.
Code Example (Arduino)
Best For
- Automatic plant watering
- Garden monitoring
- Greenhouse automation
- Lawn irrigation
Next Steps