Project tutorial
Instant Green Thumb

Instant Green Thumb © GPL3+

Automated irrigation for a small vertical herb garden.

  • 4,494 views
  • 3 comments
  • 18 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
51gzz5eu9pl. sx425
Ultrasonic Sensor - HC-SR04 (Generic)
×1
20120702130508859
DHT11 Temperature & Humidity Sensor (4 pins)
×1
13637 01
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
434MHz RF-transmitter
×1
small indoor fountain pump (submersible) + hose
×1
remote control power socket
×1
timer (optional)
×1

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

What it does:

The basics:

This device will water your plants for you. It was designed for outdoor use (balcony, terrace or any other place where the plants are not watered by rain) but will work indoors just as well.

The details:

  • The brains of the irrigation system is an Arduino Uno with sensors (see parts list)
  • At first it will measure the air temperature. If that is at least 5°C, the program will continue, otherwise it will stop, because it's too cold for watering.
  • Then it will check if there's enough water in the reservoir (e.g. a simple bucket) using an ultrasonic sensor. If there isn't, the pump won't switch on, because dry-running would damage it. If there is:
  • Next it will check if watering is even necessary using a soil moisture sensor. If watering isn't required, nothing will happen obviously and the measuring cycle will repeat after a few minutes. If the soil is too dry:
  • The RF transmitter will switch on the remote control power socket for 10 seconds which will supply power to the pump, thus watering your plants.
  • The measuring cycle will repeat after a minute until soil moisture exceeds the given threshold value. This intermittent watering (10 seconds every minute) has proven to be better than continuous watering, because the water needs some time to sink down to the bottom of the planter, where the soil moisture sensor is positioned. With continuous watering, there would be already too much water in the planter before the sensor can detect it.
  • A timer switch between mains power and the device is recommended. A setting that provides power twice a day (mornings and evenings) will prevent watering around noon, which may cause damage to your plants and is a waste of water anyway.

Parts required:

  • Arduino Uno
  • Soil moisture sensor (e.g. from Sparkfun)
  • Ultrasonic sensor (e.g. HC-SR04)
  • DHT11 temperature-humidity sensor
  • 434MHz RF-transmitter
  • remote control power socket
  • timer (optional)
  • small indoor fountain pump (submersible) + hose

Other requirements:

RF codes:

For the transmitter to be able to switch the remote control socket on and off, you first need to figure out the codes sent by the remote to the socket. For this see library https://github.com/sui77/rc-switch for tutorials and example code

Planter

Currently the system uses a column planter that looks like this:

Mine was available at my local DIY-store as a kit, but you can use any other planter/vertical garden system or even build your own from scratch.

Assembly

Arduino and sensors

see Fritzing diagram and Arduino sketch in attachments

Power supply

The timer is plugged into the mains socked and set to e.g. 7.00-8.00 am and 7.00-8.00 pm. The remote control socket and the Arduino are plugged into the timer, the pump gets plugged into the remote control socket.

Planter

The planter is filled with soil all the way down from top to bottom with the plants sticking out from the sides. The hose from the pump goes into the top, the soil moisture sensor should be placed close to the center at the bottom. Because the soil is one continuous body, the water gets distributed more or less evenly throughout the planter.

The pump is submerged in the water bucket, which is placed beside the planter.

Preview (and problems encountered)

I tried using an Adafruit Feather HUZZAH ESP8266 instead of the Arduino, but as of yet without much success because of the differences in operating voltage: 3.3v for the Feather, but the ultrasonic sensor needs 5v. Also, with the Feather it is extremely difficult to get consistent readings from the soil moisture sensor (analog signal).

I will continue experimenting with Wi-Fi capabilities for the device because it would be useful to be able to view the sensor readings remotely. I did manage to display temperature and humidity readings from the DHT11 on Adafruit IO using the Feather but that didn't work in combination with the ultrasonic sensor.

Suggestions on solving this would be gladly accepted.

Code

Instant green thumbArduino
#include <RCSwitch.h>
#include "DHT.h"

RCSwitch mySwitch = RCSwitch();

//#define
#define MOISTURE A0
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE, 15);

//initial states
int moisturecurrent = 0;
int distancecurrent = 0;
int duration = 0;

//pins
int TRIGGER = 5;
int ECHO = 4;
int POWER = 7;

/************************SETUP****************************/
void setup() {

  dht.begin();

  // set pin as an input/output
  pinMode(MOISTURE, INPUT_PULLUP);
  pinMode(POWER, OUTPUT);
  pinMode(TRIGGER, OUTPUT);
  pinMode(ECHO, INPUT);

  Serial.begin(115200);

  // Transmitter Arduino Pin
  mySwitch.enableTransmit(12);
  mySwitch.setPulseLength(306);

}

/*******************************LOOP**************************/
void loop() {

  //switch off radio-controlled power socket
  mySwitch.send(4212052, 24);
  delay(1000);
  mySwitch.send(4212052, 24);
  delay(1000);

  /*IF1:Temperature>5°C********************************/

  int humidity_data = (int)dht.readHumidity();
  int temperature_data = (int)dht.readTemperature();

  Serial.print(F("Temperature: "));
  Serial.println(temperature_data);

  Serial.print(F("Humidity: "));
  Serial.println(humidity_data);

  if (temperature_data > 5)
  {
    Serial.println(F("Temperature ok"));

    /*IF2:Distance<25cm***************************/

    //Read sensor data: distance
    digitalWrite(TRIGGER, LOW);
    delay(5);
    digitalWrite(TRIGGER, HIGH);
    delay(10);
    digitalWrite(TRIGGER, LOW);
    duration = pulseIn(ECHO , HIGH);
    distancecurrent = (duration / 2) / 29.1;
    delay(1000);

    int distance_data = (int)distancecurrent;

    //publish
    Serial.print(F("Distance: "));
    Serial.print(distance_data);
    Serial.println(" cm");

    //dry-run safeguard for water pump:
    //distance to bottom of water bucket: 30cm; min. water level: 5cm
    //this will probably need adjusting to your specific setup
    if (distance_data < 25)
    {

      /*IF3:moisture<300****************************/

      //Read sensor data: moisture
      digitalWrite(POWER, HIGH);
      moisturecurrent = analogRead(MOISTURE);
      delay(1000);
      digitalWrite(POWER, LOW);

      int moisture_data = (int)moisturecurrent;

      //publish
      Serial.print(F("Soil moisture: "));
      Serial.println(moisture_data);

      if (moisture_data < 400)
      {
        //switch on radio-controlled power socket
        mySwitch.send(4212049, 24);
        delay(1000);
        mySwitch.send(4212049, 24);
        delay(1000);

        //water for 10 seconds
        Serial.println(F("...Watering..."));
        delay(10 * 1000);

        //switch off power socket
        mySwitch.send(4212052, 24);
        delay(1000);
        mySwitch.send(4212052, 24);
        delay(1000);

        Serial.println(F("Waiting 1 min."));
        for (int i = 1; i <= 1; i = i + 1) {
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.println(F("."));
        }

      } //ENDIF3

      else
      {



        Serial.println(F("Watering not necessary at the moment."));
        Serial.println(F("Waiting 10 min."));
        for (int i = 1; i <= 10; i = i + 1) {
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.println(F("."));
        }
      }

    }  //ENDIF2
    else
    {
      if (distance_data > 30)
      {
        Serial.println(F("Error. Unplausible water level."));
      }
      else
      {
        Serial.println(F("Water bucket empty. Refill necessary!"));
      }
      Serial.println(F("Waiting 5 min."));
        for (int i = 1; i <= 5; i = i + 1) {
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.print(F("."));
          delay(20 * 1000);
          Serial.println(F("."));
        }
    }

  }  //ENDIF1
  else {
    Serial.println(F("Too cold for watering"));
  }

} //End loop

Custom parts and enclosures

Planter (sketchup file)
InstantGreenThumb.skp

Schematics

Fritzing diagram
Instant green thumb

Comments

Similar projects you might like

Have a Green Thumb with FlowerDuino

Project showcase by benjamin.notteghem

  • 1,713 views
  • 0 comments
  • 5 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 19,350 views
  • 4 comments
  • 37 respects

Automatic Plant Watering System with Arduino

Project tutorial by Team RobotGeek Projects Team

  • 32,775 views
  • 2 comments
  • 45 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,849 views
  • 17 comments
  • 75 respects

Wireless weather station (Arduino + ESP8266 + Thingspeak)

Project tutorial by Alin-Constantin Paun

  • 8,862 views
  • 2 comments
  • 11 respects

Integrated Solar ChargeController, Inverter, PowerBank, Lamp

Project tutorial by Shahariar

  • 7,755 views
  • 16 comments
  • 30 respects
Add projectSign up / Login