Project tutorial

Arduino Irrigation System © CC BY-NC-SA

In this project we want to make an automatic irrigation system with Arduino.

  • 3,891 views
  • 0 comments
  • 19 respects

Components and supplies

Necessary tools and machines

Lasercutter
Laser cutter (generic)

Apps and online services

About this project

Have you ever wanted beautiful plants in your garden?

L’A.I.S, acronym for Arduino Irrigation System, can irrigate the plants in your home to a defined environmental condition, because you mustn’t irrigate them whenever you want.

When the environmental conditions are correct, and it's the correct hour, l’A.I.S will irrigate.

How We Made It

We made it in two distinct parts: the “brain”, that control the system, and the irrigation part, that irrigate the plants.

The Brain

The brain was made with the school’s laser cutter and 6 mm plywood.

First, we thought about how we could make the tank for Arduino and the sensors. We decided to make it with a dovetail. After we drew it with AutoCAD Mechanical, we exported the file and we cut it.

We assembled it and we pasted with Vinavil, after that we made all the electric parts.

The Irrigation Part

The irrigation part was made with a slab of laminated timber, cut with a copping saw.

First, we thought about the structure and we decided to screw the parts without any kind of glue. We increased the height of a part because the water needed to climb down from the tank to the plant’s vase.

We stick “the brain” on the structure and we tested it.

Temperature Sensor

We used the temperature sensor because we want to restrict the ambient conditions that could damage the plant, like irrigation with elevated temperature.

If the temperature is over the limit that you chose, the system will not irrigate.

Real Time Clock

The DS3231 is a low-cost, highly accurate Real Time Clock which can maintain hours, minutes and seconds, as well as day, month and year information.

When the hours and the minutes are the same, you will choose when the system starts.

Keypad

Keypad is used to change the system variable. If you press the “1” key, you change the hour that the system will start. If you press the “4” key, you change the minute that the system will start. If you press the “7” key, you change the limit temperature over which you mustn’t irrigate.

LCD Monitor

The LCD monitor allows you to know what system variable that you can change with the keypad.

In the first line, we will see the hour at which the irrigation starts (Sh) and the current hour (Ch). In the second line we will see the limit temperature (Tl), and the current temperature (Tm).

The potentiometer is used to change the visibility of the LCD display.

Solenoid Valve

The solenoid valve is using to stop the water if it isn’t time to irrigate. We decided to use a solenoid valve because is easier than use a pump.

The solenoid valve is connected to the power supply and the relay, when it is time to irrigate, Arduino will change the state of the relay and in doing so the state of the solenoid valve.

Code

CodeArduino
#include <Wire.h>  //real time clock sensor library
#include <DS3231.h>
#include <LiquidCrystal.h> //LCD monitor library
#include <Keypad.h>  //keypad library

DS3231 clock;
RTCDateTime dt;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);   // initialize the library with the numbers of the interface pins

const byte ROWS = 4; //four rows
const byte COLS = 1; //one column
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1'},
  {'2'},
  {'3'},
  {'4'}
};
byte rowPins[ROWS] = {6, 5, 4, 3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {2}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

int ThermistorPin = A0; // Temperature sensor
int relaypin = 13; //relay pin

int Vore = 0;   //time, in hours
int Vmin = 0;   //time, in minutes
int Vtemp = 0;  //limit temperature
int VOfin = 0;  //end time, in hour
int VMfin = 0;  //end time, in minutes
int Vo = 0;     //conversion

float R1 = 10000;  //temperature sensor variables
float logR2, R2, T, Tc, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

void setup() {
  clock.begin();
  clock.setDateTime(__DATE__, __TIME__);  //set up the real time clock sensor
  pinMode (ThermistorPin, INPUT);
  pinMode (relaypin, OUTPUT);
  lcd.begin(16, 2);   // set up the LCD's number of columns and rows:
  lcd.setCursor(0, 0);     //reset the lcd monitor
  lcd.print ("         ");
  lcd.setCursor(0, 1);
  lcd.print ("         ");
}

void loop() {
  Vo = analogRead(ThermistorPin); // reading the temperature and conversion in celsius
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
  Tc = T - 273.15;
  dt = clock.getDateTime();   //reading the time from the  RTC DS3231
  char customKey1 = customKeypad.getKey();  //reading the keypad key
  if (customKey1 == '1' ) { // change of time 
    Vore = Vore + 1;
    if (Vore > 23) {
      Vore = 0;
    }
  }
  if (customKey1 == '2' ) {
    Vmin  = Vmin + 1;
    if (Vmin > 59) {
      Vmin = 0;
    }
  }
  if (customKey1 == '3' ) { //change of temperature
    Vtemp = Vtemp + 1;
    if (Vtemp > 40) {
      Vtemp = 0;
    }
  }
  lcd.setCursor(0, 0);   // set the cursor to column 0, line 0
  lcd.print ("Sh");      //print the time that it will start (start hour)
  lcd.print (Vore);      
  lcd.print(":");
  lcd.print(Vmin);
  lcd.print("  Ch");   //print the current time (current hour)
  lcd.print (dt.hour);
  lcd.print (":");
  lcd.print(dt.minute);
  lcd.setCursor(0, 1);   // set the cursor to column 0, line 1
  lcd.print ("Tl ");     //print the limit temperature
  lcd.print (Vtemp);
  lcd.print("C");  
  lcd.print(" Tm ");     //print the current temperature
  lcd.print (Tc);
  lcd.print("C");
  if ((dt.hour == Vore) && (dt.minute == Vmin)) {   //condition for irrigation
    if (Tc < Vtemp) {
      digitalWrite (relaypin, HIGH);      //start irrigate
      if (dt.second < 50) {
        VMfin = Vmin + 2;
        VOfin = Vore;        //set the final time of irrigation
        if (VMfin > 60) {
          VMfin = VMfin - 60;
          VOfin = Vore + 1;
          if (VOfin == 24) {
            VOfin = 0;
          }
        }
        delay(50000);      //delay to allow the correct calculation of the final time of irrigation, because we need to calculate it one time and not more//
      }
      delay(1000);       
    }
  }
  else if ((dt.hour == VOfin) && (dt.minute == VMfin)) {
    digitalWrite (relaypin, LOW);   //stop irrigate at final time of irrigation
  }
  else {
    delay(120);   //delay to refresh the LCD monitor
  }
}

Custom parts and enclosures

laser cutter file
dietro_JQS8iTLkXw.dxf
laser cutter file
centralina_alto_(2)_0kMXGylLd7.dxf
laser cutter file
davanti_tZ3iTAlcfe.dxf
laser cutter file
centralina_alto_(2)_qX7CBai7rw.dxf

Schematics

Elettric
collegamenti-elettrici_gZQxkg2Tqy.fzz

Comments

Similar projects you might like

Arduino Atari Adaptor

Project tutorial by Dante Roumega

  • 7,663 views
  • 6 comments
  • 24 respects

Arduino Pendulum Physics Lab

Project tutorial by Paul Kassebaum

  • 1,249 views
  • 0 comments
  • 3 respects

Generating Audio with an Arduino and a Resistor Ladder DAC

Project showcase by 3 developers

  • 2,754 views
  • 5 comments
  • 7 respects

Automated Plant Watering System

Project in progress by Ammar Shahid

  • 502 views
  • 0 comments
  • 4 respects

Humidity Measuring Molecule

Project showcase by KatjaNiggl

  • 1,484 views
  • 4 comments
  • 15 respects
Add projectSign up / Login