Project showcase
Plant Moisture Monitoring and Watering with LED Indicator

Plant Moisture Monitoring and Watering with LED Indicator © GPL3+

Monitor your plants and let them water themselves when they are thirsty.

  • 5,828 views
  • 0 comments
  • 13 respects

Components and supplies

Necessary tools and machines

Hand Drill
3/16'' drill bit
09507 01
Soldering iron (generic)

Apps and online services

About this project

Motivation

I work in a rather 'sterile' office, that was once a server room with raised floors. After several years working in there, I got tired of no windows, no outside light, and NO GREEN things, and decided to bring in one of my many plants, from home, in an attempt to bring a little 'green' inside.

I brought the plant in and it's done very well, advancing across my top shelf and apparently pleasingly invading my two adjoining office mates top shelves. They both seem to like it, so I haven't had to bother training it, or moving it.

Working in databases for a living, I sometimes get distracted and forget when I last watered the office plant. I mean it doesn't have a scheduler built in -- how primitive.

I don't have this problem at home as I have a pattern of behavior that deals with plant watering. At the office however, my beautiful plant will over time become a stringy nasty looking thing. Unappealing.

The Build

Enter the solution. I have an Arduino chip laying around that I'm not currently using, and some parts that I've been accumulating over the last 6 months, so I whipped up a quick program to read a moisture sensor and then based on the results lights up a Green or Red color indicator on a RGB LED.

Red is "Water Now", and turns the pump on for 10 seconds, then waits a short time to do another reading. Green is "Nice work, Everything is EXCELLENT".

I liked how well it worked, so I expanded it to handle a second plant as well. With the addition of the second plant, I have tendrils in all my office mates cubes -- much to their pleasure, surprisingly. I figured someone would complain.

So far they seem to be doing very well, though I shut them off for the weekend, at work, just out of paranoia. Testing at home showed no issues.

It is a rather easy setup, and if anyone is really interested I could do a further write up.

Code

Monitoring and watering code.Arduino
Install on Arduino and hook up appropriately.
// Define LED's
const int sensor1redPin = 2;  // R petal on RGB LED module connected to digital pin 2
const int sensor1greenPin = 3;  // G petal on RGB LED module connected to digital pin 3
const int sensor1bluePin = 4;  // B petal on RGB LED module connected to digital pin 4
const int sensor2redPin = 7;  // R petal on RGB LED module connected to digital pin 5
const int sensor2greenPin = 6;  // G petal on RGB LED module connected to digital pin 6
const int sensor2bluePin = 5;  // B petal on RGB LED module connected to digital pin 7

// Define Motors
int motor1 = 9;
int motor2 = 10;

// declare sensors
int sensorValue1;
int sensorValue2;

// declare rates and delay.
int serialRate = 9600;
int loopDelay = 5000;

void setup() {
// set LED's
  pinMode(sensor1redPin, OUTPUT); // sets the redPin to be an output
  pinMode(sensor1greenPin, OUTPUT); // sets the greenPin to be an output
  pinMode(sensor1bluePin, OUTPUT); // sets the bluePin to be an output
  pinMode(sensor2redPin, OUTPUT); // sets the redPin to be an output
  pinMode(sensor2greenPin, OUTPUT); // sets the greenPin to be an output
  pinMode(sensor2bluePin, OUTPUT); // sets the bluePin to be an output
  
  pinMode(motor1, OUTPUT); // motor1
  pinMode(motor2, OUTPUT); // motor2
  
  Serial.begin(serialRate);  // initialize serial communication at 9600 bits per second:
}

void loop() {
// read the input on analog pin 0:
sensorValue1 = analogRead(A0); 
sensorValue2 = analogRead(A1);
Serial.print ("Sensor 1: ");
Serial.print(sensorValue1);
Serial.print("  Sensor 2: ");
Serial.println(sensorValue2);
if (sensorValue1 >= 400){
  // RED LIGHT SOLID
  Serial.println("Sensor 1 - Red");
  setLED1Color(255, 0, 0);
  digitalWrite(motor1, HIGH); // turn on Watering Motor
  delay(10000); // leave pump on for 5 seconds
  digitalWrite(motor1, LOW); // turn off motor.
}
if (sensorValue1 < 400){
  // GREEN LIGHT SOLID
  Serial.println("Sensor 1 - Green");
  setLED1Color(0,200, 0);
  // no motor activation
}
if (sensorValue2 >= 400){
  // RED LIGHT SOLID
  Serial.println("Sensor 2 - Red");
  setLED2Color(255, 0, 0);
  digitalWrite(motor2, HIGH); // turn on Watering Motor
  delay(10000); // leave pump on for 5 seconds
  digitalWrite(motor2, LOW); // turn off motor.
}
if (sensorValue2 < 400){
  // GREEN LIGHT SOLID
  Serial.println("Sensor 2 - Green");
  setLED2Color(0,200, 0);
  // no motor activation
}
delay(loopDelay);
}

void setLED1Color (unsigned char red, unsigned char green, unsigned char blue)     // the color generating function 
{   
  //Serial.println("LED1");
  analogWrite(sensor1redPin, red);  
  analogWrite(sensor1bluePin, blue);
  analogWrite(sensor1greenPin, green);
}
void setLED2Color (unsigned char red, unsigned char green, unsigned char blue)     // the color generating function 
{   
  //Serial.println("LED2");
  analogWrite(sensor2redPin, red);  
  analogWrite(sensor2bluePin, blue);
  analogWrite(sensor2greenPin, green);
}

// Basic colors: 
//color(255, 0, 0); // turn the RGB LED red
/*color(0,255, 255); // turn the RGB LED green 
color(0, 0, 255); // turn the RGB LED blue 
color(255,0,0); // turn the RGB LED red 
color(237,109,0); // turn the RGB LED orange 
color(255,215,0); // turn the RGB LED yellow 
color(34,139,34); // turn the RGB LED green 
color(0,0,255); // turn the RGB LED blue 
color(0,46,90); // turn the RGB LED  indigo
color(128,0,128); // turn the RGB LED purple 
*/
Updated (Better) CodeArduino
// Define LED's
const int sensor1redPin = 2;  // R petal on RGB LED module connected to digital pin 2
const int sensor1greenPin = 3;  // G petal on RGB LED module connected to digital pin 3
const int sensor1bluePin = 4;  // B petal on RGB LED module connected to digital pin 4
const int sensor2redPin = 7;  // R petal on RGB LED module connected to digital pin 5
const int sensor2greenPin = 6;  // G petal on RGB LED module connected to digital pin 6
const int sensor2bluePin = 5;  // B petal on RGB LED module connected to digital pin 7

// Define Motors
int motor1 = 9;
int motor2 = 10;

// declare sensors
int sensorValue1;
int sensorValue2;

// declare rates and delay.
int serialRate = 9600;
unsigned long loopDelay = 3600000;
int wateringDuration = 20000;

void setup() {
// set LED's
  pinMode(sensor1redPin, OUTPUT); // sets the redPin to be an output
  pinMode(sensor1greenPin, OUTPUT); // sets the greenPin to be an output
  pinMode(sensor1bluePin, OUTPUT); // sets the bluePin to be an output
  pinMode(sensor2redPin, OUTPUT); // sets the redPin to be an output
  pinMode(sensor2greenPin, OUTPUT); // sets the greenPin to be an output
  pinMode(sensor2bluePin, OUTPUT); // sets the bluePin to be an output
  
  pinMode(motor1, OUTPUT); // motor1
  digitalWrite(motor1, LOW);
  pinMode(motor2, OUTPUT); // motor2
  digitalWrite(motor2, LOW);
  
  Serial.begin(serialRate);  // initialize serial communication at 9600 bits per second:
}

void loop() {
  Serial.println("Top of Loop");
  // safety measure turn motors off every loop  
  digitalWrite(motor1, LOW); // turn off Watering Motor
  digitalWrite(motor2, LOW); // turn off Watering Motor
  // DO Reads of Sensors
  Serial.println("Read Sensor 1");
  sensorValue1 = analogRead(1); 
  Serial.print ("Sensor 1: ");
  Serial.println(sensorValue1);
  if (sensorValue1 != 0 ) {
    setSensorColorAndRunMotor(1,sensorValue1);
  }
  Serial.println("Read Sensor 2");
  sensorValue2 = analogRead(2);
  Serial.print("  Sensor 2: ");
  Serial.println(sensorValue2);
  if (sensorValue2 != 0 ) {
    setSensorColorAndRunMotor(2,sensorValue2);
  }
  delay(loopDelay);
  Serial.println("Loop End");
}

String setSensorColorAndRunMotor(int intSensor, int intSensorValue){
  if (intSensorValue >= 400){
    // RED LIGHT SOLID
    if (intSensor == 1){
      analogWrite(sensor1redPin, 255);  
      analogWrite(sensor1bluePin, 0);
      analogWrite(sensor1greenPin, 0);
      digitalWrite(motor1, HIGH); // turn on Watering Motor
      Serial.println("Turning on Motor1");
      delay(wateringDuration);
      digitalWrite(motor1, LOW); // turn on Watering Motor
      Serial.println("Turning off Motor1");
    }
    if (intSensor == 2){
      analogWrite(sensor2redPin, 255);  
      analogWrite(sensor2bluePin, 0);
      analogWrite(sensor2greenPin, 0);
      digitalWrite(motor2, HIGH); // turn on Watering Motor
      Serial.println("Turning on Motor2");
      delay(wateringDuration);
      digitalWrite(motor2, LOW); // turn on Watering Motor
      Serial.println("Turning off Motor2");
    }
  }
  if (intSensorValue < 400){
    // GREEN LIGHT SOLID
    if (intSensor == 1){
      analogWrite(sensor1redPin, 0);  
      analogWrite(sensor1bluePin, 200);
      analogWrite(sensor1greenPin, 0);
      digitalWrite(motor1, LOW); // turn on Watering Motor
    }
    if (intSensor == 2){
      analogWrite(sensor2redPin, 0);  
      analogWrite(sensor2bluePin, 200);
      analogWrite(sensor2greenPin, 0);
      digitalWrite(motor2, LOW); // turn on Watering Motor
    }
  }
}

Schematics

watering and monitoring schematic
PlantWateringAndMonitoring.fzz

Comments

Similar projects you might like

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 3,393 views
  • 1 comment
  • 5 respects

An Urban Plant Watering Solution

Project tutorial by James Yu

  • 17,320 views
  • 15 comments
  • 50 respects

Double Plant Watering

Project in progress by adamneareva and Fabio Cardoso

  • 769 views
  • 0 comments
  • 7 respects

Plant Monitoring System

Project showcase by Ryan Gill

  • 34,716 views
  • 33 comments
  • 112 respects

The Quantified Cactus: An Easy Plant Soil Moisture Sensor

Project tutorial by Jen Looper

  • 6,847 views
  • 2 comments
  • 25 respects
Add projectSign up / Login