seconds,raw,percent → 120,55% · dry LED OFFTap a part to see what it does.
Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.
Build it step by step
0 of 5 donePlace the ESP32
Across the centre gap so both pin rows are free.
Wire the sensor
VCC to 3V3, GND to GND, AOUT to GPIO34.
Add the dry LED
GPIO25 to 220 Ω, to the LED's long leg, short leg to GND.
Calibrate
Upload, note raw in dry air (DRY) and in a glass of water up to the line (WET), put both in the code and upload again.
Put it in the pot
Push the sensor in up to the line, keep the electronics dry, and watch the log.
How do you build a plant soil moisture logger?
An ESP32 reads a capacitive soil sensor, logs moisture every 10 seconds and lights an LED when the soil is dry. You need ESP32 DevKit V1, Capacitive Soil Moisture Module, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points. It takes 5 steps and about 50 minutes.
- Level
- Beginner
- Time
- About 50 min
- Parts
- 5
Parts list
- Development BoardsBuyESP32 DevKit V1 × 1
- SensorsBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Sensor VCC | ESP32 3V3 | Sensor power |
| Sensor GND | ESP32 GND | Ground |
| Sensor AOUT | ESP32 GPIO34 | Analog reading (ADC1) |
| ESP32 GPIO25 | 220 Ω, then LED anode | Dry warning |
Code
Arduino IDE with the ESP32 board package. No extra libraries. The serial output is CSV: copy it into a spreadsheet to graph it.
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const int SOIL = 34, LED = 25;
int DRY = 3000; // reading in dry air: measure yours
int WET = 1300; // reading in a glass of water: measure yours
const int DRY_PERCENT = 30;
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
analogReadResolution(12);
Serial.println("seconds,raw,percent");
}
void loop() {
long sum = 0;
for (int i = 0; i < 16; i++) { sum += analogRead(SOIL); delay(5); }
int raw = sum / 16;
int pct = constrain(map(raw, DRY, WET, 0, 100), 0, 100);
digitalWrite(LED, pct < DRY_PERCENT);
Serial.print(millis() / 1000); Serial.print(',');
Serial.print(raw); Serial.print(',');
Serial.println(pct);
delay(10000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
seconds,raw,percent 0,2251,44
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Sensor in dry air | percent near 0, LED on |
| Sensor in water | percent near 100, LED off |
| Freshly watered pot | Roughly 60 to 90 percent |
If it does not work
raw stays at 0 or 4095
Check AOUT is on GPIO34 and the sensor has 3V3. Do not use ADC2 pins with Wi-Fi.
Percent goes the wrong way
DRY and WET are swapped in the code.
Readings drift over days
Normal for cheap sensors; recalibrate monthly and keep the top dry.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the plant soil moisture logger?
ESP32 DevKit V1, Capacitive Soil Moisture Module, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points.
How long does the plant soil moisture logger take to build?
About 50 minutes for a beginner maker, in 5 steps.
How do I know the plant soil moisture logger works?
Sensor in dry air: percent near 0, LED on. Sensor in water: percent near 100, LED off. Freshly watered pot: Roughly 60 to 90 percent.
raw stays at 0 or 4095: what should I check?
Check AOUT is on GPIO34 and the sensor has 3V3. Do not use ADC2 pins with Wi-Fi.
Percent goes the wrong way: what should I check?
DRY and WET are swapped in the code.
Readings drift over days: what should I check?
Normal for cheap sensors; recalibrate monthly and keep the top dry.
