Measuring Soil Moisture with a Sensor
Monitor the moisture level in soil using the analog output of a soil moisture sensor.
Circuit diagram

Interactive circuit guide
Run the simulation, follow the build steps one by one and try it in our real app.
Stopped
Step-by-step build
You can open the same circuit in the browser-based circuit simulator without any installation and inspect the wires and components there.
Parts list
| Component | Qty | Description |
|---|---|---|
| Arduino Uno | 1 | Reads the soil moisture output through the analog input. |
| Soil moisture sensor | 1 | Senses moisture from the resistance between the electrodes. |
| 5V supply connection | 1 | Supplies voltage to the sensor's power leg. |
| Ground connection | 1 | Common reference for the sensor and the board. |
Breadboard layout
The Arduino is on the left, the sensor at the upper right, the 5V supply at the top and the common ground at the lower right. The sensor's output leg goes to Arduino pin 2 and its ground leg to common ground.
Step-by-step build
- Place the Arduino Uno on the work area.Tip: The GND pin is index 0.
- Connect the sensor's power leg to 5V.Tip: On the sensor, pin 0 is power, pin 1 output and pin 2 ground.
- Connect the output leg to Arduino pin 2.Tip: The analog signal goes to a single pin.
- Connect the sensor ground and the Arduino GND to common ground.Tip: A common reference ensures reading stability.
- Upload the code and insert the electrodes into dry and moist soil.Tip: Note the readings for the two states.
How it works
When the sensor's two electrodes are inserted into the soil, the resistance between them changes with the soil's moisture content. Dry soil is a poor conductor, so resistance is high; as moisture increases, ionic conductivity rises and resistance falls. This resistance change is reflected in the sensor circuit's analog output voltage. The Arduino converts this voltage into a number between 0 and 1023. By choosing a threshold between the low value read for dry soil and the high value read for wet soil, the need for watering can be determined. Soil type and salinity can affect the threshold value.
What you will learn
- Reads a resistance change as an analog value.
- Sets a threshold for dry and moist soil.
- Understands the effect of sensor placement on the measurement.
Expected result: As the soil gets wetter, the analog value read on the serial port changes relative to the dry state.
Challenge
Moisture meter: Read the soil moisture level from the analog input.
Goal: A value that changes with moisture appears on the serial port.
Tips
- Touching the electrodes together spoils the measurement.
- Cleaning the electrodes after measurement reduces oxidation.
Frequently asked questions
How is soil moisture sensed?
The resistance between the two electrodes decreases as moisture increases; the sensor outputs this change as an analog voltage.
Why does the threshold vary with soil type?
Soil type and salinity affect conductivity, so the threshold is chosen based on observed readings.
What happens if the electrodes touch each other?
The measurement is spoiled; the electrodes must be kept apart and inserted to the same depth.
If you want to build this project in real life, you can get the parts from hobidevre.com. For more circuit ideas, visit the hobidevre.com blog.