#Deedu Automated Gardening Plant (arduino Uno)

Introduction: #Deedu Automated Gardening Plant (arduino Uno)

INTRODUCTION
The automated gardening kit is a system that allows controlling and automatic watering of a small plant. This system is developed for an educational purpose, the plant shall stay at different pupil's house to be controlled.

The user will take notes every weeks from the control panel to create a database to folllow the growth of the connected plant.

What does it control ?

-The moisture of the soil, this value will be directly used to decide whether to water or not

-The CO2 concentration

-The intensity of the light

-The temperature and the humidity of ambient air

What action can be performed ?

-A water pump will get water from a small reservoir to put it on the plant

-A screen will display the information needed and 2 buttons to control what info to be displayed

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: List of Parts

You will need

electronic control and command part (listed below)

water tank

a plant in a pot

box for electronic (https://www.thingiverse.com/thing:4106140)

3d printed light sensor support (https://www.thingiverse.com/thing:3986667)

3d printed sprinkler (https://www.thingiverse.com/thing:3986672)

The Command & Control part The material used for the Command and Control are the following:

- 1 Arduino UNO link

- 1 moisture sensor link

- 1 CO2 Gas sensor Mq7 link

- 1 Lcd screen 2x16 (+i2c)) link

- 1 LDR light sensor (photoresistor) link

- 2 push buttons link

- 1 Temp + humidity sensor DHT11 link

- 1 5V water pump link

- 1 5v volt relay link

- 3 1k resistor link

- 1 Breadbord or prototyping PCB link

-2 5vpower supply link

Step 2: Connecting Electronic

Digital pin

Pin: 7, relay

Pin: 9, button 1

Pin: 10, button 2

Pin: 13, LED

Analog pin

Pin: A0, Moisture sensor

Pin: A1, Co2 sensor

Pin: A2, Photoresistor

Pin: A3, Temperature sensor

Pin: A4, Screen Rx

Pin: A5, Screen Tx

The connection of Arduino on Water pump alimentation
The Arduino is to be connected directly on the water pump alimentation so the whole system need only one electric plug to works.

The Water pump is a 5V alimentation, the arduino can support that voltage but this lead to a warming of internal component of the arduino and possibly damage on the arduino with time. The easiest and fastest choice for now is two 5v power supply (one for arduino and one for the pump)

For using only one power supply like a 12v one, some solution are linked below

A page presenting the different solutions

Step 3: Code

In this sections is presented how shall be used Deedu system and what shall be the response for it at each cases

UC01 : Control data from sensors & Number of spraying By using one button and looking on the screen, the user shall be able to check on instant value measured by all sensors.

UC02 : Spray the plant when needed & Water tank level control

The system shall be able to water plant when it is needed (The moisture sensor value indicated watering is needed). The water pump is tricky to start (if no water is present in tube, it isn’t powerful enough to start), so the best is to prevent complete emptiness of the water tank. Therefore a solution shall be present to control water tank level and prevent water pumping if water level is too low. A warning shall indicate the user to fill the water tank.

The Arduino code

You can download in the following the arduino code used, every function is commented.
Download the code below on your arduino board

<p>//import the library to control LCD display, this library has been added manually through ZIP file<br>#include 
</p><p>//import library for DHT sensor
#include "dht.h"
#define dht_apin A3 // Analog Pin sensor is connected to</p><p>//create DHT object
dht DHT;</p><p>// create LCD object
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display</p><p>//declaration of variable for buttond
int ButtonOnePin = 10;  //pin for button 1
int ButtonOneState =0 ; //one variable to store current button state
int ButtonOnePreviousState = 0; //one variable to store previous button state
int ButtonTwoPin = 9; // same for button 2
int ButtonTwoState =0 ;
int ButtonTwoPreviousState = 0;</p><p>unsigned long timeBeginDisplay=0;
int timeDisplayPeriod = 6000; //period the 2nd and 3rd screen are displayed
int valToDisplay = 0; //variable to decide what information is to be displayed</p><p>int airTemp; //variable to store air temperature measured by DHT11 sensor
int airHumidity; //variable to store air humidity measured by DHT11 sensor</p><p>int LedPin =  13; </p><p>int waterPumpPin=7; // pin on which is connected the relay that command water pump
int sprayNum=0; //variable to store number of spraying 
int pumpOn =false; //variable used for spraying, it stays ON during the spray timing</p><p>int MoistureHigh = 800; 
int MoistureGood = 710;
int MoistureLow = 630; //threshold that should launch water spray of the plant
int valSoil ;  //variable to store value measured by moisture sensor
int soilPin = A0; // pin on wich is connected moisture sensor
int soilPower = 12;</p><p>int timePeriod = 1000; //variable to store timing in ms, period between each display refresh, a clear is called each time display is called 
int humMeasurePeriod=0; 
unsigned long currentMillis; //variable to store current timing
unsigned long debutMillis=0; //variable used to store timing at the debut of a period
int timePumpPeriod = 3000; //timing for water spraying
unsigned long timePumpDebut = 0; //variable used to store timing value for the debut of a spraying period</p><p>int gazPin = 1; //pin on which is connected gaz sensor
int valGaz ; //variable on which is stored gaz sensor value</p><p>int lightPin = 2; //pin on which is connected the photoresistor
int valLight ; //variable on which light value is stored</p><p>//function to read moisture sensor value
int readSoil()
{</p><p>    digitalWrite(soilPower, HIGH);//turn D7 "On"
    delay(10);//wait 10 milliseconds 
    valSoil = analogRead(soilPin);//Read the SIG value form sensor 
    digitalWrite(soilPower, LOW);//turn D7 "Off"
    return valSoil;//send current moisture value
}</p><p>//function called to refresh LCD screen, displaying wanted screen regarding value of variable "valToDisplay" 
int toDisplay(){</p><p>  lcd.clear(); //clear the screen to remove character that might not be overwritten by new message
  
  if (valToDisplay==0){
    lcd.setCursor(0,0); //to put cursor on 1rst character of 1rst line
    lcd.print("Temp:");
    lcd.setCursor(6,0);
    lcd.print("Hum:");
    lcd.setCursor(11,0);
    lcd.print("Mois:");
    lcd.setCursor(0,1); //to put cursor on 1rst character of 2nd line
    lcd.print(airTemp);
    lcd.setCursor(2,1);
    lcd.print((char)223); //special character for temperature
    lcd.print("C");
    lcd.setCursor(6,1);  
    lcd.print(airHumidity);
    lcd.setCursor(8,1); 
    lcd.print("%");
    lcd.setCursor(11,1); 
    lcd.print(valSoil); 
  }
  else if (valToDisplay==1 && (currentMillis-timeBeginDisplay)</p><p>  if((currentMillis-timeBeginDisplay)>timeDisplayPeriod){ //display original screen when display period is over
    valToDisplay=0;
    //we display in this IF condition the 1rst screen because before there was a blank screen after the timing
    lcd.setCursor(0,0); //to put cursor on 1rst character of 1rst line
    lcd.print("Temp:");
    lcd.setCursor(6,0);
    lcd.print("Hum:");
    lcd.setCursor(11,0);
    lcd.print("Mois:");
    lcd.setCursor(0,1); //to put cursor on 1rst character of 2nd line
    lcd.print(airTemp);
    lcd.setCursor(2,1);
    lcd.print((char)223); //special character for temperature
    lcd.print("C");
    lcd.setCursor(6,1);  
    lcd.print(airHumidity);
    lcd.setCursor(8,1); 
    lcd.print("%");
    lcd.setCursor(11,1); 
    lcd.print(valSoil); 
  }
  
}</p><p>int readTempHum (){</p><p>    DHT.read11(dht_apin); //read value from DHT sensor</p><p>    airTemp = DHT.temperature; //store temperature value from sensor
    airHumidity = DHT.humidity; // store humidity value from sensor
    
    //delay(3000);//Wait 3 seconds before accessing sensor again, without timing, sensor measurement is faulty. we commented this delay because this function isn't called often
}</p><p>int waterPump(){</p><p>  //the condition below to command or not the water pump
  if (valSoil</p><p>  //once the waterpump cycle is launched, this if condition will turn ON the pump on the third of the timePumpPeriod defined, the other 2 third, the water pump will be turned OFF
  if (currentMillis-timePumpDebut=timePumpPeriod && pumpOn==true){
      pumpOn=false; //once pump cycle is over, variable value change to make water spraying dependant on moisture value again
      sprayNum++; //add +1 to the number of spraying performed
  }
}</p><p>int waterTankAlarm(){
  if (sprayNum>10){ //when number of spraying is above limit, turn on led to warn user
    digitalWrite(LedPin,HIGH);
  }
  else {
    digitalWrite(LedPin,LOW);
  }
}</p><p>void setup() { 
  // put your setup code here, to run once:
  Serial.begin(9600);
  //defining wich pin are IN or OUT
  pinMode(LedPin, OUTPUT);      
  pinMode(ButtonOnePin, INPUT); 
  pinMode(ButtonTwoPin, INPUT); 
  pinMode(waterPumpPin, OUTPUT); </p><p>  // initialize the lcd
  lcd.init();                       
  lcd.backlight();
  lcd.setCursor(0,0); 
  lcd.print("Waking up");</p><p>  //ready first temperature and humidity from DHT sensor to store value (since this function isn't called often)
  readTempHum();
  
  delay(2000);
  lcd.clear();</p><p>  
}</p><p>void loop() {</p><p>  //reading of sensor value, not DHT due to the delay needed to its measurement
  readSoil();
  valGaz = analogRead(gazPin);
  valLight = analogRead(lightPin);</p><p>  currentMillis=millis(); //measurement of current time</p><p>  //small function to avoid button rebound, when pressing once on the button, arduino reads only one pressing...
  ButtonOneState=digitalRead(ButtonOnePin); //reading of button value
  if (ButtonOneState !=ButtonOnePreviousState){ //comparing with previous state
    if (ButtonOneState == HIGH){ //if previous state was 0 and current is 1, then take button pressing in account
      delay(200);
      valToDisplay=1;
      timeBeginDisplay=currentMillis;
    }
    ButtonOnePreviousState=ButtonOneState;
  }
  //same function for button 2 as button 1
  ButtonTwoState=digitalRead(ButtonTwoPin);
  if (ButtonTwoState !=ButtonTwoPreviousState){
    if (ButtonTwoState == HIGH){
      delay(200);
      valToDisplay=2; //particular value for "valToDisplay"
      timeBeginDisplay=currentMillis;
    }
    ButtonTwoPreviousState=ButtonTwoState;
  }
  
  waterPump(); //calling for water pump function which launch spray cycle if needed</p><p>  waterTankAlarm(); //calling function to warn user about water tank level</p><p>  //small condition for screen refreshing and measurement of DHT sensor
  if (currentMillis-debutMillis>timePeriod){ //end of a period
    debutMillis=currentMillis; //define the begining of a new period
    toDisplay(); //refresh of the screen regarding "valToDisplay" value
    humMeasurePeriod++; //DHT sensor values are measured every 20 times the screens is refreshed
    if (humMeasurePeriod>20){ //go to measure DHT values
          readTempHum();
          humMeasurePeriod=0;
    }</p><p>  } </p><p>}</p>

Step 4: Printing and Cutting Parts

All the files designed for this project are available on thingiverse.

Laser cutted wooden box: https://www.thingiverse.com/thing:410614

3d printed sprinkler: https://www.thingiverse.com/thing:3986672

3d printed Light sensor support: https://www.thingiverse.com/thing:3986667

Step 5: Credit


This kit was made by Pralnia Makerspace, Poland under the supervision of Digijeunes.

http://pralniasokolowsko.pl/

http://www.digijeunes.com/


This tutorial has been produced as part of the DEEDU project, co-financed by the Erasmus + Programme of the European commission. Project n°: 2018-1-FR02-KA205-014144.

The content of this publication does not reflect the official opinion of the European Union. Responsibility for the information and views expressed therein lies entirely with the authors. For more information, email us at info@digijeunes.com

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions