ESP32 C3 Super Mini - Soil Moisture Sensor

Learn how to interface a soil moisture sensor with your ESP32 C3 Super Mini to monitor soil water levels for your plant projects. This beginner-friendly guide covers wiring, calibration, and reading sensor data.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - Soil Moisture Sensor

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Capacitive Soil Moisture Sensor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Buy Note: Many soil moisture sensors available in the market are unreliable, regardless of their version. We strongly recommend buying the sensor with TLC555I Chip from the DIYables brand using the link provided above. We tested it, and it worked reliably.

Overview of Soil Moisture Sensor

Soil moisture sensors measure the water content in soil by outputting an analog voltage signal.

capacitive moisture sensor vs resistive moisture sensor

Two Types of Soil Moisture Sensors:

  • Resistive Moisture Sensor: Uses electrical current between two probes to measure resistance
  • Capacitive Moisture Sensor: Measures soil moisture through capacitance changes without exposed electrodes

Why We Recommend Capacitive Sensors:

  • Longer lifespan - no corrosion issues
  • No exposed electrodes that degrade over time
  • More accurate readings in the long term
  • Better for permanent installations

Resistive Sensor Problems:

  • Electrochemical corrosion from current flow between probes
  • Degraded accuracy over time
  • Requires frequent replacement
resistive soil moisture sensor corrosion

Note: The rest of this ESP32 C3 Super Mini soil moisture sensor tutorial focuses on the capacitive type for reliability.

Capacitive Soil Moisture Sensor Pinout

The capacitive soil moisture sensor has a simple three-pin interface for easy connection to your ESP32 C3 Super Mini.

capacitive soil moisture sensor pinout
  • GND: Ground connection - connect to GND (0V)
  • VCC: Power supply - connect to 5V or 3.3V
  • AOUT: Analog output pin - outputs voltage inversely proportional to moisture level (higher moisture = lower voltage)

How the Capacitive Moisture Sensor Works

  • Higher water content in soil = lower voltage on AOUT pin
  • Drier soil = higher voltage on AOUT pin
  • ESP32 C3 Super Mini reads analog voltage to determine moisture level
  • No direct contact with soil prevents corrosion

Wiring Diagram

Connect your capacitive soil moisture sensor to the ESP32 C3 Super Mini following this simple wiring diagram.

The wiring diagram between ESP32 C3 Super Mini soil moisture sensor

This image is created using Fritzing. Click to enlarge image

Moisture Sensor Pin ESP32 C3 Super Mini Pin
GND GND
VCC 3.3V
AOUT A4 (GPIO4 / ADC1_CH4)

Important Safety Notes:

  • Keep the circuit board (top part of sensor) above soil/water level
  • Only submerge the sensor probe portion
  • Use salt water for testing, not pure water (pure water doesn't conduct electricity)

ESP32 C3 Super Mini Code - Reading Moisture Values

This code reads analog values from the capacitive soil moisture sensor and displays them on the Serial Monitor.

What the code does:

  • Configures GPIO4 as analog input for moisture sensor
  • Reads analog voltage from the sensor every 500ms
  • Converts readings to moisture values
  • Displays values on Serial Monitor for calibration
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-soil-moisture-sensor */ #define AOUT_PIN A4 // The ESP32 C3 SuperMini pin A4 that connects to AOUT pin of moisture sensor void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); } void loop() { int value = analogRead(AOUT_PIN); // read the analog value from sensor Serial.print("Moisture value: "); Serial.println(value); delay(500); }

Detailed Instructions

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Copy the code: Paste the above code into Arduino IDE
  • Upload: Click the Upload button to program your ESP32 C3 Super Mini
  • Connect sensor: Wire the moisture sensor according to the diagram above
  • Test the sensor: Bury the probe in soil and slowly add water, or submerge in salt water
  • Open Serial Monitor: Set baud rate to 9600 to view readings
  • Observe values: Watch how values decrease as moisture increases
  • Record readings: Note the dry and wet values for calibration
  • Pro Tip: Use a consistent soil type during calibration for the most accurate threshold values across your project.

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Moisture value: 2230 Moisture value: 2223 Moisture value: 2255 Moisture value: 2279 Moisture value: 2313 Moisture value: 2350 Moisture value: 2383 Moisture value: 2395 Moisture value: 1260 Moisture value: 1325 Moisture value: 1271 Moisture value: 1261 Moisture value: 1254 Moisture value: 1261 Moisture value: 1264 Moisture value: 1360 Moisture value: 1258 Moisture value: 1263 Moisture value: 1266 Moisture value: 1258 Moisture value: 1239 Moisture value: 1264 Moisture value: 1307 Moisture value: 1488 Moisture value: 1647 Moisture value: 1746 Moisture value: 1846
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

※ NOTE THAT:

  • Do not use pure water for testing because it doesn't conduct electricity, so it won't impact sensor readings.
  • Sensor readings never drop to zero. It's normal for values to be between 3100 and 2600, although this may change due to factors such as the depth of sensor placement, soil or water composition, and power supply voltage.
  • Avoid burying the circuit part (located on top of the sensor) in soil or water, as this could potentially harm the sensor.

Calibration for Capacitive Soil Moisture Sensor

The moisture sensor outputs relative values that vary based on soil type, water salinity, and sensor depth, so calibration is essential for accurate wet/dry detection.

Why Calibration is Necessary:

  • Different soil types give different readings
  • Water composition affects conductivity
  • Sensor depth changes the measured values
  • Each project needs a custom threshold

How to Calibrate Your Moisture Sensor:

  • Upload the code: Run the first code example on your ESP32 C3 Super Mini
  • Prepare soil: Place sensor in the actual soil you'll monitor
  • Start dry: Begin with completely dry soil and note the reading
  • Add water slowly: Gradually irrigate while watching Serial Monitor
  • Find transition point: Identify when soil changes from dry to wet feeling
  • Record threshold: Write down the value at the dry-to-wet transition
  • Test both extremes: Note values for completely dry and fully saturated soil
  • Calculate middle: Your threshold is typically between dry and wet values

Typical Calibration Results:

  • Dry soil: 2200-2500 (varies by conditions)
  • Wet soil: 1200-1500 (varies by conditions)
  • Recommended threshold: midpoint between your dry and wet readings

Determine if the Soil is Wet or Dry

After calibration, use this code to determine if your soil needs watering based on the threshold value you recorded.

What this enhanced code does:

  • Compares sensor readings against your calibrated threshold
  • Displays "WET" or "DRY" status on Serial Monitor
  • Shows the actual moisture value for reference
  • Makes automated watering decisions easier
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-soil-moisture-sensor */ #define AOUT_PIN A4 // The ESP32 C3 SuperMini pin A4 that connects to AOUT pin of moisture sensor #define THRESHOLD 1500 // CHANGE YOUR THRESHOLD HERE void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); } void loop() { int value = analogRead(AOUT_PIN); // read the analog value from sensor if (value > THRESHOLD) Serial.print("The soil is DRY ("); else Serial.print("The soil is WET ("); Serial.print(value); Serial.println(")"); delay(500); }

Quick Steps for Wet/Dry Detection

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Update threshold: Replace the THRESHOLD value with your calibrated number
  • Upload code: Program your ESP32 C3 Super Mini with the updated code
  • Place sensor: Insert probe into soil at your desired monitoring depth
  • Open Serial Monitor: Set baud rate to 9600
  • Test accuracy: Add water to verify threshold detects wet/dry correctly
  • Adjust if needed: Fine-tune THRESHOLD value based on results
  • Pro Tip: Set your threshold slightly higher than the transition point to trigger watering before soil becomes too dry.

Serial Monitor Output - Wet/Dry Status

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
The soil is DRY (2129) The soil is DRY (1941) The soil is DRY (1767) The soil is DRY (1549) The soil is WET (1471) The soil is WET (1419) The soil is WET (1397) The soil is WET (1373) The soil is WET (1264)
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

※ NOTE THAT:

This tutorial uses the analogRead() function to read values from an ADC (Analog-to-Digital Converter) connected to a sensor or component. The ESP32 C3 Super Mini's ADC is suitable for projects that do not require high accuracy. However, for projects needing precise measurements, keep the following in mind:

  • The ESP32 C3 Super Mini's ADC is not perfectly accurate and might require calibration for correct results. Each ESP32 C3 Super Mini board can vary slightly, so calibration is necessary for each individual board.
  • Calibration can be challenging, especially for beginners, and might not always yield the exact results you want.

For projects requiring high precision, consider using an external ADC (e.g ADS1115) with the ESP32 C3 Super Mini or using another Arduino, such as the Arduino Uno R4 WiFi, which has a more reliable ADC. If you still want to calibrate the ESP32 C3 Super Mini's ADC, refer to the ESP32 ADC Calibration Driver.

Project Ideas with ESP32 C3 Super Mini and Moisture Sensor

Now that you know how to read soil moisture with your ESP32 C3 Super Mini, try these practical applications:

  • Automatic Plant Watering System: Trigger a water pump when soil becomes too dry
  • Smart Garden Monitor: Send moisture data to your phone via WiFi notifications
  • Multi-Plant Monitor: Connect multiple sensors to track different plants simultaneously
  • Data Logger: Record moisture levels over time to SD card for plant care analysis
  • Greenhouse Automation: Control irrigation systems based on real-time soil conditions
  • Plant Health Alert: Use LED indicators or buzzers to signal when plants need water

Video Tutorial

Watch the video below for a visual walkthrough of this project.

...VIDEO P7tG-t4dXZ0

...VIDEO

Challenge Yourself

Take your ESP32 C3 Super Mini soil moisture sensor project to the next level with these challenges:

  • Easy: Add an LED that lights up when soil is too dry
  • Easy: Display moisture percentage (0-100%) instead of raw values
  • Medium: Create an automatic watering system with a relay and water pump
  • Medium: Send moisture data to a web dashboard using ESP32's WiFi capabilities
  • Advanced: Build a multi-sensor system monitoring 3+ plants with individual thresholds
  • Advanced: Implement deep sleep mode to run on battery power for months

Function References

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!