Arduino Soil Moisture Sensor with LCD Project

Arduino Soil Moisture Sensor with LCD Project

Finally, your plants can communicate with you! Just don’t get upset if they’re just letting you know when they need something.
The Soil Moisture Sensor will tell you when your plants need to be watered based on how moist the soil in your pot, garden, or yard is. The sensor’s two probes function as variable resistors. Because water conducts electricity, the more water in the soil, the better the conductivity and the lower the resistance, resulting in a higher signal out.

You can use it in a home automated watering system, connect it to the IOT, or simply use it to figure out when your plant needs some TLC. You’ll be well on your way to developing a green thumb once you’ve installed this sensor and its PCB!

In this project, we’ll show you how to interfacing Soil Moisture Sensor with Arduino and how to program it. Once we successfully interface Soil Moisture Sensor with Arduino, We’ll use an Arduino and an LCD 16×2 module to construct a moisture display. The display constantly monitors the soil moisture value in percentage (%). So, let’s get started on the project!

Components Required  for the Arduino Soil Moisture Sensor with LCD Project

Arduino Uno× 1Amazon
Soil Moisture Sensor× 1Amazon
LCD 16×2× 1Amazon
Breadboard× 1Amazon
Jumper wires× 2Amazon
USB cable type A/B× 1Amazon

Software

Arduino IDE

Soil Moisture Sensor

The Soil Moisture Sensor can determine how much moisture is present in the soil around it. Ideal for keeping an eye on an urban garden or the water level of your pet plant. This is an essential tool for any connected garden!
This sensor conducts current through the soil using two probes, then reads the resistance to determine the moisture level. More water allows the soil to conduct electricity more easily (with less resistance), whereas dry soil does not (more resistance).

Preset (Trimmer pot)

Using the onboard preset, you can adjust the digital output threshold (sensitivity).

Soil Moisture Sensor Features

  • Soil moisture sensor based on soil resistivity measurement
  • Output Digital – 0V to 5V, Adjustable trigger level from preset
  • Output Analog – 0V to 5V based on infrared radiation from fire flame falling on the sensor
  • LEDs indicating output and power
  • LM393 based design
  • Easy to use with Microcontrollers or even with normal Digital/Analog IC
  • Small, cheap and easily available

Applications of Soil Moisture Sensor

  1. Moisture sensoring
  2. Liquid level detection
  3. Botanical gardening
  4. Flood detection
  5. Consistency measurement

Soil Moisture Sensor Specifications

Operating Voltage3.3V to 5V DC
Operating Current15mA
Output voltage signal0 ~ 4.2v
Output ValueDry soil 0 ~ 300
Humid soil 300 ~ 700
Water 700 ~ 950
PCB Size3.2cm x 1.4cm
Cost Check Price

For more information, you can check out the Soil Moisture Sensor Datasheet below:

Arduino Soil Moisture Sensor Connection

Arduino Soil Moisture Sensor Connection
Arduino Soil Moisture Sensor Connection

 

Note: The sensor connects to the 5V.

Arduino Soil Moisture Sensor Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/*** www.arduinopoint.com ***/
/*** Arduino Soil Moisture Sensor Project***/
/*
 # the sensor value description
 # 0 ~300 dry soil
 # 300~700 humid soil
 # 700~950 in water
*/
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup(){
  pinMode(sensorPin, INPUT);
  Serial.begin(9600);
}
void loop(){
 // Get a reading from the Moisture sensor:
  sensorValue = analogRead(sensorPin);  
/*------Display Moisture Sensor Value in Serial Monitor------*/
 Serial.print("Moisture Sensor Value:");
 Serial.println(sensorValue); 
 //Display the Moisture Percentage
 float moisturePercentage;
 moisturePercentage= (sensorValue/1023)*100;
 Serial.print("Moisture Percentage = ");
 Serial.print(moisturePercentage);
 Serial.print("%\n");
 
 //Display the plant need
 if(sensorValue < 300){
  Serial.println("I am thirsty, please give me water");
 }
 else if(sensorValue > 300 && sensorValue < 700){
  Serial.println("I feel so comfortable");
 }
 if(sensorValue > 700){
  Serial.println("Too much water, I might get hurt");
 }
 
 Serial.print("\n");
 delay(500);
} 

Soil Moisture Sensor and LCD Interfacing with Arduino

Now We use an Arduino and an LCD 16×2 module to construct a moisture display. The display constantly monitors the soil moisture value in percentage (%).

Arduino Soil Moisture Sensor with LCD Display Circuit Diagram

Arduino Soil Moisture Sensor with LCD Display Circuit Diagram
Arduino Soil Moisture Sensor with LCD Display Circuit Diagram

Most LCDs include a series resistor for the LED backlight. It should be connected to pin 15 on the back of the LCD (Anode). If your display doesn’t come with one, you’ll need to add one between 5 V and pin 15. A 220 resistor should be fine, but it may make your display a little dim. It’s best to check your device’s datasheet to determine the maximum current rating of the backlight before selecting a resistor value.
You must adjust the LCD display’s contrast. Turning the 10 kΩ potentiometer clockwise or counterclockwise accomplishes this.

Arduino Soil Moisture Sensor with LCD Display Code

/*** www.arduinopoint.com ***/
/*** Arduino Soil Moisture Sensor Project with LCD ***/
// Define to which pin of the Arduino the output of the Arduino Soil Moisture Sensor is connected:
int sensorPin = A0;
int sensorValue = 0; // variable to store the value coming from the sensor
#include<LiquidCrystal.h>
/* Create object named lcd of the class LiquidCrystal */
LiquidCrystal lcd(8,9,10,11,12,13); /* For 4-bit mode */
//LiquidCrystal lcd(8,9,10, 2, 3, 4, 5, 10,11,12,13); /* For 8-bit mode */
byte degree[8] =
{
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
lcd.begin(16,2);
lcd.createChar(1, degree);
lcd.setCursor(2,0);
lcd.print("Arduino Point");
lcd.setCursor(2,1);
lcd.print("Soil Moisture");
delay(2000);
lcd.clear();
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
}
void loop()
{
// Get a reading from the Moisture sensor:
  sensorValue = analogRead(sensorPin);
  
/*------Display Moisture Sensor Value in Serial Monitor------*/
 Serial.print("Moisture Sensor Value:");
 Serial.println(sensorValue);

 //Display the Moisture Percentage
 float moisturePercentage;
 moisturePercentage= (sensorValue/1023)*100;
 Serial.print("Moisture Percentage = ");
 Serial.print(moisturePercentage);
 Serial.print("%\n");
 
 //Display the plant need
 if(sensorValue < 300){
  Serial.println("I am thirsty, please give me water");
 }
 else if(sensorValue > 300 && sensorValue < 700){
  Serial.println("I feel so comfortable");
 }
 if(sensorValue > 700){
  Serial.println("Too much water, I might get hurt");
 }
 
Serial.print("\n");

/*------Display Moisture Sensor Value in LCD------*/
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Soil Moisture");

lcd.setCursor(0,1);
lcd.print(sensorValue);
lcd.setCursor(6,1);
lcd.print("&");
lcd.setCursor(8,1);
lcd.print(moisturePercentage);
lcd.print(" %");
delay(500);
}

Result

 You should see your display constantly monitors moisture surrounding the soil moisture sensor and shows it on the LCD module display in percentage (%). If you cannot see the desired output, ensure the circuit has been properly assembled, and verified and uploaded the code to your board.

Applications:
  1. Monitors Soil Moisture with serial monitor and LCD display.

Leave a Reply