luca 04/08/2015 36


Irrighino is a complete watering system, based on Arduino Yun.

The main features are:

  • a configurable number of solenoid valves
  • an AJAX web interface
  • a weekly schedule
  • manual activation / deactivation

Here’s a short video that describes the project:

How it works


An Arduino Yun – the “brain” of irrighino – is connected to the switch panel (with phsical switches and status leds), the rain sensor and the relay board that controls the solenoid valves. Yun is also connected to the home wifi network: a device (PC, smartphone…) connected to the same network can open the irrighino webinterface and configure and control it.

If you have an Internet connection, with the correct NAT (Network Address Translation) settings you can also manage your watering system from a remote location!

Web interface

The irrighino web interface is available at the following URL: http://<yun-ip-address>/sd/irrighino

The interface is divided in 3 tabs:

  • runtime, where you can manually control the system
  • setup, where you can configure the scheduling
  • events, where you can read the event log (activation, configuration changes…)

 irrighino-runtimeRuntime tab, you can manually control each valve


Setup tab, you can define the weekly schedule


Events tab, you can read all the events


I connected the different elements (switches, leds, relays…) to Arduino using a prototype shield:

irrighino-shield1 irrighino-shield2

I used 3 position switches (onoffauto) and I read the switch status using an analog PIN as explained in this my tutorial.

LEDs are connected to digital PINs through 1k ohm resistors, while the relay board (that I got from this store) can be connected directly to the PINs because it carries all the required components (transistors…) to drive the relays.

I drilled holes in the front panel for all the LEDs and the switches and connected them to the shield:

irrighino-shield3 irrighino-shield4


I put the Yun in a plastic enclosure for DIN rails (6 units). When closed, I noticed that the wifi signal strength was very poor… I therefore decided to add an USB wifi adapter with an external antenna, as explained in this my tutorial. I mounted the antenna outside the enclosure and connected it to the adapter with an RP SMA male to female cable brought on eBay:

irrighino-shield6 irrighino-shield9

irrighino-shield7 irrighino-shield8

The relay module has been mounted on a dedicated box:

irrighino-shield11 irrighino-shield12

The power is supplied by two transformers, one with a voltage of 5V (for the electronic circuitry) and one with a voltage of 24V (for the solenoid valves). The two trasformers and the main switch are located in a different DIN rail enclosure. Here’s also a shot about the final installation:

irrighino-shield10 irrighino-shield13


The watering system is divided into zones, each one connected to a solenoid valve.

I put the valves in cockpits. Each valve is connected to a relay, that supplies the correct power (24v) when activated:

irrighino-shield14 irrighino-shield15

The rain sensor is no more than a switch controlled by a spongy material. When this material absorbs the rain, it begins to expand up and triggers the switch. So you can read its status connecting it to an Arduino digital PIN (in my sketch I used the internal pullup resistor):


#define RAIN_SENSOR        8


The software that runs irrighino is divided in 3 elements:

  • the web interface (AJAX, running on the browser) based on the following javascript libraries: jQuery, jQuery DataTables and jQuery WeekCalendar
  • the backend subsystem, based on PHP and SQLite
  • the sketch, running on the ATMega that controls valves and LEDs and read the status of sensors and switches

Thanks to a configuration file (include.php) you can customize the number of outputs, their name and color…:


All the code is available on Github. The README file (that will be updated at every new release) explains how to install, configure and customize!


  1. Max 08/08/2015 at 07:06 - Reply

    Buongiorno Luca, complimenti innanzitutto!
    Ho appena provato a installare la tua applicazione ma ho un paio di problemi: il browser a intervalli regolari mi dice:

    “DataTables warning: table id=events-table – Invalid JSON response”

    Inoltre solo appena apro l’applicazione mi segnala che il fuso orario è sbagliato, anche se mi sembra di averlo configurato in tutte le parti dove doveva essere configurato.

    Per completezza, ma non credo che per ora sia importante, la scheda Arduino non ha alcun circuito collegato, sto solo provando il software.

    Grazie in anticipo!

    • Max 09/08/2015 at 10:56 - Reply

      Una parte dell’errore (timezone errata) l’ho risolta seguendo questa guida:

      Però ancora ho diversi problemi. Aggiorno quando risolvo

      • luca 12/08/2015 at 13:15 - Reply

        grazie Max, mi fai da betatester… dopo mesi che lavoro sul mio Yun è difficile ricostruire tutti i passi svolti per far funzionare irrighino ;)

    • Max 09/08/2015 at 14:19 - Reply

      Dove consigli di creare la directory temporanea del log? Io l’ho impostata sulla SD : ../temp/

      • luca 12/08/2015 at 13:13 - Reply

        ciao Max, ho aggiornato il README su Github, vedi se risolvi i tuoi problemi. Ho anche indicato la cartella dove io metto i logs (/var/log che è una temp folder così non scrivi troppo sulla SD) e i jobs che svecchiano i logs più vecchi di tot giorni.

  2. Gianluca 08/08/2015 at 08:48 - Reply

    Ciao Luca e complimenti per il progetto!!!
    Avrei una domandina:
    Si è utilizzata la funzione “range” di HTML5 per la funzione slider?? come si riesce a colorare???


    • luca 08/08/2015 at 14:58 - Reply

      Ciao Gianluca, no ho utilizzato questa libreria per gli slider…

  3. salman 11/08/2015 at 04:49 - Reply
    • luca 12/08/2015 at 13:11 - Reply

      Yes, it outputs a digital level (ground when it rains)

  4. Bouni 11/08/2015 at 05:39 - Reply

    Can you provide a Bill of materials or at least the manufacturer and part numbers of the valves and rain sensors?

    • luca 12/08/2015 at 13:10 - Reply

      Hi! I sourced those parts in a local gardening shop… for the valves, every solenoid valve should work, just pay attention that some require 12V and some 24V. My valves are made by Rain (an italian company) and the rain sensor is made by Orbit.

  5. Richard 11/08/2015 at 23:13 - Reply


    Very interesting project, many excellent features there.

    I’m working on something that uses the same principles, but I’m lacking useful information on a suitable watering system.

    Would you be able to share more detail on that side of it – the type of water valve used. A google search of the image you used in the diagram did not appear to resemble the actual watering spout used in the video – but maybe I am missing something in the watering system setup.)

    I’d appreciate any pointers you might have in that regard.

    Again, great work, and all the best,


    • luca 12/08/2015 at 20:06 - Reply

      Hi Richard, I provided the link to the water valves and the rain sensor I used in another comment. Thanks!

  6. gonalo 07/09/2015 at 18:17 - Reply


    I installed my yun your project and gives me a lot of mistakes, I think we all are connecting to the database.

    to start the web give me errors on lines 103, 104, 105 include.php file.

    Every so often you get an error: “DataTables warning: table id = events-table – Invalid JSON Response.”

    What can be the problem ??

    Thank you.

    • luca 08/09/2015 at 07:21 - Reply

      Hi! Are you sure you installed all the required php modules as explained in the readme? does the log folder you defined in the include.php exist?

  7. vincenzo 03/10/2015 at 02:18 - Reply

    Scusatemi sono davvero alle prime armi.
    Potrei eseguire il tutto senza interruttori a levetta e senza led, avendo quindi solo il controllo da interfaccia web?
    potrei quindi cancellare parte dello sketc?


    • luca 06/10/2015 at 08:02 - Reply

      Ciao Vincenzo

      assolutamente sì, puoi configurare lo sketch in modo che legga sempre gli interruttori come “automatic” e quindi neppure collegarli… lo stesso per i led.

  8. Marco 03/11/2015 at 13:14 - Reply

    Salve Luca, complimenti davvero per l’ottimo sito. Sto replicando questo progetto, ma non capisco come collegare i relè a 24 volt. Ho necessità di utilizzare tutti e 4 i relè in quanto vorrei gestire 4 zone di irrigazione. Puoi farmi uno schema? Grazie

    • luca 03/11/2015 at 14:35 - Reply

      Ciao Marco, se stai usando delle schede relay “già pronte” (come quella che ho usato io) basta collegare l’alimentazione (5V e massa) e ad ogni PIN di Arduino definito nello sketch un “input” della scheda. Se invece vuoi collegare i relay singolarmente, devi seguire lo schema su Playground.

  9. Sandro 03/11/2015 at 16:41 - Reply

    Ciao Luca, non capisco i vari collegamenti. Si potrebbe avere uno schema fatto con fritzing? Forse chiedo troppo. Ma non so proprio come fare. Grazie!

    • luca 03/11/2015 at 20:31 - Reply

      Ciao Sandro, i collegamenti dipendono molto dal setup che vuoi (con i pulsanti, quanti relay…) per questo il progetto è lasciato volutamente generico

  10. Rob 24/11/2015 at 04:27 - Reply

    Amazing project! I have been dreaming of doing something like this for some time.

    • luca 24/11/2015 at 21:00 - Reply

      Thanks Rob!

  11. Vincenzo 25/11/2015 at 13:30 - Reply

    Ciao Luca, ho un prob. Per poter aprire l interfaccia web ho dovuto mettere la cartella irrighino prima in una chiamata “www” e poi il tutto dentro una “arduino” e solo cosi riesco ad accedere digitando http://'yun-ip'/sd/irrighino.
    Poi una volta aperta, ho questo messaggio con una periodicità di circa 10 sec: “DataTables warning: table id=events-table_Invalid JSON response. For more information about this error, please see” Dove ho sbagliato? Ho eseguito tutto il resto alla lettera. Ti ringrazio anticipatamente.

    • luca 26/11/2015 at 08:45 - Reply

      Ciao Vincenzo, hai installato tutti i requisiti come da README? Di solito quell’errore indica la mancanza di qualche modulo php…

  12. lukasz 14/03/2016 at 11:49 - Reply

    I have a problem. Left position is available. Where to look? sketch or Web page?

    • luca 15/03/2016 at 08:29 - Reply

      Hi! What do you mean?

  13. Amedeo 07/04/2016 at 08:59 - Reply

    Bellissimo progetto complimenti. Vorrei chiedere, il programma funzionerebbe anche se lo si monta su un Arduino Uno con ethernet shield, la classica… oppure funziona solo con Arduino Yun. scusatemi ma sono un po alle prime armi.. Grazie mille.

    • luca 07/04/2016 at 09:02 - Reply

      Ciao Amedeo. Irrighino funziona solo su Yun al momento… si potrebbe fare un “port” per Raspberry ma non per Uno o simili perché richiede una scheda in grado di eseguire Linux.

  14. Amedeo 07/04/2016 at 09:15 - Reply

    Grazie mille. Chiedo un’altra cosa vista la mia inesperienza. Il codice php per creare la pagina web, bisogna avere un pc con un sistema tipo linux per usarlo? oppure posso usarlo anche su un pc con windows? Grazie mille

    • luca 07/04/2016 at 10:45 - Reply

      puoi tranquillamente usare Windows, tieni conto che tutto il codice PHP gira direttamente su Yun, a te per accedere a irrighino basta un PC qualsiasi / tablet / cellulare con un browser internet.

  15. Pedro 26/04/2016 at 19:32 - Reply

    Hi Luca,

    I’m thinking in a similar project, but I would like to connect two usb devices, an external antenna and a usb webcam, using an usb hub, something like that

    Do you if it is possible ?

    Thanks !!

    • luca 27/04/2016 at 15:01 - Reply

      Hi Pedro, I was told that an external USB hub works with Arduino Yun but I never tried.

      • Pedro 29/04/2016 at 17:26 - Reply

        Hi again …

        After reading your post I was convinced to buy an Arduino Yun, but I’ve seen that nowadays it is discontinued.

        According to the information I’ve find in the web “Seeeduino cloud” appears to be compatible and similar to Yun, but I’m not sure.

        Could you give some advice ?

        Thanks again

        • luca 02/05/2016 at 07:43 - Reply

          Hi! I’ve no experience with that product but it seems that it’s fully compatible. Unfortunately the Yun seems a discontinued product, I’m planning to port the irrighino project to Raspberry Pi…

          • Pedro 02/05/2016 at 08:36 -

            Thanks for your answer Luca !!

Leave A Response »

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.