Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Creating a Custom Sprinkler Controller

A family member of mine bought a “smart” sprinkler system last year. As someone who loves automation, my first inclination is, “How can I automate that?” Later, when I asked about how they liked their sprinkler system they said, “It’s supposed to know when it rains and turn off the sprinklers, but I’ve had twice where the city next door gets rain and so my sprinklers turn off. But then once it rains here my sprinklers are the first to turn on.”

We’ve all heard the stories of the product that is going to change our life only to realize it doesn’t work perfectly. I thought it would be fun to build my own sprinkler controller. - And as a disclaimer, I did not put the expectation to integrate it with the weather, or other sensors (yet…).

So here it is! My first steps into a sprinkler controller. I wanted the first iteration of my sprinkler controller to have the following:

  • Have the ability to connect to Home Assistant (or any other system for that matter)
  • Because of it’s location in the garage, I wanted it to be able to open/close the garage door
  • Be simple!

I used a doorbell transformer to provide power, with a buck converter transforming AC to DC5V for the relay board and ESP32. Custom Sprinkler Controller

Parts List*

I chose a 16ch relay board because I knew that I had 8 zones, and I would rather have 1 relay board compared to multiple boards. The ESP32 was an obvious choice because it could handle the I/O for the relay board while also working seamlessly with ESPHome (more on that later). Overall, this initial prototype/version 1 has worked really well!

Configuration

The ESPHome configuration is pretty straightforward, it is a bunch of switches like this:

switch:
    - platform: gpio
        id: sprinkler_1
        pin:
        number: 4
        mode: OUTPUT_OPEN_DRAIN
        name: "Sprinkler 1"
        inverted: true
        restore_mode: ALWAYS_OFF

The garage door uses a switch with a built in script. The garage door is just a relay in parallel with my garage door button. I have such an old garage door. ‘ol reliable, and easy to automate. The trick is getting it to show up as a garage door in Home Assistant. I chose specifically not to use the Cover component because it did not have the features that I was looking for. There’s enough on how I configured the Garage Door to make it show up exactly how I wanted to that I’ll explain that in another article.

switch:
    - platform: gpio
        name: "Garage Door Switch"
        id: garage_door_switch
        pin:
        number: 5
        mode: OUTPUT_OPEN_DRAIN
        inverted: true
        restore_mode: ALWAYS_OFF
        on_turn_on:
        - delay: 0.1s
        - switch.turn_off: garage_door_switch

A common question is ESPHome or Tasmota? In this specific case, I chose ESPHome because it supported the OUTPUT_OPEN_DRAIN. Both Tasmota and ESPHome are near identically seamlessly integrated into Home Assistant, but Tasmota did not have support for the gpio mode needed.

Automating

Everyone will tell you their two cents on how to setup your sprinklers, I’ll leave that to you. And so far I don’t have great recommendations for automating your sprinklers because It’s still a work in progress for me. I have some sprinkler system problems to remedy before I really start making some automation decisions.

Lessons Learned

No DIY project is complete without a few bumps in the road. The first issue I ran into was the relay board. The ESP32 is a 3.3v platform, whereas the relay board operates at 5v. When I was testing with the relay board, I realized that to activate the relay you pull the control pin to ground. This was great news because I was able to connect the ESP directly to the relay board and use the OUTPUT_OPEN_DRAIN mode for the control pins.

I have also ran into some reliability issues, and one of my rules of automation is that the automation must be reliable! I had instances where it just seemed like the ESP32 running ESPHome would become unresponsive or frequently disconnect from Home Assistant. To resolve it, I would have to manually erase the flash and re-install the program. I have mostly solved my intermittent problem by using the restart switch component and having Home Assistant restart my ESP32 each night at 4am. So far that has fixed my problem! - but I continue to monitor it.

*Amazon Affiliate Links