Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
40 min
Share

Know when your plant needs watering

A soil moisture sensor is a device that measures the amount of water in the soil. The sensor consists of two metal probes that can be inserted into the soil to measure the moisture levels.

Project Video

Overview

In this tutorial, the Arduino will help you avoid repeating this. It will make the process easier for you, as it usually does.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Soil Moisture Sensor
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the soil moisture sensor and the Arduino, as shown in the image below.

 

Connections from the soil moisture sensor:


     • Positive pin→ comparator op-amp module positive pin


     • Negative pin→ comparator op-amp module negative pin



 Connections from the comparator op-amp module:


     • VCC pin → Arduino VCC pin (5V)


      • GND pin → Arduino GND pin


     • A0 pin → Arduino pin A0

Coding

/*
 Voltaat learn (https://www.voltaat.com)
 Link for full tutorial:
 Tutorial: know when your plant needs watering

 The function of this sketch is to obtain the reading from
 the soil moisture sensor output through the Arduino's input.
 The sensor reading is inversely proportional to the presence of water on its surface.
 We will rely on the signal it sends to the Arduino to determine whether
 or not the soil needs water.

 Connections from the soil moisture sensor:
 • Positive pin→ comparator op-amp module positive pin
 • Negative pin→ comparator op-amp module negative pin

 Connections from the comparator op-amp module:
 • VCC pin → Arduino VCC pin (5V)
 • GND pin → Arduino GND pin
 • A0 pin → Arduino pin A0

*/


//Define the variable soilMoistureSensor to Analog Input Pin A0
const int soilMoistureSensor = A0;

//Define the threshold value
const int threshold = 480;

//Commands inside void setup run once
void setup() {
 //Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);
 //soilMoistureSensor is defined as an input
 pinMode(soilMoistureSensor, INPUT);


}

//Commands inside void loop run forever
void loop() {
 //Read the value of analog input from soilMoistureSensor and assign it in the variable value
 int value = analogRead(soilMoistureSensor);

 if (value < threshold)
 {
   //Print to serial monitor
   Serial.print("Sensor Read= ");
   Serial.println(value);
   Serial.println("There is enough water, no need to water your plants");
 }
 else
 {
   //Print to serial monitor
   Serial.print("Sensor Read= ");
   Serial.println(value);
   Serial.println("The soil is very dry, you need to water your plants!");
 }

 //wait for one second
 delay(1000);


}

Testing it Out

You should also make sure you have chosen the right baud rate (9600) as specified in the code. You can do this by clicking on the drop-down menu at the bottom right corner of the output window.
know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Insert the sensor’s two metal probes into the soil of your flower pot to test it. Make sure it’s completely dry before watering it with a sufficient amount of water.

The serial monitor will now print the sensor read value as well as the status of your soil, indicating whether it requires water or not.

Different plants require different quantities of water. As a result, you may adjust the code’s threshold value to meet your planting water requirements.

know when your plant needs watering

Resources

No items found.