Simple Garden Watering System




Introduction: Simple Garden Watering System

There are some garden automation systems using Arduino which are fairly detailed. I wanted to develop a simple system for timed watering. One could always develop it using IC555, but the power fluctuations may disturb the watering cycle, and Arduino provides high customization of cycles (plus it's fun!). I tried to use as many household items as possible to keep it simple. Broadly speaking the project involves two steps:

  1. Making a watering hardware (assembling pumps, pipes and all)
  2. Driving the pump via a relay controlled by an arduino with a DS1307 RTC circuit.

Following is the list of stuff:

  • An Arduino. I used Pro Mini. But any model would be fine.
  • A water pump.
  • Pipes and small tubes
  • Relay
  • RTC circuit:

    • DS1307
    • Crystal
    • Two 1k ohm resistors
    • 3V coin battery
    • PCB mount, connectors, wires etc.
  • (OPTIONAL) Relay driving circuit:
    • NPN transistor. (I used 2222. BC548 would do just fine)
    • 1k ohm resistor
    • PCB mount, connectors, wires etc.

  • Container to enclose the assembly

Let's start with the hardware assembly.

Step 1: Hardware Assembly

I tried to use the most basic technique to water my plants. This is not a high precision scientific technique, but it works for me and may as well work for you. (If you already have a motorized watering system in place you can skip this step.)


I used a small 18W submersible water pump used in aquariums etc,. (It cost me ₹220 (i.e. about $3)). It is small but sufficient for me because I have relatively smaller area to cover. I have like 20 odd pots. If you have larger garden you may want to use a larger pump.


I used a tube (about a centimeter in diameter) that ran along the garden (transparent tube seen in the picture). These are the tubes used in household water purifiers. Further smaller tubes (about a size of a ballpen-refill) was pierced in the tube and taken to the pots (they are pinkish in color). They are clamped down by simple metal wires and bamboo twigs. You can use any other means to put them in place.

Depending upon your pump the amount of water coming out will differ. Moreover some pots may require more water than others. Therefore number of holes to pierce will really depend upon your garden. The smaller tubes are not absolutely essential. One can always pierce the holes in the tube and it may work. But the pipes have a tendency to block the holes.

Once you have the hardware in place test it manually and see if you can distribute appropriate amount of water everywhere. It is also advisable to check amount of time required for the pump to distribute, say a 10 liter bucket. This will help you decide how long you want the pump to run.

Once we have the hardware tested manually, we move on to automate it.

Step 2: Automation

The idea is that, at a specific time of day, and for a specific amount of time the Arduino will turn on the relay connected to the pump. To give the Arduino a sense of "specific time" we add a Real Time Clock (RTC) circuit. The RTC will tell the Arduino what time it is, and Arduino will control the relay. If you have a relay operating at 5V, you can directly connect the Arduino output to relay. But I had a 12V relay lying around, which meant I had to build a driver circuit for it. Let's first talk about the driver circuit.

Relay driver circuit

Again, if you have a 5V relay, you don't need this. If you have a higher voltage relay, you can drive it from 5V using an NPN transistor. There are several wonderful tutorials on how to build the driver circuit. See for example :

All you need is a transistor, a diode and a resistor. I used 2N2222 transistor and 1k ohm resistor. A schematic circuit diagram is attached here.

Real Time Clock (RTC) circuit

The RTC is an easy circuit to build. There is a beautiful and detailed instructable on RTC which I followed:

Please note that Arduino's I2C A4 and A5 pins (SDA and SCL respectively) are specifically made to handle the type of data that DS1307 sends. That means you have to use these specific pins only.

Once you have RTC circuit ready, test it with the code given in the same link. Also adjust the time. This will be once and for all. Later on we'll not use this code. You could use any other code to set the RTC time (like this one, which is easier).

Step 3: Timing & Code

Once you've got the hardware, arduino, RTC circuit, (relay driver, if required) and a relay in place you are done, except for final bit of coding. We have to tell Arduino at what time to start the relay and for how much time. I find the Arduino Cron Library most suitable for this purpose. Just download the zip file and unzip it in library folder of Arduino package. Once you get the library you have to figure out how you want to configure your watering cycle.

If you have calculated how much time it takes to empty your bucket and if you know how many buckets you need to water you can do the math to figure out how much amount of time you want your pump to be driven (number of buckets * time to empty one bucket). Moreover you can choose whether to water at once or schedule it throughout the day. So suppose it takes 180 sec to empty one bucket and 2 bucket is the total amount of water I want to supply to my garden, then I have to drive the pump for 360 sec. Further I want to distribute this water not at once but in 24 hour period. In that case my code would look like this:


// Do not remove the include below
#include "Wire.h"
#include "RTClib.h"
#include "SwitchOnCommand.h"
#include "TimedCommand.h"
#include "Cron.h"
#include "SwitchOffCommand.h"

// I have made the trivial changes in the Switch*Command.h files to prevent them from 
// writing on Serial Console.

// create objects for each command
SwitchOnCommand sonCommand;
SwitchOffCommand sOffCommand;

// I am using pin "9" for relay driver. 
// The cron command has following sequence :, command, pin
// '*' means 'every': which means 10,*,*,*,*,* means 10th second of every minute of 
//	every hour of every day of every month of every year. 

TimedCommand command1("00.00.00.*.*.*",&sonCommand,"9"); // Turn on the pin 9 at 12AM everyday
TimedCommand command2("20.00.00.*.*.*",&sOffCommand,"9");// Turn it off at 12:00:20, everyday 

TimedCommand command3("00.00.03.*.*.*",&sonCommand,"9");// 3AM in the night for 20 sec
TimedCommand command4("20.00.03.*.*.*",&sOffCommand,"9");

TimedCommand command5("00.00.06.*.*.*",&sonCommand,"9"); // 6 AM for 20 sec
TimedCommand command6("20.00.06.*.*.*",&sOffCommand,"9");

TimedCommand command7("00.00.08.*.*.*",&sonCommand,"9"); //8 AM for 60 sec
TimedCommand command8("60.00.08.*.*.*",&sOffCommand,"9");

TimedCommand command9("00.00.10.*.*.*",&sonCommand,"9"); //10 AM for 30 sec
TimedCommand command10("30.00.10.*.*.*",&sOffCommand,"9");

TimedCommand command11("00.00.12.*.*.*",&sonCommand,"9");
TimedCommand command12("30.00.12.*.*.*",&sOffCommand,"9");

TimedCommand command13("00.00.14.*.*.*",&sonCommand,"9");
TimedCommand command14("60.00.14.*.*.*",&sOffCommand,"9");

TimedCommand command15("00.00.16.*.*.*",&sonCommand,"9");
TimedCommand command16("20.00.16.*.*.*",&sOffCommand,"9");

TimedCommand command17("00.00.18.*.*.*",&sonCommand,"9");
TimedCommand command18("60.00.18.*.*.*",&sOffCommand,"9");

TimedCommand command19("00.00.21.*.*.*",&sonCommand,"9");
TimedCommand command20("40.00.21.*.*.*",&sOffCommand,"9");

// create an array of timed commands
TimedCommand *tCommands[] = {

// create a cron object and pass it the array of timed commands
// and the count of timed commands
Cron cron(tCommands,20 );

void setup()
  //Serial.begin(9600); // In case you want to see the serial output
  //Serial.println("Starting ArduinoCronLibrary Example");
  // sets the time to be the date and time of the compilation
  //  cron.setTime(DateTime(__DATE__, __TIME__));

  pinMode(8, OUTPUT);
  digitalWrite(8, LOW); // I am using pin 8 for Relay ground.


// The loop function is called in an endless loop
void loop()
  // the loop function checks if a timed command 
  // is due to be executed and executes if it is

Once you upload the code you are done. Your pump will follow the cycle you have programmed.

Be careful when operating the relay at high voltage.

If this tutorial helps, do let me know!


Epilog Contest VII

Participated in the
Epilog Contest VII

Be the First to Share


    • Organization Challenge

      Organization Challenge
    • Block Code Contest

      Block Code Contest
    • Anything Goes Contest

      Anything Goes Contest



    6 years ago

    I'm extremely new to arduino projects. But, I was wondering if in the case that I don't need a relay driver, do I connect the battery to the relay only or should i connect one end to the relay and another to the arduino? any tips greatly appreciated


    Reply 6 years ago

    In principle you can connect relay directly to the arduino, but it may drive too much current through the arduino and can result in overheating. Please go through the comments below by "diy_bloke", they are very informative.


    Reply 6 years ago

    thank you, I found their comments very informative. I'm thinking about switching the RTC for a hygrometer module to code for the pump to kick in when the soil moisture goes below a certain point :)


    7 years ago

    just one correction. I said "a 5 volt relay should have a coil of 125 ohm"

    A word disappeered there, it should be "a 5 volt relay should have a coil of ATLEAST 125 ohm"

    That is if one wants to drive it directly from an I/O port which I really would not advise.


    Reply 7 years ago

    thanks for your valuable comments and links. I appreciate that.:)


    Reply 7 years ago

    Please dont take it as criticism, just wanted to point people to cheap components


    Reply 7 years ago

    No. No offense taken. :)


    7 years ago

    Just one more remark on your relay driver. Wether or not one can drive a relay directly from ones Arduino pin, depends on the relay and especially the current it draws. An Arduino can deliver only 40mA per pin so a 5 volt relay should have a coil of 125 ohm and one should not forget the flyback diode or stand a chance of blowing up the port. It is always safer to build a driver for a 5 volt relay as well, or choose the easy and cheap option of ordering a chinese seller such as Aliexpress
    Similar as what I said for the DS1307, ready to use 5Volt relays including a driver are often cheaper than building it yourself.
    Obviously if you already have a relay like you did, a resistor, BC547 and a diode are all you need to drive it

    Check here for an RTC module (55 cts)

    and here for a 5 Volt relay including driver, leds etc. (66 cents)


    7 years ago

    Well done. just an advice about the RTC. I have built DS1307 RTC's and somehow just the DS1307 bare chip is already more expensive than a ready made module available at DealExtreme, Aliexpress etc.Bought one for 50 ct (in Euro). So for anyone considering this project, mak it easy and cheaper onyrself get such a module or get a DS3231 module for around 1 euro.


    7 years ago

    This is great! I love simple systems like this!


    Reply 7 years ago



    7 years ago

    excellent... I want the exact same thing to test LED's as the uv source and need a reliable water system. thx!


    Reply 7 years ago

    Thanks. I am glad it helped.