Skip to main content

Soil Moisture Sensor with Arduino Uno

Working of Sensor

The soil moisture sensor consists of two probes which are used to measure the volumetric content of water. The two probes allow the current to pass through the soil and then it gets the resistance value to measure the moisture value.

When there is more water, the soil will conduct more electricity which means that there will be less resistance. Therefore, the moisture level will be higher. Dry soil conducts electricity poorly, so when there will be less water, then the soil will conduct less electricity which means that there will be more resistance. Therefore, the moisture level will be lower.

This sensor can be connected in two modes; Analog mode and digital mode. First, we will connect it in Analog mode and then we will use it in Digital mode.
Specifications
The specifications of the soil moisture sensor FC-28 are as follows:
Input Voltage3.3 – 5V
Output Voltage0 – 4.2V
Input Current35mA
Output Signal
Both Analog and Digital

Pin Out – Soil Moisture Sensor for Analog Pin
The soil Moisture sensor FC-28 has four pins:
  • VCC: For power
  • A0: Analog output
  • D0: Digital output
  • GND: Ground

The Module also contains a potentiometer which will set the threshold value and then this threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value.
Analog Mode – Interfacing Soil Moisture Sensor and Arduino
To connect the sensor in the analog mode, we will need to use the analog output of the sensor. When taking the analog output from the soil moisture sensor FC-28, the sensor gives us the value from 0-1023. The moisture is measured in percentage, so we will map these values from 0 -100 and then we will show these values on the serial monitor.You can further set different ranges of the moisture values and turn on or off the water pump according to it.

Pin Out – Soil Moisture Sensor for Digital Pin
The connections for connecting the soil moisture sensor FC-28 to the Arduino in digital mode are as follows.

  • VCC of FC-28 to 5V of Arduino
  • GND of FC-28 to GND of Arduino
  • D0 of FC-28 to pin 12 of Arduino
  • LED positive to pin 13 of Arduino
  • LED negative to GND of Arduino
Digital Mode – Interfacing Arduino and Soil Moisture Sensor
To connect the soil moisture sensor FC-28 in the digital mode, we will connect the digital output of the sensor to the digital pin of the Arduino. The Sensor module contains a potentiometer with it, which is used to set the threshold value. This threshold value is then compared with the sensor output value using the LM393 comparator which is placed on the sensor module.The LM393 comparator will compare the sensor output value and the threshold value and then gives us the output through the digital pin. When the sensor value will be greater than the threshold value, then the digital pin will give us 5V and the LED on the sensor will light up and when the sensor value will be less than this threshold value, then the digital pin will give us 0V and the light will go down.

Arduino Code for Analog Pin

/*******
 All the resources for this project:
 https://lihuo.blogspot.com
*******/ int sensor_pin = A0;
int output_value ;

void setup() {

   Serial.begin(9600);

   Serial.println("Reading From the Sensor ...");

   delay(2000);

   }

void loop() {

   output_value = analogRead(sensor_pin);

   output_value = map(output_value,550,0,0,100);

   Serial.print("Mositure : ");

   Serial.print(output_value);

   Serial.println("%");

   delay(1000);

   }

Arduino Code for Digital Pin


int led_pin = 13;
int sensor_pin = 8;

void setup() {

  pinMode(led_pin, OUTPUT);

  pinMode(sensor_pin, INPUT);

}

void loop() {

  if(digitalRead(sensor_pin) == HIGH){

    digitalWrite(led_pin, HIGH);

  } else {

    digitalWrite(led_pin, LOW);

    delay(1000);
  }
}



Comments

Popular posts from this blog

The laws of set algebra & Laws derivable >> in the table 5.1 & 5.2 :

Ans :       Commutative laws                             Ans:          Associative laws Ans:         Distributive laws       Ans:            Identity laws Ans:         Complement laws Ans:          Absorption laws Ans:         Minimization laws Ans:         De Morgan’s laws

Exercise Chapter7 : Vectors

VECTORS AND SCALARS: BASIC CONCEPTS Exercise 7.2 Solution : 1. For the arbitrary points A, B, C, D and E, and a single  vector which is equivalent to A:   DC + CB    = DB B:  CE + DC   = DE 2.  shows a cube. Let p =  AB, q =  AD and  r =  AE . Express the vectors representing  BD,  AC and  AG in terms of p, q and r. Consider the triangle ABD shown in Figure. We note that  BD represents the third  side of the triangle formed when AD are placed head to tail. Using the triangle law we find :                      AB + BD = AD               => BD = AD - AB                             = q - p Consider the triangle  ADC  shown in Figure. We note that  AD  represe...

Matrix algebra

                 Matrices provide a means of storing large quantities of information in such a way that each piece can be easily identified and manipulated. They permit the solution of large systems of linear equations to be carried out in a logical and formal way so that computer implementation follows naturally. Applications of matrices extend over many areas of engineering including electrical network analysis and robotics. 1-BASIC DEFINITIONS                  Matrix is a rectangular pattern or array of numbers.      For example:                    are all matrices. Note that we usually use a capital letter to denote a matrix, and enclose the array of numbers in brackets. To describe the size of a matrix we quote its number of rows and columns in that order so, for example, an r × s matrix has r rows and s colu...