Raspberry Pi Web-Enabled Irrigation Bypass Project

A Better Solution

The problem with rain sensors lies within how they are engineered. My particular rain sensor works by using absorbent cork discs to detect moisture. When it rains, the discs swell-up with water, depressing a switch which disables the watering. The watering is enabled again when the discs dry-out and contract, releasing the switch. There are two problems with this method:

  • The bypass will only disable the watering after it has rained, it cannot predict rain. You may have just finished watering your garden minutes before it starts raining. Would you waste 200 gallons of water on your garden today if it were going to rain tomorrow?
  • With most rain sensors, you cannot control how long to wait before the watering is re-enabled. In my particular case, the cork discs seem to dry out after 2-3 days and then watering commences. After rain, my soil is still extremely saturated with water after 2-3 days, and certainly doesn't need to be watered again. I would like to have more control over how long it takes before my watering schedule is re-enabled.

Raspberry Pi Web-Enabled Irrigation Bypass Project

These shortcomings can be readily solved with a RPi. We can use its network connectivity to get current local weather conditions, forecasts, and even weather history. We can use the GPIO pins and a relay to break the continuity of the rain sensor contacts. Using Python code, we can combine internet connectivity with the ability to control IO to make the project behave however we want.

What You Will Learn:

  • You will learn how to access weather forecast information using the Weather Underground forecast API
  • You will learn how to create a configuration file to save the settings of your program even when your RPi is reset
  • You will construct a simple circuit that will disable your irrigation controller when it rains. The system will provide notification that the system is enabled/disabled/not working even when it isn't plugged into a monitor.
  • You will learn how to run the resulting script on your RPi as a startup service so it will automatically when your RPi is rebooted.

What You Will Need:

  • Raspberry Pi with active internet connection and GPIO library installed
  • A Weather Underground API developer account
  • 1 – 1k resistor
  • 3 – 51 ohm resistors
  • 1 – zener diode
  • 1 – 3v relay switch (I used a Goodsky RW-SH-103D)
  • 1 – green led
  • 1 – red led
  • 1 – blinking red led
  • 1 – 2n2222 transistor or similar (I used an NTE NTE123)
  • An irrigation controller with a rain-bypass option. Mine is a Rain Bird SST-900i

Signing-Up For a Free Weather API Account:

Before you can access live weather feeds from wunderground.com, you will need to sign up to become a member of their weather API program. It is free to become a member, and you will be able to access weather data up to 500 times a day, which is way more than we would ever need for this project. Go to this site, and sign up for an account.

Choose the following settings when you sign up:

  • STEP 1: Anvil plan – this will grant us access to hourly 10-day forecasts
  • STEP 2: History add-on – sure, why not, we may want to use this later
  • STEP 3: Developer – this plan should allow you to ping wunderground.com for weather information up to 500 calls per day, and up to 10 calls per minute.

After doing so, you will have access to your wunderground API key. Make note of this key, as you will need to add it to the python script.

Raspberry Pi Web-Enabled Irrigation Bypass Project Schematic

Program It

You can download the python source code for the program here. Remember, to access the GPIO pins with your Python script, you will need to run Python as a superuser. Launch IDLE IDE as a superuser by typing sudo idle into the terminal. If you choose to run the script from the terminal, type sudo python rain-bypass.py

  • Enter your Weather Underground key at line 15 of the script. Replace the xxx's with your API code.

Run It

This project is designed to run in the dark confines of your garage next to your irrigation controller. After the initial setup, it can be disconnected from any I/O devices, such as your keyboard, mouse, or monitor.

 

For more detail: Raspberry Pi Web-Enabled Irrigation Bypass Project


About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top