Activity9 - Automated Plant Watering System
Activity9 - Automated Plant Watering System
Circuit Diagram:
1. Activity Title:
Activity 9: Automated Plant Watering System
2. Objective:
Develop an automated plant watering system using soil moisture sensors to
determine when to water the plants. The system will provide real-time status
updates using an LCD display and LED indicators without any data logging or
internet connectivity.
3. Materials Used:
• Arduino Uno
• Buzzer
* Author: Demilson Moreira Bose Junior, Leonardo Pereira Barros de Camargo, pinMode(WaterPump, OUTPUT); // Set the water pump pin as output
Pedro Didoné de Vasconcelos *
pinMode(LedRed, OUTPUT); // Set the red LED pin as output
* 23S Internet of Things - Arduino - 207 COMP1045-23S-31962 *
pinMode(LedGreen, OUTPUT); // Set the green LED pin as output
* Date: 11/07/2023 *
pinMode(BuzzerPin, OUTPUT); // Set the piezo buzzer pin as output
* Time: 4:00 pm */
// Include the LiquidCrystal library, which provides functions to control the LCD
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
display.
pinMode(BuzzerPin, OUTPUT); // Set the piezo pin as output
// Declaring variables
lcd.clear(); // Clear the LCD display
const int BuzzerPin = 10; // Pin connected to the piezo buzzer
lcd.setCursor(0, 0); // Set the cursor to the first column and first row
const int LedRed = 12; // Pin connected to the red LED
// Display "Automated Plant" on the first row of the LCD with a delay of 100ms
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // Create an instance of the LiquidCrystal class
between characters
to control the LCD
for (int i = 0; i < message1.length(); i++) {
lcd.print(message1.charAt(i)); void loop()
delay(100); {
// Display "Watering System" on the second row of the LCD with a delay of lcd.setCursor(11, 0); // Set the cursor to the 12th column and first row
100ms between characters
lcd.print(mappedValue); // Display the mapped value (moisture
for (int i = 0; i < message2.length(); i++) { percentage) on the first row
lcd.print(message2.charAt(i)); lcd.setCursor(14, 0); // Set the cursor to the 15th column and first row
delay(100); lcd.print("%"); // Display the percentage symbol on the first row
} lcd.setCursor(13, 1); // Set the cursor to the 14th column and second
row
lcd.clear(); // Clear the LCD display again // Control the water pump and LEDs based on the moisture percentage
lcd.setCursor(0, 0); // Set the cursor to the first column and first row if (mappedValue < 50) {
lcd.print("Moisture ="); // Display "Moisture =" on the first row digitalWrite(WaterPump, HIGH); // Turn on the water pump
lcd.setCursor(0, 1); // Set the cursor to the first column and second row digitalWrite(LedGreen, HIGH); // Turn on the green LED
lcd.print("Water Pump ="); // Display "Water Pump =" on the second row digitalWrite(LedRed, LOW); // Turn off the red LED
else { Connect a 16x2 LCD display to show current moisture levels and system status.
digitalWrite(WaterPump, LOW); // Turn off the water pump If using an I2C LCD, connect:
lcd.print("OFF"); // Display "OFF" on the second row LED and Buzzer for Alerts:
tone(BuzzerPin, 87, 100); // Play a tone of 87 Hz for 100 milliseconds on the Activate the water pump when moisture falls below a set threshold.
piezo buzzer
Display real-time data on the LCD.
delay(1000); // Delay for 1 second
} Trigger the LED (and buzzer) if the moisture is critically low.
6. Procedure: How It Works:
Connect the Soil Moisture Sensors:
Reading Moisture Levels:
Connect the analog output of each soil moisture sensor to the analog input pins
on the Arduino (e.g., A0, A1). The soil moisture sensor provides an analog value corresponding to the soil’s
moisture level.
If monitoring multiple plants or different soil areas, use multiple sensors.
This value is displayed on the LCD in real-time.
Interface the Water Pump or Solenoid Valve:
Water Pump Activation:
Connect the relay module’s input to a digital pin on the Arduino (e.g., D8).
When the soil moisture level falls below the set threshold, the relay module
The relay output will control the water pump. activates the water pump.
Make sure to use a flyback diode to protect the Arduino from voltage spikes. The pump automatically stops when the moisture level is above the threshold.
Visual and Audible Alerts:
Real-Time Monitoring:
The LCD display shows both the moisture level and system status (e.g.,
“Watering…” or “Soil OK”).
10. References:
https://www.tinkercad.com/things/6ju2isA9JHD/editel