Arduino Soil Moisture Detector

 

    This project uses an Arduino Uno, a soil moisture sensor module, and jumper wires to measure soil moisture levels and display the readings in the Serial Monitor. The system reads analog data from the sensor and classifies the soil condition as “WET,” “NORMAL,” or “DRY” based on the moisture level.


Code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  int moisture = analogRead(A0);

  Serial.print("Moisture: ");
  Serial.print(moisture);
  Serial.print(" - ");

  if (moisture > 700) {
    Serial.println("WET");
  } 
  else if (moisture > 400) {
    Serial.println("NORMAL");
  } 
  else {
    Serial.println("DRY");
  }

  delay(500);
}