WebsiteSpark

Sunday 27 September 2015

Arduino based, Solenoid controlled small garden irrigation

The aim of this application is to keep the garden plants alive, when we are on vacation.

This uses a solenoid valve, controlled by Arduino UNO for feeding the micro irrigation kit.

Equipment inventory
Solenoid valve
1
Electronically controlled water valve
Arduino UNO
1
The main microcontroller
Single channel Relay
1
To control the current through solenoid
Power supplies
            5V for Arduino
             24 V for solenoid
            Optionally 12V for relay

1
1
1

Drip irrigation water feeder tube

Length varies according to the number of plants / pots to be irrigated
Plumbing accessories

To connect the drip irrigation system to main water inlet.

Arduino library
         Time Library (http://www.pjrc.com/teensy/td_libs_Time.html)
         Time Alarms Library(http://www.pjrc.com/teensy/td_libs_TimeAlarms.html)
          DHT11 Library(http://playground.arduino.cc/Main/DHT11Lib)


Connection block diagram

Arduino Code

#include <Time.h>
#include <TimeAlarms.h>
#include <dht.h>


int pin = 10;
dht DHT;
#define dht_dpin A0;

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(pin,LOW);
  digitalWrite(13,LOW); // don't want the LED on pin 13 glowing
  Serial.begin(9600);

  setTime(22,37,00,27,9,2015); // set the date time of your Arduino
 
  Alarm.alarmRepeat(6,0,0, EarlyMorning); // 6:00am every day
  Alarm.timerRepeat(3600, Hourly);  // timer for every 2 hours  

  Serial.println("");
}

void loop() {
  Alarm.delay(1000); // wait one second between clock display
}

void EarlyMorning(){
  // first thing in the morning open solenoid for 2 mins
  Serial.println("Early morning");
  solenoid(2);
}

void solenoid(int min)
{
  digitalWrite(pin,HIGH); // Open solenoid
  delay(min * 60 * 1000);
  digitalWrite(pin,LOW); // shut solenoid 
}

void Hourly()
{
  Serial.println("Hourly");
  // check during daytime only
  if( hour() >= 8 && hour() <= 17 && ChkTemp())
      solenoid(1);
}


bool ChkTemp()
{
  DHT.read11(A0);
  // if temp > 30 and humidity > 75%
  return (DHT.temperature >= 30 || DHT.humidity >= 75   );
}

Further improvements, to control the solenoid hourly reoccurring function additionally based on moisture level present in the soil rather than just atmospheric temperature and humidity levels.

No comments:

Post a Comment