How to use Soil moisture Sensor

 Soil Moisture Sensor

 What is a Soil moisture sensor?

Soil moisture sensors measure the volumetric water content in the soil.  The relation between the measured property and soil moisture must be calibrated and may vary depending on environmental factors such as soil type, temperature, or electric conductivity.


How to Work soil moisture sensor?

A small charge is placed on the electrodes and electrical resistance through the sensor is measured. As water is used by plants or as the soil moisture decreases, water is drawn from the sensor, and resistance increases. Conversely, as soil moisture increases, resistance decreases.

Soil moisture sensor parts and pinouts

Soil Moisture Sensor With Arduino

REQUIRED MATERIALS, <you can click and buy >

   How to connect soil moisture sensor to Arduino UNO


  code/ Program


int msensor = A0;
int mvalue;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
mvalue = analogRead(msensor);
Serial.println(mvalue);
delay(1000);
}
 


Soil moisture Sensor Project



Program / code

#define soilWet 500   // Define max value we consider soil 'wet'
#define soilDry 750   // Define min value we consider soil 'dry'

// Sensor pins
#define sensorPower 7
#define sensorPin A0

void setup() {
  pinMode(sensorPower, OUTPUT);
  
  // Initially keep the sensor OFF
  digitalWrite(sensorPower, LOW);
  
  Serial.begin(9600);
}

void loop() {
  //get the reading from the function below and print it
  int moisture = readSensor();
  Serial.print("Sensor Output: ");
  Serial.println(moisture);

  // Determine status of our soil
  if (moisture < soilWet) {
    Serial.println("Status: Soil is too wet");
  } else if (moisture >= soilWet && moisture < soilDry) {
    Serial.println("Status: Soil moisture is perfect");
  } else {
    Serial.println("Status: Soil is too dry - time to water!");
  }
  
  delay(1000);  
  Serial.println();
}

//  This function returns the analog soil moisture measurement
int readSensor() {
  digitalWrite(sensorPower, HIGH);  // Turn the sensor ON
  delay(10);              // Allow power to settle
  int val = analogRead(sensorPin);  // Read the analog value form sensor
  digitalWrite(sensorPower, LOW);   // Turn the sensor OFF
  return val;             // Return analog moisture value
}






      Video Tutorial




Video link: http://fumacrom.com/ISeI



--------------------------------------------------------------------------------


If you think this is important, subscribe to my youtube channel to know more like this.



Post a Comment

0 Comments