DIY WiFi Sprinkler Controller using ESP8266

Tags: #<Tag:0x00007f780fe801f0>

I just finished up my WiFi sprinkler controller using an ESP8266 and programmed using esphome. I’m controlling 8 zones but should be easily expandable to more zones using another shift register. I’ve got a pretty basic automation running now but would like to beef it up in the future with some moisture sensors.

Part 1 - Hardware
Part 2 - Software


Looks great!
Thanks for the write-up.

Have a look here if you want some ideas on how to automate things home-assistant-side including weather prediction etc.

Woah this looks awesome! Definitely going to grab some good stuff from that, thanks for sharing!

Well, kudos to @klogg for putting it together.
Keep in mind it’s his own code that he shared, so it will need some work to adjust it to your platform.
Let me know if you need help as I stole it too recently :slight_smile:

Thanks for the article! I’m going to use it for my own system. I’ve got max 4 zones, so probably I can leave the shift register out.

Wow that looks amazing! I have a small advise, if you want to replace your Nodemcu easily, in for example a case of failure, I would advise to use female header pin connectors. Nice project!

@DutchDeffy if you look closely you may be able to see that’s exactly what I did. Learned that trick awhile ago!

@selfhostedhome (Zach), thanks for posting this!

Very awesome that you used ESPHome in your implementation, a definite plus in my book. I’m very interested in building something similar but I really like the idea of having some autonomy built into the unit and some control and display on the unit itself. All of that just to ensure that if my HA unit goes down my lawn watering doesn’t halt too – but I also love the idea of having HA manage it so I keep bouncing back and forth.

All of that stuff aside, I’ve reviewed your implementation and I’m wondering when you have 8 zones does HA know that if you cannot have two zones on at once? I mean, what happens when a zone A is switched to ‘ON’ and you switch another zone B to ‘ON’ without touching zone A? Is HA smart enough to turn off zone A and then turn on zone B? I can’t tell browsing through the code…

Thanks again!

@SpikeyGG, right now HA does not know two zones cannot be on at once. Maybe you could write an automation or something to add this restriction. Or actually you could enforce it on the ESPHome side somehow using custom C++ code. In my case, I very rarely use the switches in Home Assistant. Typically this runs of an automation so I just turn one zone on at a time in my automation.

Great suggestion. I haven’t built any hardware yet but I’m thinking this might do the trick, see inline comments:

class ShiftRegisterSwitch : public Component, public switch_::Switch {
  int index;
  const uint8_t resetSR[8] = { 0, 0, 0, 0, 0, 0, 0, 0}; // Define an array to reset all pins
  ShiftRegisterSwitch(int output) {
    index = output;
  void setup() override {
    sr.set(index, HIGH);
  void write_state(bool state) override {
    if(state) {
      sr.setAll(resetSR); // Added to reset everything first when one pin gets set.
      sr.set(index, HIGH);
    } else {
      sr.set(index, LOW);
    // Acknowledge new state by publishing it

I think this should reset all pins to zero before setting a pin to one… I’ve ordered my hardware so when it gets in I’ll have to proto something up and try it out.

1 Like

Thank you, this is really useful information.
I have 6 zones Orbit 57946 and wish to expand it to more zones. I think this will help me. :slightly_smiling_face: