Introduction: Alexa Controlled Garden Watering System
I had a few ESP8266 devices available (Wemos D1 Mini’s) and I also had a timer based watering system for my garden. The timer was very simple and kept failing and every year I had to buy a new one.
As I had Alexa and Domiticz for my home automation it seemed natural that I create an Alexa powered watering system!
Step 1: You Will Need...
Wemos D1 Mini https://wiki.wemos.cc/products:d1:d1_mini
Wemos D1 Mini Relay Shield https://wiki.wemos.cc/products:d1_mini_shields:relay_shield
Voltage regulator LM2596 on eBay
12v Solenoid Valve 12v Solenoid Valve on eBay
12v power supply
Enough wire to wire it together
Irrigation supply hose
4mm irrigation hose for the sprinklers
Hose joiners and adapters
Something like this: Irrigation system
Step 2: Assemble the Electronics
Plug the relay shield into the Wemos D1 mini. That’s the easy part!
Next we need to wire up the power supply regulator to the Wemos D1 mini. First things first though the regulator that I used was adjustable so that I attach it to my 12v supply but I only want 5v coming out so that I don’t blow the Wemos device. We need 12v for the solenoid valve - hence the need for the relay.
I soldered the ground from the regulator to the GND pin on the Wemos of the +V to 5v on the Wemos after confirming that it was adjusted correctly.
Next I wired the Solenoid valve to the Relay. I took the 12v line from the power supply to the middle pin of the relay. Then I took a wire from the NO (normally open) pin on the relay to one of the pins on the solenoid. The other pin on the solenoid went to GND on the power supply.
At that stage it was all ready to be put ina box - but before we do that - we need to program the device
Step 3: Programming the Wemos
I found a great project on GitHub that makes the ESP8266 device act like a Belkin Wemo switch. This is great because Alexa has direct support for the Belkin. The original source can be found here: https://github.com/kakopappa/arduino-esp8266-alexa-multiple-wemo-switch
I made some minor changes to this code and published on my github here: https://github.com/davewins/alexa_wemo_SprinklerSwitch
Mainly the changes were to deal with WiFi connectivity issues. If WiFi got disconnected it took a really long time to connect it didn’t always start the UDP connection and the web server. In my code I automatically reconnect.
I just used the Arduino IDE to compile the code and flash the Wemos device.
You will need to adjust the code to connect to your WiFi network with the correct password. Look around line 14/15 and replace the YOURSSID with your WiFi name and the following line has the password.
Now we can assemble into a box!
Step 4: Put the Electronics in a Box!
Put it all together neatly in a box! I used a waterproof box so that I could put it outside and made sure I had enough power cable to run from the house to the box and from the box to the solenoid.
Don’t have it too far from the house otherwise you won’t get a wifi signal. In those case maybe use a different ESP8266 device with an aerial.
Step 5: Assemble the Irrigation System!
Hook your supply hose up to the mains supply however is best for your situation. Connect the other end to the solenoid.
Connect the output of the solenoid to the irrigation supply hose.
Lay the supply hose round your garden.
Add the sprinklers etc and put them in your plant pots/borders etc.
Step 6: Integrate With Alexa
Once you’ve turned it all on and it has connected to your WiFi you can get Alexa to discover your device.
The blue led on the Wemos device is used to show the connection status. Flashing every half second (quite dimly) shows that it is trying to connect. If it is a solid blue light - it has connected to your WiFi.
Either use the Alexa app to start searching for devices, or ask Alexa to discover devices. After a while if all works well it will discover a new devices called Switch_random-letters. The random letters are unique to the device.
You can change the name to be what’re you like. I changed mine to “Back Garden Sprinkers”.
Press the button to turn the system on and hopefully it all works! Pressing it again or asking Alexa to turn off the back Garden sprinklers should also work.
Step 7: Integration With Domiticz
I used Domiticz to create scene so that the sprinklers would turn on at Sunrise and Sunset automatically. Unfortunately Domiticz does not have native integration with Belkin Wemo devices but they do have scripts that will work acceptably.
They also work best if you use your internet router to always give the sprinkler device the same IP address all the time. You can also adjust the code to provide a static IP address if you like. I’ve left the code to do that in the source - just commented out so adjust as required for your network.
Use the scripts provided here: Domoticz wiki to integrate with Domiticz.
Essentially you set up a dummy device which calls the script with an on/off command.
In my scene I added a number of devices 3 zones in the front garden and 1 in the back garden and set these to come on in a sequence when the scene is triggered.
I set the timer to trigger once at Sunrise and once at sunset.
Step 8: Sit Back and Enjoy!
This is an entry in the