Here is a project for you whom is like me, you like fresh herbs when cooking food but is to absent minded to water them all the time (seriously basil need watering every single day in the summer!).

So to solve the watering problems I have put together a small self watering system. It simply checks if the plant needs water and if it does it gets it. So how is it done?

When you power up the system it turns on the power to the sensors (if the power is on all the time to the sensors there will be an electrolytic reaction and the metal on the moisture probes will erode away very fast) using, in my case, a DIL relay but you can use what ever you have laying around. The system then checks the moisture in the plants one at the time, if the moisture is to low (I have set this to 300 in the code, higher = dryer, lower = wetter) it will turn on that plants designated pump and run it for 2s. It then waits for 3min to let the water spread out and then check again and if the level is high enough it will move to checking the next plant using the same procedure. When all the plants is at the right moisture level the system will turn of the sensors and wait for 3h before repeating.

The system in the current configuration is made for two plants but you can update it for 6 (the amount of analogue ports on the Arduino board dictates it, one port per plant).

I will update this post when I have made a schematic of the system but for now you have to use your ingenuity!

The stuff

1 x Arduino Nano: https://www.banggood.com/ATmega328P-Nano-V3-Controller-Board-Compatible-Arduino-p-940937.html

2 x Moisture Sensor: https://www.banggood.com/Soil-Hygrometer-Humidity-Detection-Module-Moisture-Sensor-For-Arduino-p-79227.html

1 x L9110S Motor Controller: https://www.banggood.com/L9110S-H-Bridge-Stepper-Motor-Dual-DC-Driver-Controller-Module-p-914880.html

2 x Mini Pumps: https://www.banggood.com/Mini-Submersible-DC-Motor-Pump-3V-120LH-Low-Noise-Max-Lift-p-87235.html

1 x DC-DC Voltage Converter (Optional but handy in my opinion): https://www.banggood.com/DC-DC-Voltage-Converter-Multi-output-Power-Supply-Module-12V-to-3_3V5V12V-p-1020749.html

1 x Random Jumper Leeds ie: https://www.banggood.com/40Pcs-20cm-Male-To-Female-Jump-Cable-For-Arduino-p-973822.html

1 x Mini Prototype Board (If you don’t want to solder everything): https://www.banggood.com/Mini-Solderless-Prototype-Breadboard-170-Hole-Self-adhensive-For-Arduino-p-1039378.html

1 x Random relay or transistor for switching on the sensors, I had a DIL VR05R241 laying around so used that one: https://www.kjell.com/se/sortiment/el-verktyg/elektronik/elektromekanik/relaer/1-poligt-dil-rela-5-v-dc-0-5-a-30-v-p36110

1 x Power supply, I used this one: https://www.kjell.com/se/sortiment/el-verktyg/stromforsorjning/nataggregat/ac-dc/stallbar-utspanning/stallbar-natadapter-3-12-v-(dc)-3-6-w-p44108

1 x Housing. Take what you find, I just used a random connection box.

And some heat shrink, electrical tape, soldering iron, solder etc. The usual.

The Code

/**
 * Project: Green Finger
 * Self watering system
 * Author: Henrik Norberg
 * E-mail: henrik@dbhn.se
 */

// motor one
int en1_A = 5; //Arduino digital 8 is connected to HG7881's A-1A terminal
int en1_B = 6; //Arduino digital 9 is connected to HG7881's A-1B terminal

int en2_A = 8; //Arduino digital 8 is connected to HG7881's B-1A terminal
int en2_B = 9; //Arduino digital 9 is connected to HG7881's B-1B terminal

int mostureSensor1 = 6;
int mostureSensor2 = 7;

int trigger = 2; //Power on/off sensors to prevent corrotion

// Sensor states, 0 = Dry, 1 = Moist
int sensor1 = 0;
int sensor2 = 0;

void setup() {
    // Serial Begin so we can see the data from the mosture sensor in our serial input window. 
  Serial.begin(9600);
 // set all the motor control pins to outputs
  pinMode(en1_A, OUTPUT); //direction
  pinMode(en1_B, OUTPUT); //speed

  pinMode(en2_A, OUTPUT); //direction
  pinMode(en2_B, OUTPUT); //speed

  pinMode(trigger, OUTPUT); //Trigger
}

void loop() {
  //Set engine direction
  analogWrite(en1_A, LOW);
  analogWrite(en2_A, LOW);
  // now turn off motors
  analogWrite(en1_B, 0);
  analogWrite(en2_B, 0);

  digitalWrite(trigger, HIGH);
  Serial.println("Sensors on");
  delay(1000);

  sensor1 = 0;
  sensor2 = 0;
  Serial.println("Sensors set to 0");
  while (sensor1 == 0){
    // read the input from sensor1:
    int sensorValue = analogRead(mostureSensor1);
    Serial.println(sensorValue);

      if (sensorValue >= 300 )
       {
        // turn on motor
        // set speed out of possible range 0~255
        analogWrite(en1_B, 70);
        delay(2000);
       // now turn off motors
        analogWrite(en1_B, 0);
        delay(180000);
      }
       else {
          sensor1 = 1; 
          Serial.println("Sensor 1 OK!");
        }
  }     
  delay(1000);  
  while (sensor2 == 0){
    // read the input from sensor1:
    int sensorValue = analogRead(mostureSensor2);
    Serial.println(sensorValue);

      if (sensorValue >= 300 )
       {
        // turn on motor
        // set speed out of possible range 0~255
        analogWrite(en2_B, 50);
        delay(2000);
       // now turn off motors
        analogWrite(en2_B, 0);
        delay(180000);
      }
       else {
          sensor2 = 1; 
          Serial.println("Sensor 2 OK!");
        }
  }    

  delay(400);
  digitalWrite(trigger, LOW);
  Serial.println("Sensors off, sleep");
  delay(14400000);
}

The Future

A future development could be to make it an IoT device, sending plant data to a server for all your plant geekiness needs.