Autonomous Irrigation

To build this circuit you need the following items:

– 1x Arduino Uno Rev3
– 1x LCD4884 shield (with a 5 degree of freedom joystick)
– 1x Data logging shield
– 3x IRF3205 N-Channel Power MOSFETs
– 3x 1N4001 flyback diode
– 3x Plastic water solenoid valve (12V)
– 1x Power supply (12V DC)
– Breadboard and wires

To simplify the schematics I will not represent the LCD4884 shield and the data logging shield. They are stacked in the following order:
Bottom: Arduino Uno Rev3
Middle: Data logging shield
Top: LCD4884 shield


Some important remarks that should not be forgotten:

Before compiling the code you need to download, uncompress and install the following libraries: RTClib and LCD4884. To install simply copy them into the “libraries” folder. Alternatively you can read the official tutorial: Installing Additional Arduino Libraries

The pinout for the IRF3205 N-Channel Power MOSFETs is the following:

Gate | Drain | Source

If you’re using other transistors to operate the electrovalves and you are not sure about its pinout, you should read the datasheet.

The 12V power supply is used to power the Arduino Uno (Vin pin) and the electrovalves. Keep in mind that red wires operate at 5V and orange wires operate at 12V.
Even though there is no 5V electronics represented in the circuit (besides the LCD4884 and data logging shields) I decided to represent the 5V line (red wires) for future reference.

Don’t forget to add the 1N4001 flyback diodes (one for each electrovalve). They are very important because the switching of an inductive load will originate transients (voltage spikes) which might damage sensitive electronic components.

Make sure that on your data logging shield SDA is connected to A4 and SCL is connected to A5. If these pins are not connected the RTC (DS1307) will not be able to communicate with the Arduino Uno.

On the Arduino Uno, digital pin 13 is the same as ICSP SCK, pin 12 is ICSP MISO and pin 11 is ICSP MOSI. However, this is true only for the Arduino Uno.
Other Arduinos have different connections and pinouts. This might also be true for Arduinos clones. These pins are used for the SD card communication, which I am not using for this project.
So, if you plan to add an SD card in this project you must be aware of which Arduino and data logging shield you are using and perform the connections accordingly.

The communication between the LCD4884 shield and the Arduino Uno uses pins D2, D3, D4, D5 and D6. There is also a 5 degree of freedom joystick (or 6 states joystick) which uses pin A0. The LCD backlight is controlled by pin D7 (not used in this project).

The 5 degree of freedom joystick (or 6 states joystick: up, down, left, right, pressed and unpressed) relies on a set of 5 resistors with each one having a different value. This method is very useful because it is only needed one analog input to operate the joystick.
However, if the resistors on your LCD4884 have different values you must adapt this code to make it work. Another option is to buy the exact same LCD4884 shield as I am using for this project (see note at the bottom).
If you want to use another LCD4884 shield make sure you get the following readings from each position:
Unpressed: 1003~1023
Pressed: 135~155
Up: 735~755
Down: 320~340
Left: 0~20
Right: 495~515

Make sure that you use a good power supply with enough power to operate the electrovalves.

Note: If you do not have the skills to debug and adapt your hardware to my code, I recommend you to use the following boards:

Arduino Uno Rev3. Buy it here

LCD4884 shield (with a 5 degree of freedom joystick). Buy it here

Data logging shield. Buy it here

Plastic Water Solenoid Valve (12V). Buy it here

    If you need to ask me a question, suggest an enhancement or report a bug, please use the contact form below:

    Your name

    Your e-mail (double check your e-mail or I won't be able to contact you)


    Your message