AI Lab for the Internet of Things

From sensors to intelligent self-deciding systems: lessons, projects, architectures, interactive simulation labs and a specialist AIoT assistant.

20Lesson

Soil moisture sensor

A sensor that estimates the water content of soil through its resistance or capacitance, used in smart irrigation.

BeginnerChemical, gas and soil

Illustration of Soil moisture sensor
A schematic illustration created for this section for teaching purposes; it is not a photograph of the part or of any specific product.

Educational content in scientific-draft form; a specialist should review it before it is adopted as an academic reference. No measurement or performance result that was not actually obtained is shown here.

Facts

Measured quantitySoil moisture (relative)
Data typeAnalogue
Units of measurementRelative until calibrated
Examples of common partsA capacitive or resistive sensor

How it works

The resistive type measures resistance between two electrodes, and the capacitive type measures a change in capacitance; the latter usually lasts longer because its electrodes are not corroded to the same degree.

How to connect

Analogue output to an ADC with power and ground.

AIoT applications

  • Smart irrigation
  • Precision agriculture

Measurement and calibration issues

  • Needs calibration in your own soil
  • Affected by salinity and soil type
  • Resistive electrodes corrode

Code example

CPPIllustrative, not implemented or tested
// raw analogue reading (calibration needed)
const int PIN = 34;
void setup() { Serial.begin(115200); }
void loop() {
  int raw = analogRead(PIN);
  Serial.println(raw);
  delay(1000);
}

Simulations and labs run inside your browser. Nothing you enter and none of the conversations is stored on the server. Privacy policy