Connect the ideas · 14 / 16
Soil Moisture: Readings & Calibration
Map a soil moisture reading to a percentage. Test the lesson’s dry and wet endpoints and learn why a real sensor needs calibration.
Map a conceptual sensor reading to a percentage.
Understand it
The example maps a dry reading of 800 to 0% and a wet reading of 300 to 100%, then constrains the result. These endpoints are demonstration values. Calibrate the actual sensor and soil before using a percentage.
Your experiment
Try raw readings of 800, 550 and 300. Run and compare the indicated moisture at the dry end, midpoint and wet end.
Connections
- A0 — Conceptual moisture sensor
- Serial — Moisture percentage
Sketch
This sketch illustrates the hardware logic. The workbench runs its corresponding teaching model, not a C++ compiler.
// Calibrate dry and wet endpoints for your own sensor.
void setup() {
Serial.begin(9600);
}
void loop() {
int reading = analogRead(A0);
int moisture = map(reading, 800, 300, 0, 100);
moisture = constrain(moisture, 0, 100);
Serial.println(moisture);
delay(200);
}Quick check
Is the displayed percentage a universal soil moisture measurement?
Show explanation
No. It is a mapping between the lesson’s chosen dry and wet readings. Real sensors need calibration for the probe, soil and conditions.