DIY WiFi Sprinkler Controller using ESP8266

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

8 Likes

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.

EDIT: Got a “hot link” badge with the above link but it seems to be down, creator has now two new repositories:


and

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!
-Greg

@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 {
 private:
  int index;
  const uint8_t resetSR[8] = { 0, 0, 0, 0, 0, 0, 0, 0}; // Define an array to reset all pins
 
 public:
  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
    publish_state(state);
  }
};

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:

I had been looking around a non-cloud based zwave or IP based solution and came up with nothing so with your help, I was able to build it :slight_smile:

Thanks for taking the time to post your project and document it. This is my first ESP8266 project and I have to say for the cost its crazy cool.

The amazon linked parts list and schematic was dead on and primarily what I used to recreate the setup. The photos helped make sure I was doing something reasonable.

Here are a couple photos of the finished product:

I ended up wiring it in tandem with my original orbit controller so my family could operate it manually without having to access home assistant. It also served as a convenient 24v powersupply.

@selfhostedhome Thanks for the inspiration and great docs

Ray.

What’s the small rectangular pcb board for? Seems to have several things on there.

I believe it’s the common of the relays merged together and something else. Is there a higher resolution image of the wiring?

that’s what it is yes. You can see it clearer on the pictures from his blog post (linked on the 1st post)

1 Like

Anyone knows if i can replace the esp8266 with a WT32-ETH01? I want Ethernet connection, will this hardware switch affect the coding?

If that can be flashed with ESPHOME I don’t see why not. Just make sure you use the same pins I guess

1 Like

I forgot about this thread until I saw it again just now. I finished my sprinkler controller, it’s an ESP8266-based setup using OpenSprinkler. It’s been in production use since April of 2019 and it works very well.

Here are some shots of what I put together. I housed it in a medical box and hung it on the wall of my garage! :slight_smile:

1 Like

Nice du you have the wiring diagram and part list? I see you added manual switches as well…

I tallied up the parts and it’s more than $30 by a little but if you include all the extras like prototype PCBs, wire, solder, battery, 24V supply, fuse holder, fuse, pin connectors, sockets, crimper, etc. it’s probably a bit more but most of that is icing. I could have reused the 24V supply from my existing sprinkler system but I wanted to test this one in its entirety without futzing with the working system. I also designed it so I could easily swap out components and that added a cost.

Component Price
PCF8574 IO Expander $1.50
0.96" I2C Screen $3.07
Precision RTC $2.23
AC to DC converter $12.42
NodeMCU V3 Lua $3.04
8-channel relay pack $5.61
Buttons x3 $2.73
Total $30.60

I followed the OpenSprinker circuit design found on the last page of the OpenSprinkler user manual (thanks Ray!), just replace the ATMega with the ESP8266. Generally, ESP8266 devices are like legos: just use I2C and hook up whatever you want to it. I used a little trial and error to determine which components to use (like the RTC and the PCF8574s).

The screen and buttons were completely optional since the whole thing is controllable headless via a browser over the network. I put that little screen on there because I have a bunch of them (bought like 10 of those buggers). Because I made everything easily replaceable, if I ever want to spend some money and buy a larger screen, I can do that and just swap it out! :smiley:

2 Likes

Can this device be used with hassio? Ethernet Control Module Lan Wan Network Web Server RJ45 Port 16 Channel Relay Is Ethernet Controller Board.RJ45 Interface|Relays| - AliExpress

image

It uses some kind of an ethernet board…