Home / Lawn & Garden / How to Build Your Own Pi Sprinkler Controller With Opensprinkler & Relay Board
project box is a DeWalt box that I cut out all the plastic supports

How to Build Your Own Pi Sprinkler Controller With Opensprinkler & Relay Board

Sprinkler Controller Using Opensprinkler Software

This is a DIY on the basics of how to build your own sprinkler controller with using open source software called opensprinkler and a Raspberry Pi that you can use anywhere with an app from Play Store or web browser.

Materials you’re going to need are Raspberry Pi; some components, transistor, shift registers, some perf board, soldering iron, solder, resistors, 24-ac volt transformer, 12-volt DC power supply, Relay board, and some other basic tools.

If you like these pages please use the affiliate link. Clicking on it won’t change the price of the product and will help us produce more articles. Please share to social links. If you have comments or questions, leave in comment box below.

It cost $200 and up for an automatic Wi-Fi control rain delay function sprinkler controller. Do it yourself cost around a hundred bucks with a little bit of creativity and ingenuity. If you don’t want to build your own sprinkler controller you can buy pre-built one from opensprinkler.com with expansion boards if needed.  They’re comparable to others without the eliminations. I just want to point out I’m not affiliated with opensprinkler I just think they have a good software and it works well for my needs.

Links & Resources

Article Sections

project box is a DeWalt box that I cut out all the plastic supports



My project box is a DeWalt box that I cut out all the plastic supports. I put a piece of plywood in there to mount my circuit boards, and pi to all the wires that hook up to my sprinkler valves.

 

Sainsmart 16 Channel Relay Board

Quick overview: I used a Sainsmart 16 channel relay board with a 12-volt DC 2 amp power supply, and a 24-volt AC 1 amp transformer to give the power to my sprinkler valves. Sainsmart relay board has a 5-volt voltage regulator on it that I used to power my pi and other circuitry on my board.

If you look at the number one relay,  that is hooked to a transistor that’s controlled by Gpio pin from the pi and it is set as the master valve. The 24-volt AC starts at the main relay and when that Master turns on it gives the power to the rest of the relays, so I’m not constantly burning up fuses. That’s why you must fuse you’re 24-volts. I recommend fusing the 12-volt supply just in case something goes wrong, so you don’t burn up your power supplies or worse.

Sainsmart 16 Channel Relay Board

 You can still use the master without having a master valve in your sprinkler system. I use a Master valve.I always have at least two relays on at one time. When you’re picking your 24-volt transformer, keep in mind you need about 100-200 milliamps per valve that you will be running at the same time. I have another additional master for my garden, so at the most, I use three to four valves at a time. I bought my 24-volt power supply from SprinklerWarehouse.com, and I just found this 12 volt supply that i had.

If you have a small system or you’re not going to go over 12 to 16 valves, you could get away without using shift registers. With my Raspberry Pi model B+ and the open sprinkler software, which I think has an additional 18 pins, I don’t need to use the shift registers as is. I intend to add more to it in time, but if you’re not going to you can skip and ignore how to put in a shift register and just use the gpio pins on the pi and in the software. You would have to come up with a different 5-volt power supply like a cell phone charger or something similar.

Pi, Shift Register and GPIO Diagram

How to connect the shift registers to the Raspberry Pi. The blue wire is ground, and the red wire is 5 volts DC from the relay board that has a 5-volt  voltage regulator on it that Powers Raspberry Pi and other circuits in the diagram. Each one of these shift registers can handle eight channels at a time. You can daisy-chain as many of them as you need to run all your stuff. The diagram I made shows two shift registers for a total of 16 channels. You might want to install opensprinkler on your Raspberry Pi before mounting into your controller box.

Pi, Shift Register and GPIO Diagram

On the left is a diagram of the opensprinkler and the Gpio pins and how they relate to each other in the program. It took me a while to figure out why nothing worked when I use the Gpio pins. It was because I had my wires hook to the wrong pins of the pi.

I’m using a model B+ that has a built-in Wi-Fi. If you use a pi that does not, you will have to make sure you put in Wifi or run a landline to it.

Transistors Diagram

The diagrams below show the layout of the transistors . Your ground on your transistors must be common and hooked to the same ground as your pi. The transistors I am using is an npn 2n3904 and a 1K Ohm resistor. To limit the current, you may be able to use a higher resistor to limit current usage; this is just what I used.

Transistors Diagram

Installing Opensprinkler Firmware

Now, this would be or should be the only time you’re going to need your Raspberry Pi out of your controller. You’re going to have to hook it up to another 5-volt power supply like a cell phone charger and connect a keyboard mouse and a display this pi is installed with raspbian. I assume you know how to get this far if not there are tons of tutorials out there that can show you how to install raspbian on the Raspberry Pi.

I do recommend, so you never have to take the pi out of your controller box, to install a VNC viewer. Make sure it’s up and running on your Raspberry Pi before you put it back into your controller. Your VNC viewer on your computer needs to be on the same network then connect and sign on to your Wi-Fi connection. Once that’s all set up you can put the pi back into your controller. Install Opensprinkler firmware afterward, but either way will work.

Install Opensprinkler Firmware

This is the actual pi I use with opensprinkler installed. I’m looking at it through a VNC viewer. Your first step will be to open up your SSH, the secured shell, if you use a VNC viewer. You can open up the link on another page and simply copy and paste the commands. Just follow the instructions on the opensprinkler firmware link.

Go to your browser in the pi and type in your IP. Best way to find your IP it just move your mouse and hover over the Wifi thing in the corner of the pi. Make sure you put in your IP with colon 8080, and if it all works, it will open up. You should be able to type in the default password of [OpenDoor].

Default Password of [OpenDoor]

How to Create a Static IP

If it all is working fine you might want to create a static IP for your Raspberry Pi. The first thing you need to do is go back into your SSH and type in ifconfig. It should pull up a page like this and you can see what your Mac address is now you can write this down or take a note of it.

Creating a Static IP

Next, you’ll need to login to your internet router. I’m using the Netgear router, but the steps should be close to the same on any of them. Put in your default IP in your browser’s address bar–it should be 192.168.1.1. Enter your default username and password. For Netgear, it is admin and password.

Once you are logged into your router, you’re going to look for Lan setup or settings. Once there, look for address reservation. Select add, find and choose the MAC address of your Raspberry Pi then put in your IP address for it–it can be anything you wish. For mine, I put in 192.168.1.80. I put the device name as sprinkler. Make sure you click add or apply. The IP will never change as long as you’re logged into your local network. If you want to be able to access opensprinkler away from home, you’ll need to setup port forwarding.

Netgear Address Reservation

How to Setup Port Forwarding

Go to port forwarding and Select add. The service name will be HTTP, protocol is TCP, starting Port 80 ending Port 80. Type in the IP address that you set earlier, mine is 192.168.1.80 , click add or apply.

How to Setup Port Forwarding

The next thing you will need is you’re public IP address. So you can acses off Opensprinkler when you’re off of your local network. The easiest way to find this is when you’re on your local network do a Google Search and asked what’s my IP.

what's my IP

The IP address you get will be your public IP. Use that instead of your local IP, and you will be able to connect to opensprinkler anywhere that you have an internet connection.

what's my IP

You can go to your app store, do a search for opensprinkler and download their app on your mobile device. You can use your public IP when setting the app up; then you’ll be able to control your sprinklers from your phone or mobile device anywhere you are. Or use your web browser with the public IP address.

I hope this DIY was easy to follow and you didn’t have too much trouble. Please check out the video if you have not done so already. I know I didn’t get into much technical detail on how to solder and set up your circuitry, I was trying to keep this project quick and simple as I could. I will continue updated tips and tricks, and any information I may have forgotten as i receive comments or suggestions. I want to hear from you.

Also if you enjoyed and found this project useful, I always appreciate any support you maybe able to provide. You can show your support by using any of my links on parts list for products and or sending donations directly. Thank you!

Don’t forget it’s okay to be a cheap as DIY guy or gal– be safe and stay creative.

Parts list

About cheapasdiyguy

4 comments

  1. Hey there! I know this is somewhat off topic but I was
    wondering if you knew where I could get a captcha
    plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one?
    Thanks a lot! https://dermawrx.net/

  2. Hey do you have a guide as to how you’ve set this up in the OpenSprinkler pi? Trying to work out how it’s done with shift registers and how it knows which relay to turn on as if using GPIO pins I found that works straight away.
    Maybe you could email me as I have a few things I’m wondering about and that I would like to try and develop for this! Great guide though! Thanks

Leave a Reply

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

By continuing to use the site, you agree to the use of cookies. Privacy Policy

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close