Smart-Irrigation

Logo

Makayla's Engineering Portfolio

View the Project on GitHub MakaylaLundry/Smart-Irrigation

Automatic irrigration and plant watering system

Unlike humans, plants can’t go to a doctor, ask for food, or move to a better location. However, with the automated irrigation system and various sensors, we can create a system that displays the plant’s needs on an LCD screen. Whether it’s efficient light, hydration, humidity, or temperature, this irrigation system has got you and your plants covered. While you can’t directly ask a plant what it needs, by using smart Irrigation, we can come close to understanding it!

Engineer School Area of Interest Grade
Makayla L Chaparral High School Aerospace Engineering Incoming Junior

Final Milestone

In my final milestone, I implanted additional sensors to better monitor the plant’s environment. I incorporated temperature, light, humidity, and rain detection all onto the LCD. Additionally, an automated fan was added to regulate the temperature, in case of any overheating. Throughout these 3 weeks, I spent working on smart Irrigation, I found the most difficult in my last milestone, setting up the photometer, as there were no instructions provided, and I had to greatly modify the code to get the photometer to correctly detect light. I learned how to research efficiently and work diligently. I enjoyed wiring and building my first engineering project, so I plan to continue with Arduino and create additional projects to gain more experience.

Code

// Raindrop 
  int raindropValue = analogRead(RAINDROP_ANALOG);
  lcd.setCursor(0, 0);
  lcd.print("Raindrop: ");
  if (raindropValue > 500) {
    Serial.println("Rain detected!");
    digitalWrite(LEDPIN2, HIGH);
    lcd.print("Yes ");
  } else {
    digitalWrite(LEDPIN2, LOW);
    lcd.print("No  ");
  }
  lcd.setCursor(0, 1);
  lcd.print(raindropValue); 

  delay(2500); //
  lcd.clear();

  // temperature and humidity 
  float temperature = dht.readTemperature(); // Get the temperature value
  float humidity = dht.readHumidity(); // Get the Humidity value

  if (isnan(temperature) || isnan(humidity)) {
    lcd.setCursor(0, 0);
    lcd.print("DHT11 issue");
    Serial.println("DHT11 issue");
  } else {
    lcd.setCursor(0, 0);
    lcd.print("Temp: ");
    lcd.print(temperature);
    lcd.print(" C");

    delay(2500); 
    lcd.clear();

    lcd.setCursor(0, 0);
    lcd.print("Humidity: ");
    lcd.print(humidity);
    lcd.print(" %");

    delay(2500); 
    lcd.clear();

    
    if (temperature > 10) { 
      digitalWrite(FAN, HIGH);
      lcd.print("Fan: ON");
    } else {
      digitalWrite(FAN, LOW);
      lcd.print("Fan: OFF");
    }
  }

  delay(2500); 
  lcd.clear();
}

Second Milestone

In this milestone, I set up and got the photoresistor working for my system to track the light value, and whether that turns out to be high or low. This value is shown on the LCD, within the other values I did in my last milestone. For this to work, I had to try out a couple of different methods to organize and set up the photoresistor, while trying to reduce complications. I used a resistor to make that happen, plus connections along the side of the breadboard and in the analog. In my next and final milestone, I’ll program and set up the rain sensor, ESP8266, cooling fan, and programmer adapter.

Code

//Photoresistor
#define LIGHTPIN A1          
#define LEDPIN 7
           
//LightSensor

  int lightValue = analogRead(LIGHTPIN);  

  if (lightValue >= 1000) {  
    digitalWrite(LEDPIN, HIGH);  
  } else {
    digitalWrite(LEDPIN, LOW);  
  }

 lcd.clear();
  lcd.print("Light Sensor");
  lcd.setCursor(0, 1); // Set cursor to the first column (0) and second row (1)
  lcd.print("Light: ");
  lcd.print(lightValue);
  delay(2000);

First Milestone

To complete my first milestone, I developed a system where the LCD would display and decide whether or not the given plant needed water, and automatically start the pump if necessary. To achieve this, I connected the baseboard to the breadboard, which was crucial to the organization, while also providing 5v and GND connections. Next, I integrated the LCD, soil moisture sensor, and pump into the system. My next step will be setting up the photoresistor to monitor light.

Schematics

image

Code

#include <LiquidCrystal.h>


LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const int AirValue = 693;
const int WaterValue = 290;
const int ThresholdValue = 484;
int soilMoistureValue = 0;
const int RelayPin = 2;


void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(RelayPin, OUTPUT);
  digitalWrite(RelayPin, HIGH);
}


void loop()
{
  soilMoistureValue = analogRead(A0);
  Serial.println(soilMoistureValue);


  lcd.setCursor(0, 0);
  lcd.print("Moisture: ");
  float moisturePercentage = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  lcd.print(moisturePercentage, 0);
  lcd.print("%");


  int upperLimit = ThresholdValue + 0.1 * (AirValue - WaterValue);
  int lowerLimit = ThresholdValue - 0.1 * (AirValue - WaterValue);


  if (moisturePercentage < 30.0)
  {
    digitalWrite(RelayPin, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Pump: ON ");
  }
  else if (moisturePercentage > 70.0)
  {
    digitalWrite(RelayPin, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Pump: OFF");
  }
  else
  {
    lcd.setCursor(0, 1);
    lcd.print("Pump: ");
    if (digitalRead(RelayPin) == LOW)
    {
      lcd.print("ON");
    }
    else
    {
      lcd.print("OFF");
    }
  }


  delay(250);
  lcd.clear();
}
// testing/adjesting for air and water value~~

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1000);
}


Bill of Materials

Part Note Price Link
9V Batteries Powersource $8.43 Link
9V Battery Clip What the item is used for $5.99 Link
1Digital Multimeter What the item is used for $10.99 Link
L9110S DC Motor Drive Module Stepper What the item is used for $7.79 Link
Micro Submersible Mini Water Pump What the item is used for $9.99 Link
Arduino UNO R3 Starter Kit What the item is used for $49.99 Link