Soil Moisture Sensor: How It Works and How to Read It
A soil moisture sensor turns the water around its probe into a number. This guide explains how capacitive and resistive probes work, how to turn the raw number into a percentage, how to calibrate dry and wet, and how to use the reading in a plant rule.
By the MakerBuddy team Published 19 min read
A watering can sprinkles water on a potted plant while a flat black capacitive soil sensor blade, pushed into the soil up to its printed line, sends its reading along a cable to an ESP32 board and a dashboard card showing Soil Moisture 40%, raw 2280.
A soil moisture sensor is a probe that you push into soil to measure how much water is around it. It does not see water directly. A resistive probe measures how easily electricity flows between two metal prongs. A capacitive probe measures how much electric charge a coated blade can hold, which rises when water is near. Either way, the sensor gives a raw number. You read it by calibrating two ends, dry and wet, and placing every new reading between them as a percentage.
The MakerBuddy kit uses a capacitive blade, not a two-prong probe. It plugs into the socket marked 32, and the dashboard shows both the raw number and a 0–100% value with no code. Lesson 18, Smart Agriculture, teaches it with a calibration activity and a "thirsty plant" challenge.
What a soil moisture sensor measures
Soil is a mix of mineral grains, organic matter, air and water. Scientists describe its water as volumetric water content: the volume of water divided by the volume of soil. Texas A&M AgriLife Extension's guide Irrigation Monitoring with Soil Water Sensors (E-618) (opens in a new tab) points out that this value is always less than 1. Even soaked soil is never all water.
The same guide names three points that matter to a plant:
Field capacity: the water left after a heavy watering has drained away. Loam and clay reach it two to three days after irrigation.
Permanent wilting point: so little water that a plant cannot recover overnight.
Plant available water: everything between those two points. This is the water roots can actually use.
Here are E-618's figures for three soils, given as a share of the soil's volume:
Two lessons hide in that table. First, a full pot of loam holds only about a quarter water. Second, clay holds the most water but also keeps the most for itself, so a plant in clay can wilt while the soil still feels damp.
E-618 (opens in a new tab) also sorts soil water into three classes. Gravitational water drains out, capillary water clings between grains and feeds plants, and hygroscopic water is held too tightly for roots to use.
Three families of sensor are common. Each measures something that changes with water, then turns it into a reading.
Resistive probes: two metal prongs
A resistive probe has two bare metal legs. A small current flows from one leg, through the soil, to the other. Water carries current better than dry soil, so wet soil gives a stronger signal. SparkFun's soil moisture sensor hookup guide (opens in a new tab) describes the two probes as a variable resistor, and on a 5 V board its example reads close to 0 in air and about 880 when the probe is soaked.
The weak point is the metal. The same SparkFun guide warns that these sensors have a short life in moist soil and advises powering them only when you take a reading. Adafruit's STEMMA soil sensor guide (opens in a new tab) explains why: the exposed metal oxidises, even when gold plated, so the reading drifts and the code needs constant recalibration.
Capacitive probes: a coated blade
A capacitive probe has no bare metal in the soil. Copper areas sit under a coating on a flat blade. A circuit on the board charges and empties them very fast, and the soil around the blade acts as the filling of a capacitor. The more water near the blade, the more charge it holds, and the circuit turns that into a voltage. Texas A&M's E-618 (opens in a new tab) describes the professional version: an oscillator drives the electrodes with high-frequency current, and its frequency drops as water content rises.
Tension sensors: how hard roots must pull
Tensiometers and granular matrix sensors measure how tightly the soil holds its water, in centibars, rather than how much there is. E-618 (opens in a new tab) puts field capacity near 10 centibars in sandy soil and about 30 in loam and clay. They are farm tools: the same guide notes that granular matrix sensors respond slowly and are read with a handheld meter.
Types compared
Type
What it senses
Metal in soil
Main weakness
Typical use
Resistive two-prong probe
How easily current flows between prongs
Yes, bare
Prongs corrode and readings drift
Cheap starter kits, short tests
Capacitive blade
How much charge a coated blade holds
No, coated
Needs firm contact and calibration in your soil
Student kits, plant monitors
Granular matrix or gypsum block
Resistance inside a porous block, shown as tension
Inside the block
Slow to respond, needs calibration
Farm irrigation
Tensiometer
Suction on a water-filled tube
No
Needs refilling, limited range
Farm irrigation
Type
Resistive two-prong probe
What it senses
How easily current flows between prongs
Metal in soil
Yes, bare
Main weakness
Prongs corrode and readings drift
Typical use
Cheap starter kits, short tests
Type
Capacitive blade
What it senses
How much charge a coated blade holds
Metal in soil
No, coated
Main weakness
Needs firm contact and calibration in your soil
Typical use
Student kits, plant monitors
Type
Granular matrix or gypsum block
What it senses
Resistance inside a porous block, shown as tension
Water's number is about 20 times that of the minerals and 80 times that of air. When water fills the gaps between grains, it pushes out air and the blade's capacitance climbs sharply. Of those three, only water has such a large value, so the blade works mainly as a water detector.
The same note gives two warnings that shape how you use the blade:
The electric field is strongest right at the sensor surface and fades with distance. So the blade mostly senses the soil touching it, not the whole pot.
Any air gap between the sensor and the soil causes a large error. A blade pushed into loose soil, or one that wobbles, reads drier than the soil really is.
Water's permittivity also falls by about 0.5% for each degree Celsius it warms, according to the application note (opens in a new tab), so morning and afternoon readings are not perfectly comparable.
A capacitive blade pushed into soil up to its printed line: two copper areas under a coating send an electric field into the soil that is strongest at the blade and fades with distance. On the dry side air pockets sit between the grains (air 1, minerals about 4) and the blade gives a high raw number; on the wet side water films fill the gaps (water about 80) and it gives a low raw number, while the electronics above the line stay dry.
What the kit's blade does
On the MakerBuddy blade, wetter soil gives a lower raw number, which surprises most students. Dry air reads high and water reads low. Other sensors may run the other way, which is why you calibrate both ends yourself.
The blade has a line printed near the top. Only the part below the line may go into soil or water. The electronics above it are not waterproof, and the cable plug and the board must stay dry.
How to read a soil moisture sensor: from raw number to percent
The probe gives an analog voltage, which the microcontroller's analog-to-digital converter turns into a whole number. The guide to analog vs digital signals explains the difference.
On the ESP32, Arduino-ESP32's ADC reference (opens in a new tab) says analogRead gives 12 bits by default, a range of 0 to 4095. The MakerBuddy board reads the soil blade on GPIO 32. Espressif's GPIO reference (opens in a new tab) lists GPIO 32 as ADC1 channel 4, and that matters: it warns that ADC2 pins cannot be used when Wi-Fi is on. All four analog sensor pins on the board are on ADC1, so readings keep working while the dashboard is connected.
The firmware reads the pin four times, averages the four values to calm the noise, and keeps the result as the raw number. Then it turns the raw number into a percentage with your two calibration points.
Worked example: turn raw readings into moisture percent
The formula places a reading on a straight line between dry and wet:
text
percent = (raw − dry) × 100 ÷ (wet − dry)
Until you calibrate, the board uses dry = 3000 and wet = 1200. Take three readings:
1
A raw reading of 2280 in damp soil. Subtract dry: 2280 − 3000 = −720. Multiply by 100 to get −72,000. Divide by wet − dry, which is 1200 − 3000 = −1800. The answer is −72,000 ÷ −1800 = 40%. Two minus signs cancel, so a lower raw number gives a higher percentage, just as it should.
2
A raw reading of 3150 in very dry potting mix. That gives (3150 − 3000) × 100 ÷ −1800 = −8.3. A negative moisture makes no sense, so the firmware clamps it to 0%.
3
A raw reading of 1100 with the blade in a cup of water, a little below the default wet point. That gives (1100 − 3000) × 100 ÷ −1800 = 105.6, which is clamped to 100%.
The firmware uses whole-number maths and drops fractions, so a raw 2290, which works out at 39.4, shows as 39%.
The key point: 40% on the card does not mean the soil is 40% water. It means the blade sits 40% of the way from your dry point to your wet point. Your wet point is usually a cup of water, while real loam at field capacity is only about 27% water by volume. Treat the card as a scale you set yourself, not a lab measurement.
Two scales running opposite ways: the raw number from 0 to 4095 with the wet point at 1200 and the dry point at 3000, and the moisture card from 100% at 1200 to 0% at 3000. A raw reading of 2280 lands at 40%, readings below 1200 are clamped to 100% and readings above 3000 to 0%, because wetter soil gives a lower raw number.
The guide to the LDR light sensor uses the same kind of mapping for light, without the calibration step. The full story of ESP32 analog accuracy is in the guide to the ESP32 ADC and reading analog sensors accurately.
Calibrate dry and wet for your own soil
Calibration replaces the default 3000 and 1200 with numbers from your blade. Lesson 18 is firm on this: calibrate both ends yourself, never with someone else's numbers. The steps, from the documentation's sensor settings:
1
Plug in the blade. Unplug the USB cable first, push the blade's plug into the socket marked 32 at the bottom of the right-hand edge, then plug the USB cable back in. The plug fits only one way, so never force it.
2
Open the window. On the Soil Moisture card, press the gear button to open Soil Moisture Calibration.
3
Set dry. Hold the blade in the air, touching nothing. Under Dry Calibration press Start. The box shows the live raw number. When it stops changing, press Save. The card should now read 0%.
4
Set wet. Dip the blade into a cup of water up to the line, never deeper. Under Wet Calibration press Start, let the number settle, then press Save. The card should now read 100%.
5
Check it. Wipe the blade dry and push it into damp soil. The percentage should land somewhere in the middle. If it moves the wrong way, redo both ends and check the plug.
The bottom line of the window shows Raw, Dry and Wet together. The board keeps your values through a restart. They must sit between 0 and 4095, and if dry and wet are equal, the board reads 0% all the time.
For a tighter scale, use your project soil for both ends: soil dried out on a tray for dry, and the same soil just after a thorough watering and a few minutes of draining for wet. The guide to calibrating a soil moisture sensor goes further, including how to check your scale with a kitchen scale and an oven-dried sample, the method E-618 (opens in a new tab) calls the standard all other sensors are calibrated against.
Moisture sensor for plants: build a thirsty plant rule
A rule on the MakerBuddy board watches one or two sensors and runs up to 10 steps. It runs on the board itself, so it keeps working when you close the browser. The guide to if-then statements with real sensors explains the logic behind it.
Worked example: a rule written step by step
Goal: when the plant's soil drops below 35%, beep once and show a message on the text screen, then wait a minute before reminding again.
1
Name it. Open a new rule and call it "Thirsty plant". Names can be up to 20 characters.
2
Pick the loop mode. Choose Condition. A condition rule starts once the match has held for 0.3 seconds, then repeats its steps for as long as the match lasts.
3
Set the condition. Sensor: Soil Moisture. Comparison: Less than. Number: 35.
4
Step 1. Buzzer On, Delay 500 ms. In a rule, the buzzer stays on until a Buzzer Off step, so the delay sets the beep length.
5
Step 2. Buzzer Off, Delay 0 ms.
6
Step 3. LCD Display, with line 1 "Water the plant" and line 2 "Soil {soil}%". The {soil} wildcard prints the live percentage. Delay 60000 ms, which is one minute.
7
Save and enable it.
When the soil drops under 35%, the buzzer beeps, the screen asks for water, and a minute later the round repeats. Once you water and the reading climbs back to 35% or more, the rule finishes the round it is in, then stops. Rules check the reading once a second.
Flowchart of the Thirsty plant rule: the condition Soil Moisture < 35, which must hold for 0.3 s and is checked once a second, leads on Yes to Step 1 Buzzer On with a 500 ms delay, Step 2 Buzzer Off with 0 ms, and Step 3 LCD Water the plant / Soil {soil}% with a 60000 ms (one minute) delay, then loops back to check again. On No the rule finishes the round it is in, then stops.
Why 35 and not 20 or 50? Lesson 18 gives a rough guide once you have calibrated: about 0–30% is dry, 30–60% moist and comfortable for most plants, and 60–100% wet. Many classes start the threshold around 40%. The honest answer is to measure your own plant: record the percentage the day it starts to droop and set the line a little above it. The guide to picking sensor thresholds covers the method.
Taking it further: watering by itself
The project ideas library has a Garden Auto-Waterer: when the soil reads too dry, the relay switches a small water pump or valve. The pump is an extra part, not in the kit, and it must be a low-voltage pump. The relay is for low-voltage things only, never mains electricity. The guide to how a relay works and Lesson 15 on relay control explain why.
Water takes time to soak down to the blade, so a pump left on until the reading rises will overwater. Use pulses instead: Relay On with a 3000 ms delay, then Relay Off with a 60000 ms delay. The condition rule repeats the pair while the soil is dry, giving each squirt a minute to spread. The full build is in the automatic plant watering system guide, and Lesson 26, Sensor-Based Control, teaches condition rules in depth.
For coders: read the blade with Arduino
This sketch prints the same raw number and percentage the firmware works out. Replace the two calibration numbers with your own.
cpp
// MakerBuddy soil blade on GPIO 32: print raw and percent once a second.
const int SOIL_PIN = 32; // ADC1 channel 4, so it still works with Wi-Fi on
int dryRaw = 3000; // your Dry reading (blade in air)
int wetRaw = 1200; // your Wet reading (blade in water to the line)
int readAverage(int pin) {
long sum = 0;
for (int i = 0; i < 4; i++) {
sum += analogRead(pin); // 12-bit: 0 to 4095
}
return sum / 4; // average four reads to calm noise
}
void setup() {
Serial.begin(115200);
}
void loop() {
int raw = readAverage(SOIL_PIN);
long percent = map(raw, dryRaw, wetRaw, 0, 100); // dry is 0, wet is 100
percent = constrain(percent, 0, 100); // no -8% or 105%
Serial.print("raw ");
Serial.print(raw);
Serial.print(" moisture ");
Serial.print(percent);
Serial.println(" %");
delay(1000);
}
map() works even though dry is bigger than wet, because it is just the straight-line formula from the worked example. Uploading your own sketch replaces the MakerBuddy firmware until you put the firmware back, so the dashboard and rules stop working in the meantime. The guide to programming an ESP32 with the Arduino IDE covers the board setup and upload.
Where to put the soil moisture sensor probe
A good number depends as much on placement as on calibration. These habits come from the warnings above and from Lesson 18:
Push it in up to the line. Less depth means part of the sensing area is in air, which reads drier. More depth soaks the electronics.
Put it where the roots are: in a pot, between the stem and the edge.
Leave it in one place. Moving it changes the soil around the blade, and the number jumps.
Wait after watering. Water reaches the blade from the top down, and E-618 (opens in a new tab) notes that capacitance sensors show these wetting fronts, so expect the number to climb over a minute or more.
Wipe it after use. Lesson 18 warns that water soaking into the blade's edges can damage it over time.
Common soil moisture sensor mistakes and how to fix them
Symptom
Cause
Fix
The card always shows 0%
Dry and wet were saved as the same number, or the blade is drier than your dry point
Redo the calibration so dry and wet differ; check the raw number in the calibration window
The percentage falls when you water
Dry and wet were swapped, for example Save was pressed under Wet with the blade in air
Recalibrate: Dry in air, Wet in water
The number jumps every time you touch the pot
The blade is loose, so air gaps open and close around it
Push it in to the line and firm the soil around it
A reading still shows with the blade unplugged
The pin floats, and the board cannot tell a loose plug from a real value
Check the plug before trusting a strange reading
Readings fail on your own ESP32 project once Wi-Fi starts
The sensor is on an ADC2 pin
Move it to an ADC1 pin such as GPIO 32 to 39
The board stopped responding after water reached it
The blade went in past the line, or the plug got wet
Unplug at once, dry everything, and keep the line above the soil
Symptom
The card always shows 0%
Cause
Dry and wet were saved as the same number, or the blade is drier than your dry point
Fix
Redo the calibration so dry and wet differ; check the raw number in the calibration window
Symptom
The percentage falls when you water
Cause
Dry and wet were swapped, for example Save was pressed under Wet with the blade in air
Fix
Recalibrate: Dry in air, Wet in water
Symptom
The number jumps every time you touch the pot
Cause
The blade is loose, so air gaps open and close around it
Fix
Push it in to the line and firm the soil around it
Symptom
A reading still shows with the blade unplugged
Cause
The pin floats, and the board cannot tell a loose plug from a real value
Fix
Check the plug before trusting a strange reading
Symptom
Readings fail on your own ESP32 project once Wi-Fi starts
Cause
The sensor is on an ADC2 pin
Fix
Move it to an ADC1 pin such as GPIO 32 to 39
Symptom
The board stopped responding after water reached it
Cause
The blade went in past the line, or the plug got wet
Fix
Unplug at once, dry everything, and keep the line above the soil
Yes, for what they are built to do. A capacitive blade reliably shows that soil is getting wetter or drier, without corroding. That is enough to remind you to water a plant, compare materials or switch a small pump. It is not a lab instrument, though. Texas A&M's E-618 (opens in a new tab) makes three points worth knowing:
All soil water sensing methods must be calibrated, despite the efforts of makers to supply calibration curves.
Capacitance methods are sensitive to soil temperature, salinity, clay content and soil structure, which makes them unreliable for precise farm irrigation scheduling.
They are still useful for following wetting and drying patterns over time.
The Campbell et al. application note (opens in a new tab) adds that the bulk density of farm soils alone can shift predicted water content by about ±2.5%, so any claim of 1% accuracy in every soil is an overstatement.
So trust the kit's percentage as a trend and check it as an absolute number. The MakerBuddy documentation calls the soil sensor's values learning readings, not certified ones.
Where these sensors do pay off is water saved. The US Environmental Protection Agency's WaterSense page on soil moisture-based irrigation controllers (opens in a new tab) says an average home with an automatic sprinkler system could save more than 15,000 gallons of water a year with a WaterSense labelled controller, because it skips watering when the ground is already wet enough.
Using the soil sensor in class
The blade is easy to teach because the result is visible: pour water, watch the number move. Lesson 18 builds a session around it, and the project library adds three no-code ideas:
Idea
What students do
Parts used
Lessons
Wet or Dry Lab
Test sand, soil and sawdust with different amounts of water, then rank them from driest to wettest
Soil sensor
18
Plant Thirst Tracker
Calibrate dry and wet, then let a light or beep say when the plant needs water
Soil sensor, blue light, buzzer
18, 26
Garden Auto-Waterer
A rule switches a small low-voltage pump through the relay when the soil is dry
Soil sensor, relay, extra pump
15, 18, 26
Idea
Wet or Dry Lab
What students do
Test sand, soil and sawdust with different amounts of water, then rank them from driest to wettest
Parts used
Soil sensor
Lessons
18
Idea
Plant Thirst Tracker
What students do
Calibrate dry and wet, then let a light or beep say when the plant needs water
Parts used
Soil sensor, blue light, buzzer
Lessons
18, 26
Idea
Garden Auto-Waterer
What students do
A rule switches a small low-voltage pump through the relay when the soil is dry
Parts used
Soil sensor, relay, extra pump
Lessons
15, 18, 26
Ideas from the MakerBuddy project library. In the Wet or Dry Lab, push the blade in only up to the printed line.
A good question to pair with it: which soil holds water longest? Water pots of sand, loam and clay, then log the reading every five minutes, the way Lesson 18's first challenge logs a single pot. Teachers planning a unit can find the lesson sequence and classroom tips on the MakerBuddy page for teachers.
FAQ
What type of sensor is used to measure soil moisture?
Most school projects use a resistive probe with two metal prongs or a capacitive blade with coated copper areas. Farms also use tension sensors, such as tensiometers, which measure how tightly soil holds its water. The MakerBuddy kit uses a capacitive blade, which has no bare metal to corrode.
How does a soil moisture sensor work?
It measures a property of the soil that changes with water. A resistive probe measures how easily current flows between two prongs. A capacitive probe measures how much charge a coated blade holds, which rises sharply near water because water's permittivity is about 80 against about 4 for soil minerals, according to a Decagon application note (opens in a new tab). The microcontroller turns the result into a raw number.
How do you read a soil moisture sensor?
Read the raw number on an analog pin, then place it between a dry reading and a wet reading you recorded yourself. The formula is percent = (raw − dry) × 100 ÷ (wet − dry), clamped to 0–100. On the MakerBuddy board the dashboard does this for you once you calibrate dry and wet.
Why does my soil moisture sensor give a lower number when the soil is wet?
Many capacitive blades, including the MakerBuddy one, give a lower output as the soil around them gets wetter, so dry air gives a high raw number and water a low one. This is normal. Calibration handles it, because the percentage comes from your own dry and wet points.
What is the ideal soil moisture level for plants?
There is no single number; it depends on the plant and the soil. Texas A&M's E-618 (opens in a new tab) says many field crops should be watered before about half of their plant available water is used, and some drought-sensitive vegetables sooner. That is a farm measure, not a card reading. On a calibrated MakerBuddy card, Lesson 18's rough guide treats about 30–60% as moist and comfortable for most plants.
Do soil moisture gauges work?
Yes, for showing whether soil is getting wetter or drier, and for timing watering. They are less reliable as exact measurements, because temperature, salt, clay and air gaps all shift the reading, as Texas A&M's E-618 (opens in a new tab) explains. Calibrate in your own soil and compare readings from the same spot over time.
How deep should a soil moisture sensor go?
Push a blade in up to the line printed on it, and no further, so the whole sensing area touches soil and the electronics stay dry. Place it in the root zone, between the stem and the pot's edge.
Can you leave a soil moisture sensor in the soil all the time?
A capacitive blade can stay in a pot, which is how plant monitors work. A resistive two-prong probe should not, because its metal corrodes in moist soil; SparkFun's hookup guide (opens in a new tab) advises powering one only while you take a reading. Wipe any blade dry when you take it out.
The MQ-2 is a heated tin dioxide sensor that reacts to burnable gases and smoke. This guide covers what it detects, how long it needs to warm up, what a 0–100 gas reading means, and why it is a learning tool, never a real alarm.
The DS18B20 is a digital temperature sensor that sends exact readings over one data wire, and its waterproof probe version can sit in water or soil. This guide covers its specs, pinout, how the one-wire bus works, a no-code water rule and ESP32 code.
The DHT11 measures air temperature and relative humidity and sends both over one data wire. This guide covers its pinout, what its ±2 °C and ±5% accuracy really mean, how it senses humidity, and how to use it on the MakerBuddy board with no code or with Arduino code.
· 19 min read
Learn with MakerBuddy
Start building today.
Every part in these guides has its own lesson. Read them free, or get a kit for your class.