Irrigation sytem for trees using ESP32

Want to share with the comunity a project I have done to irrigate my trees which are in pots.

The ideia is simple, keep my trees wateres using solenoids and humidity sensors.

Given the costs where I live, I decided to just use a ESP32 Devkit, a board of 4 relays, 4 solenoids of 110v 3/4 and 3 humidity sensors.

The sensors I brought from aliexpress, the solenoids in my country for a price good enough to not import, the rest I had from other projects.

For the water, just used a garden hose I had here, because, the project was already way too much costy, and at the end I managed to connect everything using quick connectors for easy remotion for manutention.

The wiring was well isolated using 3 layers of isolation, one using common isolation tape, another using autofusing isolation tape and finally a layer of silicon.

For the humidity sensor, used the lan cables, for they are easy to connect into the prototype cables, they are cheap, resist well in the weather, and I had it here. Same thing, soldering, isolation, silicon for good measure. And take it to the box where everything is.

For energy, used a box with two plugs, one for the ESP32, another one for the solenoids

A couple of images of the project.

Here is the config file for ESP32:

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable Home Assistant API
api:

ota:

wifi:

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:

# captive_portal:

sensor:
  - platform: adc
    pin: 34
    name: "Humidade do Solo da Amoreira" #1
    update_interval: 5s
    unit_of_measurement: "%"
    attenuation: auto
    filters:
    - median:
        window_size: 7
        send_every: 4
        send_first_at: 1
    - calibrate_linear:
        - 1.1 -> 100
        - 2.5 -> 0
    - lambda: if (x < 1) return 0; else return (x);
    # accuracy_decimals: 0

  - platform: adc
    pin: 35
    name: "Humidade do Solo da Lichia" #2
    update_interval: 5s
    unit_of_measurement: "%"
    attenuation: auto
    filters:
    - median:
        window_size: 7
        send_every: 4
        send_first_at: 1
    - calibrate_linear:
        - 1.1 -> 100
        - 2.5 -> 0
    - lambda: if (x < 1) return 0; else return (x);
    # accuracy_decimals: 0

  - platform: adc
    pin: 32
    name: "Humidade do Solo do Limoeiro" #3
    update_interval: 5s
    unit_of_measurement: "%"
    attenuation: auto
    filters:
    - median:
        window_size: 7
        send_every: 4
        send_first_at: 1
    - calibrate_linear:
        - 1.1 -> 100
        - 2.5 -> 0
    - lambda: if (x < 1) return 0; else return (x);
    # accuracy_decimals: 0
# g33 g25 g26 g27

switch:
  - platform: gpio
    pin: 33
    name: Solenoide da Bomba
    id: solenoide_bomba
    # internal: True
    inverted: True
    restore_mode: ALWAYS_OFF

  - platform: gpio
    pin: 25
    name: Solenoide do Limoeiro
    id: solenoide_limoeiro
    # internal: True
    inverted: True
    restore_mode: ALWAYS_OFF

  - platform: gpio
    pin: 26
    name: Solenoide da Lichia
    id: solenoide_lichia
    # internal: True
    inverted: True
    restore_mode: ALWAYS_OFF

  - platform: gpio
    pin: 27
    name: Solenoide da Amoreira
    id: solenoide_amoreira
    # internal: True
    inverted: True
    restore_mode: ALWAYS_OFF

What do you ppl thinks? Feedback is well received :slight_smile:

3 Likes

Good job. If i may suggest a couple of things. Either a physical rain sensor or a HA binary sensor from a weather api that wont allow watering if it is raining. Is this automated or do you manually open/close each valve? I dont see any automations. A flow rate sensor is helpful. Not only will you know your water usage for each valve but you can use it to prevent over watering or most importantly, if you ever have a leak, the flow meter can catch that and you can be alerted before you flood your lawn.

The one thing i dont particularly like is its quite the mess. Making things neat and organized can really take your project to the next level, plus someones going to trip on those hoses and break their neck.

I did something similar a couple years ago. This controls 4 valves for drip irrigation in my flower beds plus one extra hose hookup where i can get water from if i need it.

Just a couple other friendly suggestions to make your projects more organized and prevent loose connections or accidental short circuits.

Breadboard wires are for a breadboard and mocking up temporary circuits. You’re just asking for bad connections or shorts with those wires and having your esp board hanging loose like that.

These are breakout boards and they come in several options for esp8266 NodeMCU and esp32 NodeMCU. This allows you to mount your board and have solid connections to the gpio’s.

I only started using these recently because, you can get a petty good conmection just by sticking bare wire in those screw terminals. The problem is over time the wires start to frey and little bits of copper wire break off and can cause short circuits. Wire ferrules make things so convenient and very easy to move wires around if you need to, plus you can color code your wires to prevent mixing them up.

I used to do the hot glue thing too… it does the job but, its a nightmare if you have to add wires or change wires.
Cable glands have a rubber gasket inside of them. You put your wires through it snd then tighten the nut to seal out water and it keeps your wires from accidentally getting pulled out when you trip over tbem and break your neck lol.

Hopefully you didnt take this the wrong way and think im being rude or anything. These things really help you out long term and i had to figure this out the hard way by making many mistakes and learning lessons. If you have to get back in that box 7-8 months later, you dont always remember all the details and what goes where, especiallyif you use only red wires for for everything. Organizing everything helps tremendously. You can quickly find problems or maybe add things inside the box later on. Its just easier because you can quickly look at it and see what everything is and where each wire goes.

If it helps you. This is something i finished last year. Its 100% worth the little extra moneyal and time i promise and i highly recommend you try some lf these things.

I