Homeowners often find that over-the-shelf sprinkler systems can be difficult to use and lack customization options. They may also be outdated and may not be as efficient for water or power usage as desired. The "set it and forget" mentality is not always the best approach. It may be worth considering more customizable and efficient options for your home's sprinkler system.

Project Research

Want to improve your home's sprinkler system without breaking the bank? One solution is to use a combination of inexpensive hardware and customizable open-source software. This approach allows for flexibility and the ability to add additional features as needed. The main goal is to trigger the water sprinkler solenoid to turn on or off based on specific conditions such as time, including sunrise and sunset, humidity, and temperature. By implementing this method, you can achieve better results with low effort.

(there is affiliate links on this page for hardware used in this project)

Must Haves

  • ✅ IoT device runs when the internet is down (or network is down).
  • ✅ Timer based watering (support for sunrise/sunset as well)
  • ✅ Manual toggling watering state
  • ✅ Backup / Restore settings
  • ⏳ If sunrise/sunset with a temperature restriction then start watering. To prevent freezing of plant roots.

Wants

  • ✅ Measure water time, humidity, and temperature (All off-the-shelf sprinklers do this with various features)
  • ✅ Local network control with no data submitted to third party
  • ✅ graphing and ability to analyze the data
  • ✅ Watering runaway protection
  • ⏳ If humidity is at percentage then skip watering today (Most over-the-shelf sprinklers do this)
  • ⏳ If weather forecast is rainy then skip watering. Notify me when this occurs. (Most off-the-shelf sprinklers can do this sort of)
  • ⏳ Send to notification to any platform I want (AWS, Gmail, IFTTT, Alexa, etc... )
  • ⏳ Moisture sensor

Hardware

At the lowest level, the IoT hardware should be the following:

  • Toggle power on/off
  • Report power state, humidity, and temperature
  • Not require an internet connection.
  • Customize power toggling based on special conditions.

$20 USD over-the-shelf Sonoff hardware that does those 3 out of 4 easily. The 4th point needs to have special programming. There are multiple options out there but this fulfills the need of an "over-the-shelf" device that can be used with open source software.

Sonoff device

The easiest way to wire this up is using an existing extension cord, cut into it, then follow the directions of wiring Sonoff guide. Plug one into the 24 VAC power supply of an existing water sprinkler adapter.

Alternative hardware that I ended up using:

Sprinkler PCB 3D Sprinkler PCB

Software

The device can be flashed with open source software Tasmota. I prototyped with the Arduino IDE for awhile but Tasmota seems safer with features needed. So I won't go into too much detail but Tasmota solves the following problems:

  • Local network controlled
  • Runs even when the internet is down
  • Highly customizable and battle tested for years.
  • Simple programming
  • Multiple ways of interacting (command line, MQTT, web UI)

Here is a video on how to flash and setup the device when you get it (this is really common with this device).

Wiring & Module Parameters

  • D2 GPIO4 -> I2C SDA
  • D1 GPIO5 -> I2C SCL
  • D5 GPIO14 -> Relay 1
  • D0 GPIO16 -> Counter 1

Setup Time

Using the Tasmota Web Console Command line

  • PowerOnState 0 If a power outage/reset, default the power state to off.
  • Set your time zone using standard GMT offset: Timezone -8 .
  • Test your time with time
  • Update your location (use can use https://www.latlong.net/)
    • Run Latitude 0.0000 for latitude. Replace 0.0000 with proper value.
    • Run Longitude 0.0000 for longitude. Replace 0.0000 with proper value.
  • Run STATUS 7 to see sunrise / sunset with local time. Ensure it's the actual time.

Setup Timers

Using the Tasmota Timer Web UI, 4 timers will be created. Two timers for starting/stopping the watering at sunrise. Two timers for same at sunset.

  • Timer1 {"Enable":1,"Mode":1,"Time":"00:00","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":1}
  • Timer2 {"Enable":1,"Mode":1,"Time":"00:20","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":0}
  • Timer3 {"Enable":1,"Mode":2,"Time":"00:00","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":1}
  • Timer4 {"Enable":1,"Mode":2,"Time":"00:20","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":0}

Timers on

⭐ It's adjustable in Web UI as well.

Sunrise Starting Timer

To stop the watering. Timer 3 has a 20 minute offset. This allows for 20 minutes of watering. Do the same for Timer 4 for sunset. Per the Tasmota docs:

When Mode 1 or Mode 2 is used, Latitude and Longitude become available. In that case the Time value is always used as an offset so make sure to set it to 00:00 if no offset is wanted

Sunrise Stopping Timer

Using the Tasmota Web Console Command line, type in the timers to verify: Timer1 , Timer2 , Timer3 and Timer4 .

Runaway Protection

  • First method Timer2 and Timer4 should stop the sprinkler
  • Second method, never runs more than 1,320 seconds (22 mins) when power state is on.
    • Rule1 on power1#state=1 do backlog RuleTimer5 1320; counter1 +1 endon on Rules#Timer=5 do power1 off endon
    • Rule1 1
  • Third method, use NodeRed to trigger a power state off if receiving MQTT messages. This could be adapted to turn off timers when the weather is expected to rain.
  • Monitor on/off times using Graphana. I've prototyped using alerts with a Telegram integration incase all else fails.

Extending to other Platforms (Optional)

Using a simple flow in NodeRed, I've added support for a UI and Alexa control with tracking usage via Graphana. Using the MQTT message tele/tasmota_YOURDEVICE/SENSOR , the data is formatted and sent to a local Graphana instance on a Raspberry PI.

Node red with Alexa support

Node red UI

Simple tracking the ON/OFF state of tasmota MQTT messages

Graphana dashboard from Tasmota MQTT

Graphana dashboard from Tasmota MQTT 7 days

Setup Rules (Optional)

Here are two more timers (or rules) wanted:

  • 🚧 before sunrise, check the temperature. if it's too cold, send a MQTT message and disable start timers
  • 🚧 before sunrise, check the humidity, if it's raining then disable timer.

Resources

History Revisions

  • January 25, 2023 - Update links and verbiage
  • May 23, 2022 - Various updates regarding setup and configurations.
  • November 01, 2020 - PCB designs
  • June 27, 2022 - Timers via console