Automated Plant Watering System
Based on Soil Moisture and Water Tank Levels
Introduction
In this automated project, I developed a system dedicated to watering house plants by intelligently responding to soil moisture levels, specific time intervals, and various environmental factors. The design incorporates a tri-hourly moisture detection and indication system, complemented by a pumping mechanism and an alarm system. The goal is to provide optimal growth conditions for house plants by delivering precise and timely hydration. The project, designed as a commercially viable prototype, also features a water tank level indicator for convenient monitoring of the water supply. This innovation aims to simplify and enhance the process of plant care, ensuring a flourishing and healthy environment for indoor greenery.
Methodology
Hardware/Electronics: The system incorporated various electronic elements, comprising an Arduino Nano microcontroller, Moisture Sensor, Relay, 16×2 LCD Screen (for presenting system information), HC-SR04 Ultrasonic sensor, Buzzer (serving as an alarm), DC pump, indicator LEDs, and a power source. Utilizing jumper wires on a breadboard facilitated the interconnection of these components before being housed in a foam board casing.
Programming: Below is the Arduino IDE code for the Automated Plant Watering System based on Soil Moisture and Water Tank Levels to maintain suitable conditions for the plants.
/*
Project Name: Automated Plant Watering System based on Soil Moisture and Water Tank Levels
Author: Dhyey Shah
Date Modified: 17th July, 2022
*/
/*-----------------------------------------------------------------------------START OF MAIN PROGRAM------------------------------------------------------------------------------*/
// Include Libraries
#include <NewPing.h>
#include <LiquidCrystal_I2C.h>
// Defining Variables
#define ledGreen 8
#define ledWhite 9
#define ledRed 10
#define buzzer 4
#define relay 6
#define sm_sensor A2
unsigned long prevTime_1 = 0;
unsigned long prevTime_2 = 0;
// Creating Objects for Peripherals
LiquidCrystal_I2C lcd (0x3F, 16, 2);
NewPing sonar(11, 12, 80);
/*-------------------------------------------------------------------------------------*/
void setup() {
pinMode(ledGreen, OUTPUT);
pinMode(ledWhite, OUTPUT);
pinMode(ledRed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(relay, OUTPUT);
pinMode(sm_sensor, INPUT);
digitalWrite(relay, HIGH); // Relay is Active Low Connected
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello Dhyey !");
lcd.setCursor(0,1);
lcd.print("Sys Status: ON");
delay(3000);
lcd.clear();
Serial.begin(9600);
//digitalWrite(ledGreen, LOW);
}
void loop() {
unsigned long currTime = millis();
unsigned int waterLevel;
unsigned int moisture_val;
// Reading Water Level with Ultrasonic Sensor Every 3 hours:
if ( currTime - prevTime_1 >= 10800 ){
waterLevel = readWaterLevel();
Serial.print("Water Level Detected = ");
Serial.print(waterLevel);
Serial.println(" cm");
// WaterLevel Conditions:
if (waterLevel < 10){
digitalWrite(ledGreen, LOW);
digitalWrite(ledWhite, LOW);
digitalWrite(ledRed, HIGH);
//digitalWrite(4, HIGH);
lcd.setCursor(0,1);
lcd.print("FILL UP TANK !");
Serial.println("Red LED is ON");
Serial.println("Please fill up the Tank !");
// while (waterLevel < 10 && moisture_val >= 200){
// digitalWrite(relay, HIGH); // Active Low Relay Channel
// digitalWrite(4, HIGH);
// playBuzzer();
// }
}
else if (waterLevel >= 10 && waterLevel < 18){
digitalWrite(4, LOW);
digitalWrite(ledGreen, LOW);
digitalWrite(ledWhite, HIGH);
digitalWrite(ledRed, LOW);
Serial.println("White LED is ON");
}
else if (waterLevel >= 18){
digitalWrite(4, LOW);
digitalWrite(ledGreen, HIGH);
digitalWrite(ledWhite, LOW);
digitalWrite(ledRed, LOW);
Serial.println("Green LED is ON");
}
prevTime_1 = currTime;
}
// Reading Soil Moisture Level with Moisture Sensor Every 6 hours:
if ( currTime - prevTime_2 >= 21600 ){
moisture_val = readMoisture();
Serial.print("Moisture Level Detected = ");
Serial.println(moisture_val);
if (moisture_val >= 200){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Moisture: LOW");
lcd.setCursor(0,1);
lcd.print("PUMP ON");
digitalWrite(relay, LOW);
if (waterLevel < 10){
digitalWrite(relay, HIGH); // Active Low Relay Channel
playBuzzer();
}
}
else if (moisture_val > 100 && moisture_val < 200){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Moisture: MED");
lcd.setCursor(0,1);
lcd.print("PUMP OFF");
digitalWrite(relay, HIGH);
}
else if (moisture_val < 100){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Moisture: HIGH");
lcd.setCursor(0,1);
lcd.print("PUMP OFF");
digitalWrite(relay, HIGH);
}
prevTime_2 = currTime;
}
}
/*----------------------------SECONDARY USER FUNCTIONS-------------------------------*/
// Reading Soil Moisture Sensor Value
int readMoisture(){
unsigned int sensor_val = analogRead(sm_sensor);
unsigned int sm_val = map(sensor_val, 0, 1023, 0, 255);
return sm_val;
}
// Reading Bucket Water Level Value
int readWaterLevel(){
unsigned int wl_val = sonar.ping_cm();
return wl_val;
}
// Playing Buzzer Sound
void playBuzzer(){
digitalWrite(buzzer, HIGH);
}
Operation: The system monitors soil moisture every 3 hours and water tank levels every 6 hours. It updates the LCD screen and LED indicators based on the status. When a low moisture level is detected, the relay activates, turning on the DC pump to water the plant. If both moisture and water tank levels are low, the buzzer signals the need to fill the tank only when insufficient moisture is detected.
Results & Discussion
The results of the Automated Plant Watering System indicate effective functionality in maintaining optimal soil moisture levels for plant growth. The system successfully detects low moisture conditions and responds by activating the DC pump to water the plants. The integration of a relay and buzzer enhances user awareness, providing timely alerts for low moisture and water tank levels. The practicality and efficiency of the system in ensuring plant health. Additionally, the real-time status displayed on the LCD screen contributes to user-friendly interaction, making it a valuable tool for plant care. The system was observed to water a single plant for a week and ensured perfect conditioning for the plant moisture monitoring levels (LOW, MODERATE, HIGH). The water tank bucket was filled at 50% of its capacity, twice a week.
Conclusion & Future Work
In conclusion, the Automated Plant Watering System based on Soil Moisture and Water Tank Levels has demonstrated its efficacy in maintaining optimal conditions for plant growth. The consistent monitoring of soil moisture levels, coupled with automatic watering mechanisms, ensures that the plant receives adequate hydration without the risk of overwatering. The integration of an alarm system further enhances user awareness, providing timely alerts for actions such as refilling the water tank. As for future work, there is potential to incorporate advanced sensors and data logging capabilities to gather more comprehensive information on environmental conditions. A controller like ESP8266 NordMCU could add on to the Wi-fi connectivity capabilities where temperature and environmental weather conditions can be included to make adequate predictions on the need for watering the plant. Additionally, exploring connectivity options for remote monitoring and control could further enhance the system’s functionality. Overall, this project lays the foundation for developing smart and adaptive plant care systems that contribute to sustainable and efficient gardening practices.
Additional Documents
More detains about this project: Github Link.
Guide: –