Introduction: Connected Sprinkler Controller Powered by Afero
Manage Your Sprinkler System Wherever You Go!
There is a place in my home where I fear to tread. It is in the front corner of the garage, beneath two beach umbrellas, a ski pole, two baseball bats, and a hedge trimmer. This is where I have to go each time I need to change the settings on my sprinklers. I don’t mind the cobwebs and the bad lighting, but what I really hate is having to deal with the infuriatingly bad user interface on the controller. Strange dials, buttons, and sliders that make no sense, and without the manual, your fate is sealed. The goal for this project is to get rid of the old sprinkler controller and put it out with the household garbage where it belongs.
Out with the Old, and In with the New!
Step 1: The Problem We're Trying to Solve
Valves that control the water flow in your yard are opened and closed using solenoids. Apply 24VAC to the valve and it will open and the water will flow; remove the voltage and the valve will close. The controllers on the other hand, are complicated because they need to include clocks and timers for each valve, settings for days of the weeks, buttons for testing each valve, and hard-to-read displays. What is great about creating your own Afero Sprinkler Controller is that it can be done with a standard Afero Modulo unit and less than $20 of easily-available parts. The timing controls are sent by the Afero Cloud, and everything is managed from your phone.
Step 2: Parts Needed
The list of parts is really quite short. You will need an Afero Modulo, a 4-Relay Arduino Shield board for switching the 24VAC power, an AC/DC Step Down power converter, a Shield Stacking Header to connect the Modulo to the Relay board, and a short length of wire (solid or stranded). You will also need a 24VAC power supply, or you can use the one on your existing watering system. Finally, you’ll need a waterproof case to hold everything once your project is built.
- Afero Modulo Board ($19, available from Mouser)
- 4-Relay Arduino Shield ($3, available on eBay)
- AC/DC Step-Down Converter ($3, available on eBay)
- Insulated Wire (whatever you might have handy)
- 6-pin Shield Stacking Header
- 2.1mm Barrel Jack connector (female) ($3)
- Waterproof case (Pelican 1010, available on Amazon or elsewhere)
- PG7 Plastic Waterproof Cable Gland ($1.50/10 - optional but seals the wiring in the case better)
Step 3: Tools/Test Equipment Needed
This project doesn’t require much beyond a screwdriver, wire strippers, and a drill to make holes in the case for power and wiring. In a few short hours you will be the master of your castle, King or Queen of Home Irrigation.
Small Screwdriver (things have screws, yo)
Wire Strippers (for previously mentioned wire)
Voltmeter (to adjust voltage of Buck Converter)
Soldering Iron and Solder
Power Drill and Bits (to make a hole in the waterproof case)
Castle (so you can be the King or Queen of it)
Step 4: Setup: Things to Do Before You Do the Other Things
Before you start this project, you should have an Afero Modulo and downloaded the Afero mobile app to your phone. If not, to download the Afero mobile app, click here. In addition, you should have already added the Modulo to your account by scanning the QR Code, and plugged it in and verified that you can toggle the LED on the Modulo with your phone. Basic instructions on how to do that are in the Afero Developer docs. Done that? Then let’s get started!
Step 5: Some Assembly Required…
The first part of this project is to pass the GPIO signals from the Modulo to the four Relays that control the sprinkler valves. In the top image, you can see the relay board, and the 2nd image is a close-up of the six-pin connector. The connector has ground (Gnd) on the left, the four signals, and the 5V Vcc pin on the right.
The 3rd image shows four GPIO pins on the Modulo, labeled IO0 through IO3. I want to connect the Modulo IO pins to the Relay’s Input pins so I will use a Shield Stacking Header, but instead of just the four pins, I’m using a six-pin header, and bending the VCC and GND lines out so they can be used to apply power to both the Modulo and Relay.
Solder the Stacking header to the 4 GPIO lines on the Modulo; you may want to use a ‘helping hands’ to hold the header straight while soldering. If the connector isn’t straight, you can heat up each of the solder connections and gently adjust the connector, but it is better to get this right from the start. When you are done, you can test the fit by plugging the Modulo into the relay board.
Step 6: The Modulo Squad Or, Old Solders Never Die, They Just Fade Away
Next, we will want to connect the two bent header pins to the Ground (GND) and 5V (VIN) through-holes on the Modulo board. The GND pin is just opposite the GPIO0 (I00_A0) pin on the Modulo, the 5VCD Input is the very top pin on the same side as the header. I used a fine piece of insulated wire for this. Just be sure to connect the GND and 5V wires to the pins that match the connector on the Relay.
Step 7: Absolute Power!
Now that your Modulo and Relay boards are connected via the Shield Stacking Header, it is time to apply some power. For this, I found an inexpensive AC/DC to DC Buck Converter on eBay ($2.80). Remember that the Sprinkler Valves want 24VAC, and the Modulo and Relay wants 5VDC. Having a single 24VAC power supply supplying power to both is convenient, but we need to convert the AC to DC, and drop the voltage. The Buck Converter is small and useful for a variety of projects, and with the twist of a screw you can easily adjust the output voltage.
Start by soldering wires to the AC/DC input through-holes on the Buck Converter (bottom wires in the top photo). Strip the ends of these wires and connect one to each terminal on the Barrel Jack Converter. Since the power supply provides AC voltage, it doesn't matter which wire goes to which connector. Next, add jumpers to the output side on the top. These will slip onto the GND and Vcc pins that stick up from your Modulo board - but don't connect them yet!.
Now you will want to check and adjust the voltage on the Buck Converter. Start by connecting your voltmeter to the output pins and set the dial for DC Volts. Now plug the AC converter into the wall and plug the connector into the Barrel Jack Connector. While watching the voltage, adjust the small screw on the blue trimming potentiometer until the output is five volts. You are now ready for the final assembly.
Step 8: We Came in Pieces!
You now have all of the key pieces for assembling your new Sprinkler Controller. Before we complete the final wiring, let’s apply power to the system and verify that the main relay is working. Slide the Modulo onto the Relay connector, attach the power (Ground to Ground, ‘+’ to Vcc), and when power is applied, the Modulo should initialize and you should hear the first relay click. You can even get out your phone and launch the Afero mobile app and select the Modulo. When you turn the LED off and on, the first relay should toggle off and on as well. To control all four relays, we will need to create a new Profile, and that will be in just a few more steps.
Step 9: Interlude: Let’s Look at How Sprinkler Valves Work
Look at the wire bundle coming from your sprinkler valves. One of these wires (white in our example) is connected to all of the valves. This wire is called Common since it is Common to all of the valves. This is not to be mistaken for the Relay Common point. Instead this Common will connect to one side of the 24vac power supply. Each of the remaining wires connects directly to one of the four valves. In our case, connecting one lead of the 24vac power supply to the common White wire, and the other to the Red wire, will cause the first sprinkler valve to turn on. Connecting the power to the White and Yellow lead will turn on your second set of sprinklers. You should test that each valve is working properly before going any further.
Step 10: Relay Race to the Finish!
We’re almost done! Now we need to do some wiring for the relays. Remember that the Sprinkler Valves are turned on with 24VAC. A four-sprinkler watering system only requires five wires since one of these wires is common (white) and shared by all of the valves and each of the other colored wires is dedicated to a particular valve. In the top image you can see the white common wire connects directly to one side of the power on the Barrel Jack.
The other source for power for each valve comes from the other side of the barrel connector. This black wire connects to the center/common pin on the first relay. Short jumper wires (see 2nd photo) carry this voltage to the center/common connectors on the other three relays. Now all that is left is to feed each of the colored sprinkler lines to the NO (Normally Open) lines on the relays. When a relay closes, the connected valve will have both the White Common and the Black 24VAC power.
Step 11: The APEs of Wrath… Or, Past Their Primates
For the next step, we will be using the Afero Profile Editor, or APE. APE is a Chrome app that allows you to create and test profiles on your phone and Afero devices. You will use APE to replace the profile on your Modulo with a custom profile specifically designed for controlling a set of sprinkler valves.
Launch APE and sign in using your Afero ID and password. Click the ‘+’ to create a new device profile. Name the profile ‘Sprinklers’.
Shortcut! We've made this APE profile downloadable from GitHub - you should go through the steps to make a profile to see how easy it is, but if you want, you can just download the profile from GitHub and "open" the project in APE instead of creating a new project.
Step 12: APE: Device Types
Create a ‘Sprinklers’ folder for your local copy of the profile and click the Create button to create the profile. (top photo)
You will arrive on the Device Type window. At this point you should add a description and pick an icon that will appear when using the Sprinkler in the Afero mobile app. A sprinkler will be connected to a power outlet, so a 250ms Advertising Interval is appropriate. A longer Advertising Interval can be used to save battery life on projects that are battery powered. Save your changes after each of these steps.
Step 13: APE: Attributes
Click on the Attributes navigation tab to set the GPIO attributes. For each GPIO line, 0 through 3, turn the attribute ON, give it an appropriate name (Relay 1, 2, 3, 4), set the Default level to 0 (off) and set the Operation Mode to Output. When all four GPIO are enabled and configured, save the settings.
Step 14: APE: UI Controls
Click the UI Controls navigation tab and click + New Control. Select the Menu Control then click Add. Under the Attribute, select Relay 1, and give it a name (VALVE 1). Create the first value option as Value:0 and Label: Off. Then click + Value Option to add the second state of Value:1 and Label On.
Repeat the previous steps to create the additional three valve controls. Once all four controls are created, click Save.
Step 15: APE: UI Control Groups
Click the UI Control Groups navigation tab. Click the Valve 1 UI Control and drag it to one of the circles. Click the other valve UI Controls and drag them to the same circle so all of the sprinklers will be under the same control. Click Save and you are done with UI Control Groups.
Step 16: APE: Publish!
Click the Publish navigation tab. Now it is time to send your new profile down to both the device and to your phone. Since you already added your Modulo (see Setup), you will see your Modulo listed as one of the devices that you can publish to.
Next, start the Afero mobile app on your phone and make sure that you can see the device you want to send the profile to. To send the new profile, your Modulo must be powered up and the app must be running and connected to the device. Click the grey checkbox to the left of the device to indicate that this device’s profile will be updated, and then click Publish. In a few moments you should receive a message that the new profile has been sent.
You are now ready to test your new profile. Select the first valve and tap the On or Off button. If you check your Relay board, you will see the LED next to the associated relay turn On and Off based on your command. Test all four relays.
Step 17: Get Off My Case!
The final touch is to put your project inside a waterproof container. I found that a Pelican 1010 case fit everything very nicely. While not necessary, I added a PG7 black plastic waterproof Cable Gland. Once you have moved all of your Sprinkler Valve wires from your old controller to your new wireless controller, apply power and be prepared to take a stroll through your new Smart Garden. Standing by your rose bed and turning on the sprinklers from your phone is incredibly satisfying.
Until the next time, happy watering!