Arduino Gardening

Arduino Gardening

It’s a burning summer in Florence and I needed a solution to watering my little plants I have around the house.

Of course I had a look at some shops for a ready solution, but where is the joy of experimenting with an arduino?

First thing to do in this case is to know what you want, and where your project could drive you. It’s nice to fly high with ideas, but to make them affordable you have to take off first.

So here we are with our project/tutorial: a time programmed irrigator which will water my plants for 1 minute, once a day, on alternate days.

The whole thing costs around 25$ (we’ve bought almost everything from china).

What we’ve used


Wiring Diagram

Wiring Diagram


I wanted to make arduino water my plants on alternate days, so we had to add a little function ‘dayOfYear’ which will tell us (guess what?) the day of the year it is. Example: February 1st is the 32nd day of the year, and our function will return ’32’.

Maybe there was a better solution, or it was already implemented, but this way was faster for our purpose.

If the day number it’s even and the time correspond to what I’ve set, it will close the relay (and the valve will open).

We’ve used the RTClib (with the little edit I mentioned about ‘dayOfYear’) to control and read the RTC.

The Sketch

The Function We Added

We have modified the class DateTime in RTClib.h as follow:


and added  the following function to RTClib.cpp:


Possible Developments

As you’ve seen this is a really stupid implementation, but it was on our purpose to make it stupid and not including any sort of display.
In fact, the main project is a little bit bigger than just a programmable Garduino (as someone calls it).

What we have in mind is to make the Garduino just an interpreter for our garden architect “Mr Rasp Gardner”, a raspberry pi which will communicate with the arduino using the NRF24l01+ module we tested here. As you can imagine, this drive us to an intelligent gardener, a nice web interface, statistics and much (much) more.


One of the first thing to implement, apart wireless communication, could be a simple hygrometer which will tell us if the plants have actually been watered. Maybe next week.




Post a comment
  1. matus #
    May 26, 2017

    Hello and sorry for my bad english 🙁 .I am a beginner in arduino and i want to make a aquarium controlled with arduino.For this i write to you.Can you help me?I want to switch on and off the aquarium lights through arduino nano,rtc ds3231 and 8 channel relay(using 2 relays one for lights and second for air pump).Can you write the code for me on my email?thanks 🙂

  2. preeth rao obley #
    May 5, 2016


    i just want to know how the code changes if i want to water the plants on daily basis once at a particular time period ?

  3. ed #
    December 8, 2015

    very interesting hack
    yet it seems it calculates wrong. It is now december 8 and it tells me it is day 86.
    Compiles properly but the calculation somehow seems wrong 🙂 I will do some more digging myself but would appreciate some pointers

    • ed #
      December 8, 2015

      If I make a printout of the cumulating days, I get the following result:
      So the accumulation is right, but somehow the return value is wrong

      • ed #
        December 8, 2015

        I already discovered where the mistake is: 342-86=256 Hmmm seems only the low byte is returned,
        Not surprising as it is defined as uint8_t
        dayOfYear should be defined as uint_16 in both the .h and the .cpp file

        • December 11, 2015

          Hi, thank you for pointing the error out. This blog goes on thanks also to the help of people like you. Can you share the edits you’ve made to make the code behave as supposed so I can update the post? Thank you.

          • ed #
            December 20, 2015

            define the dayOfYear as uint16_t rather than uint8_t

            If you chech my values it is clear the MSB wascut off as 342-86=256

  4. JenFox #
    May 15, 2014


    Super awesome project! I’m working on a similar system for an urban farm in Inglewood, CA where residents are building a new food system. Here’s a quick video of my first prototype:

    I came across your project while researching the NRF24L01. Are you interested in collaborating, and/or is it ok w/ you if I incorporate aspects of this project in my next prototype (which will hopefully be installed and utilized in the urban farm)? You can reach me at the e-mail address provided. Thanks!

    • May 16, 2014

      Glad to know our work was useful and that you are spreading the word!
      I don’t have the time follow other projects at the moment, but keep us informed with future developments!
      Feel free to use our work, it is released under Creative Commons CC-BY-SA

  5. September 3, 2013

    Done! This is the link:
    Congrats for the project!

  6. September 2, 2013

    This is an awesome project! We will post a backlink to your project in our blog if you agree, at

    • September 2, 2013

      @Anton sure! Thank you for sharing.

      • mahmood #
        December 15, 2014

        Hi Edoardo …. nice project and smart …. but I have a problem. I would appreciate if you could help me, please.

        When I upload the code, the compiler says “class datetime’ has no member named”. Can you point me to a solution?

        • December 15, 2014

          Hi Mahmood,
          did you include all the libraries, the class and functions we added?

          Note: I’ve edited a bit your comment, to make understandable to all the readers. Please, for further comments, use a clear, plain english and avoid abbreviations. It helps a lot understanding your question, and save my time (plus it makes me more prominent to answer). Thank you.

          • mahmood #
            December 16, 2014

            Hi Edoardo I am soo sorry for my English Language ..I’ll do it certainly

            I already have librarie for RTC but I dont know how I can add the class and functions .. I was try Writing your the class and function to notepad and moved to my libarie folder but Does not work ..

            sorry again I am new in this area but I want learn ….

            thank you

Leave a Reply

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

By continuing to use the site, or scrolling, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.