know when your plant needs watering🌱

If you enjoy having natural flowers and plants, you are aware of how important it is to care for them on a daily basis.


Perhaps some of your favorite flowers died because they needed water while you were busy.


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

Overview


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.


Soil moisture sensors are used in a variety of applications, including irrigation, water conservation, and agricultural monitoring systems.


We will use the soil moisture sensor to monitor your plants' water needs. While the sensor is implanted in the soil, it can read the moisture level regularly. We will display those values on your computer, as well as the soil's state, whether it needs water or not.




Getting the items


For this project you will need the following components, you can buy them from our store.

Sale Off
Voltaat Arduino Uno R3 (Voltaat Version)
45 QAR
Sale Off
Voltaat Soil Moisture Sensor
16 QAR
Sale Off
Voltaat Jumper Wires - Male to Male (40 Pack)
10 QAR

Wiring it up



To set up the soil moisture sensor in the correct way, follow the instructions below. The image demonstrates how to connect the wires between the soil moisture sensor and the Arduino. Once the soil moisture sensor and the Arduino are connected to each other, connect the Arduino to your computer using the USB cable.


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


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.


If it is high, it means the soil is dry and you need to water your plants. If it is low, it means there is enough water for your plant and there is no need to water it now.


You can adjust the sensor's threshold value by changing the potentiometer on the op-amp comparator module, just like the way of changing LCD brightness.


It is really simple and easy. Let’s test out the code together!

 

/*
Voltaat learn (https://www.voltaat.com)
Link for full tutorial: https://bit.ly/3ToWxdq

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




Now you must have correctly wired the soil moisture sensor to the Arduino as we explained in the wiring section, as well as uploaded the code to your Arduino board.


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


The serial monitor is a great tool that can facilitate communication between the computer and the Arduino. It can allow us to send and receive different commands, as well as view information directly from the Arduino.


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.


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.

 

Resources 


Arduino Code

Fritzing Wiring file

Related Tutorials


A "buzzer" is an electrical device that makes an alarm sound. It is usually used to indicate when someone has pressed a button or to give a warning sound. Buzzers come in different shapes and sizes.


In this tutorial, we will use the Arduino to read the resistance of an LDR and detect darkness. This project may be expanded to control an LED to turn on when the light goes out and off when it comes back, similar to how a street light works!



Most of us are familiar with the switches used in household devices. A relay is a type of switch that can be connected to an Arduino or any other microcontroller.