Simple, Reliable Sprinkler Controller with ESPHome

Hi,

I used a 24VAC/1250ma adapter. Hope this helps.

Thanks I picked up a 2 amp one. Planning on going about it the same way you did.

Got it running, just printing out a case.


I’m glad to see everyone is enjoying this project!

For those of you asking if you can use a 24VAC power supply to power the valve, the answer is YES of course you can. Obviously, you can skip the part where you wire the 24VDC to the relay outputs. Simply use the relays normally: connect 24VAC to COM and valve to NO. Just don’t try to power the board with 24VAC.

If you choose the 4 channel board (amazon, aliexpress) then you can simply power the board with 120V or 230V AC mains, no DC power supply is needed.

1 Like

Hi,
Got it working, but was wondering could i switch on manually or automatically 2 or more zones at once? My pump can easily manage 2 zones or more.

When selecting a zone when one is running it switches now.

Thanks,
Jan

Just wanted to say thank you for this write up I was able to get mine setup today - glad to get rid of the cloud dependencies

2 Likes

I think the original esp sprinkler code has the switches interlocked so you cannot enable two at the same time without rewriting everything by your self.

What you could do, is connect both valve cables on the same output, so you could control them with 1 switch (1 zone)

1 Like

Im not enjoying it at all and certainly dont find it useful!! What a bunch of false advertising this was! I want my money back!!

Oh… Im JK!

That was very cool and a very well done write up and well articulated. Well not quite as good as mine is but, whos keeping score ; )

Thank you for sharing your project amd putting in all the work and many hours of it to just give it away to the community! That makes you OK in my book!

Yes, only “OK” so dont push it! ; )

I would like to have the Sprinkler Controller to somehow open my Main Valve and wait for e.g. 3 seconds and the open a zone value wait for e.g. 3 seconds and then enable my Pump.

In the Sprinkler Controller, I would like to specify both a main valve and a pump. Currently can specify one pump_switch_id, which controls a pump or a main valve. I would like to specify both a pump and a main valve.

My irrigation system is feed from main watersource, so it has a main valve and a pump (because of low pressure from the watersource). Downstream are zone valves. The main valve, a zone valve and the pump must be turned on to get my system to work well. Main valve and pump are controlled through different GPIO (because of delay requirement). Using the Sprinkler Controller, I see no direct way to turn on both the main valve, and the pump, when turning on the zones.

This requires the following steps:
Starting:
1: open main valve
2: open zone valve (with a delay)
3: enable pump (with a delay)

Stopping:
1: Disable pump
2: close zone valve (with a delay)
3: close main valve (with a delay)

I’ve though about using a template switch for the pump_switch_id (not sure if it will work), but would prefer it natively in the Sprinkler Controller.

Any tip is appreciated to get this working properly.

Snippets from my currect config:

#############################
#  Establish Substitutions  #
#############################
substitutions:
  devicename: irrigation_controller
  system_name: irrigation-controller
  friendly_name: "Irrigation Controller"
  device_description: "The T-Relay is a handy relay module with Wi-Fi and Bluetooth. This module contains 4 relays and an ESP32 Wrover"
  zone1: "Zone1"
  zone2: "Zone2"
  zone3: "Zone3"
  zone4: "Zone4"
  zone1_id: valve_0
  zone2_id: valve_1
  zone3_id: valve_2
  zone4_id: valve_3
  sensor_update_frequency: 1s
  
switch:
  - platform: gpio
    pin:
      number: GPIO33
      inverted: false
    internal: true
    name: "${friendly_name} Pump"
    id: ${devicename}_pump
	
sprinkler:
  - id: $devicename
    main_switch: "Start/Stop"
    auto_advance_switch: "Auto Advance"
    reverse_switch: "Reverse"
    next_prev_ignore_disabled: true

    multiplier_number:
      id: run_time_multiplier
      name: "Run Time Multiplier"
      min_value: 0.1
      max_value: 5
      step: 0.1
      icon: mdi:multiplication
      mode: BOX
      restore_value: true
      initial_value: 0.1

    # Causes pump start/stop delay for the duration specified.
    # Causes the current valve and the next valve to run simultaneously for the duration specified.
    # Prevents water hammer effect.
    pump_start_pump_delay: 3s
    pump_stop_valve_delay: 3s
    valve_overlap: 3s

    valves:
################
#  Zone One    #
################
    - valve_switch:
        id: $zone1_id
        name: $zone1
        on_turn_on:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: $zone1 Active
        on_turn_off:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: Idle
      enable_switch: Enable ${zone1}
      run_duration_number:
        id: zone_1_duration
        name: ${zone1} Duration
        min_value: 1
        max_value: 60
        step: 1
        unit_of_measurement: min
        icon: mdi:timer-outline
        mode: BOX
        restore_value: true
        initial_value: 1
      pump_switch_id: ${devicename}_pump
      valve_switch_id: relay1

################
#  Zone Two    #
################
    - valve_switch:
        id: $zone2_id
        name: $zone2
        on_turn_on:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: $zone2 Active
        on_turn_off:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: Idle
      enable_switch: Enable ${zone2}
      run_duration_number:
        id: zone_2_duration
        name: ${zone2} Duration
        min_value: 1
        max_value: 60
        step: 1
        unit_of_measurement: min
        icon: mdi:timer-outline
        mode: BOX
        restore_value: true
        initial_value: 1
      pump_switch_id: ${devicename}_pump
      valve_switch_id: relay2

################
#  Zone Three  #
################
    - valve_switch:
        id: $zone3_id
        name: $zone3
        on_turn_on:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: $zone3 Active
        on_turn_off:
        - then:
          - text_sensor.template.publish:
              id: irrigation_controller_status
              state: Idle
      enable_switch: Enable ${zone3}
      run_duration_number:
        id: zone_3_duration
        name: ${zone3} Duration
        min_value: 1
        max_value: 60
        step: 1
        unit_of_measurement: min
        icon: mdi:timer-outline
        mode: BOX
        restore_value: true
        initial_value: 1
      pump_switch_id: ${devicename}_pump
      valve_switch_id: relay3

Hi, I uploaded this to my sonoff 4ch pro R3 unit and it works fine. But I don’t understand the scheduling part and tried out several thing. How does this work? For now I use it only with the zone auto, zone duration and then I switch the sprinkler cycle active to start a run. This works fine. But how do I use the scheduling part?

edit: I digged myself a bit more, it seems that the time funtion which should run every minute does not work. How can I figure out why this does not work?

edit2: changed the time function to use sntp instead of HA. Also added some logging, now I saw that the time zone wasn’t correct but adjusted it, tested with new time and now it works.

I changed this for the time function to make it work and some more logging:

- platform: sntp
  id: ha_time
  on_time:
    - seconds: 0
      minutes: /1
      then:
        - lambda: |-
            auto now = id(ha_time).now();
            ESP_LOGI("time", "Current time: %02d:%02d on weekday %d", now.hour, now.minute, now.day_of_week);
        - script.execute: ${id_prefix}_script1

You should try to check the age of historical posts online because, they dont always age well or just dont at all.

Since this post was made 3 years ago, there have been many improvements to Esphome such as the Datetime component.

This will give you a UI box to pick either a Date, Time, or both Date and Time and right in the UI so that you can change it or whatever, right on the spot and doesnt require changing any Esphome configurations or flashing esp boards every time you want to change the scheduling for something.

I highly recommend that you and everyone just spend some time on a regular basis and go through the documentation to see what’s there, see what’s interesting to you, see if something inspires you, etc. Its a good way to keep up-to-date on things available to you just like this.

Here is an example of my keypad and i can for example allow a guest temporary access and use the Datetime integration to configure a Start/Stop for 24hs as an example, 5am - 5pm on todays date.

Might want to add FTDI to the list of required hardware. I just bought everything that I needed and started with the steps, only to come to the conclusion that I have to order an FTDI and wait an other week for it to arrive. :joy:

I received my FTDI, but I can’t seem to get it to work…
I don’t understand what I’m doing wrong.

Here is a picture of my flashing setup

  • ESP-12F connected to 24V
  • ESP-12F bridge between IO0 and GND
  • FTDI bridge set to 3.3V
  • FTDI RX connected to ESP-12F TX
  • FTDI TX connected to ESP-12F RX

I followed all the steps, but every time I try installing it keeps spinning on “Connecting”

Any advice? Bad FTDI?

the connections don’t look right.

from left to right in your picture of the ftdi board you need to connect the ftdi as:

gnd
no connection
vcc
rx on the other board
tx on the other board
no connection

from that picture it looks like you don’t have anything connected on the ftdi vcc pin

Sorry. I missed your reply. Thank you for your help.
To where do I have to connect the vcc according to you?

This is the picture OP used. No vcc connected either?

I tried what you said and connected the vcc of the FTDI to the 5V point on the board. Even though the vcc is only supplying 3V.
Still can’t get it to work.

try removing the separate power to the ESP board.

Then set the ftdi jumper to 5v. you will be powering the ESP chip from only the ftdi board at that point.

I’m assuming the ESP chip is OK with being powered with 5v since the pin is literally labeled as such.

if you want to not be as daring then try it first by keeping the ftdi board to 3.3v. if it works then :partying_face:

if it doesn’t work then try switching the jumper to 5v and try it again.

Thank you @finity for helping @Rubeast. I’m glad to see people give this a go!

Programming the ESP8266 was a finnicky procedure for sure, but I have done it many times on boards just like this one and other similar ones.

In general, programming an ESP8266 with an FTDI requires an external power source because the FTDI often cannot supply sufficient current for the programming operation. It’s hit or miss. You can read many frustrated accounts of people trying and failing, because it isn’t obvious and it often works fine with other microcontrollers.

It requires a careful order of operations to get it programmed the first time. In my experience, this worked:
Power supply OFF.
FTDI usb UNPLUGGED.
Hold RST button. Keep holding it.
Power supply ON.
Plug in USB, click install via wired connection.
Release the RST button.
It should begin the upload within 1-2 seconds.

You can also try using the FTDI without external power supply. It may work partially but fail shortly after beginning the flashing process. Or it may not work at all. Or it might work. It’s hard to say.

Have fun!

I follow all steps. But as soon as i release the RST button, it starts doing it’s default programming (looping through all relays turning them all off and back on)

I’m going insane with this damn board :joy:

Bought myself a new/different FTDI programmer. This one:

But the same shit is still happening!
I do the exact same steps, but AS SOON as I let go of the RST button, it starts flipping through all the relays (the default programming I guess?).
The interface keeps spinning 'Connecting" until I disconnect the USB.

  • I tried on an other PC. But I never had trouble with flashing ESP modules that came with an onboard USB connection.
  • I replaced the dupont cables.
  • I checked with a multimeter for continuity between the points.
  • On the other FTDI programmer I even soldered the wires to the board.

This is my setup now:



Really not sure what else I can try besides also buying a new board…
Someone willing to flash a board and ship it to me? (Location: Belgium)

I had similar issues, trying to load anything onto it. I couldn’t even get it to run the default sequence. The best I got was a 2 LEDs. 1 for power, the other at the first relay.

I gave up on the board and bought a separate 4 relay board to pair with an ESP32. I modified this project’s code and had that setup and sprinkling within 24 hours. Albeit with 2 power supplies.