Electronics as a hobby ..

For many years now, I have enjoyed electronics as a hobby; something to keep my grey matter engaged and a creative outlet to solve real-world challenges. I view every “problem” which I encounter to be an opportunity to devise an overly: designed, engineered, built, complicated … (pick one) solution.

Were I a real bona fide engineer, I would be designing and building my solutions down to the bare minimum required to resolve the challenge. Engineers spend untold hours optimizing and redesigning, looking to eek out every last bit of design genius or efficiency. Not me! There is no thrill like overkill. Besides, just because you can do more with less, it doesn’t mean that: you have to, it is a good idea, or even necessary.

On to a (relatively) recent example of a problem in search of a James solution.

Picture of the backyard showing fruit tree orchard, raised planers / herb garden, apiary, quail hutch and garden.
Locations (aside from lawn) where irrigation / water are required

When we bought our property, Julie and I decided that we would convert a brick structure in the back into a raised garden for herbs and strawberries. We also wanted to make a garden, so we did. Backing onto a creek, I decided that I would draw surface water for our gardening needs. Naturally, I wanted to know if a permit was required and the answer was: maybe. In our case, for personal use, less than 50’000L a day, a permit was not required.

View of backyard showing creek and pump location
Backyard showing location of water.

Hoping to also one day install an irrigation system for the lawn (or at least portions thereof), I set to looking for an appropriate irrigation zone controller which is both user programmable and “weather smart”. My initial searching revealed commercial offerings starting at $300+ for what I wanted. Being cheap and knowing full well that I could make precisely what I wanted (for around the same price), I set out to making my own.

Requirements: The custom irrigation controller must be capable of at least 8 zones and have WiFi connectivity so that programming changes could be made via web interface. The user would have the option of making it available over the public internet, but in my case, I know better and would make my own IoT device live behind a firewall in its own VLAN allocation. Having the basic requirements down, I decided to make an interface between a Raspberry Pi and the logic and control of a 24VAC irrigation system.

Photo by Gareth Halfacree from Bradford, UK – Raspberry Pi 3 B+, CC BY-SA 2.0

The Raspberry Pi 3B+ was released April 2017 and boasted new features, of which included built-in WiFi and Bluetooth connectivity. Bonus! As it turns out however, due to distance, a USB WiFi adapter with an external antenna connector is a better choice. I was still able to use the Pi’s WiFi but it required installing a yagi antenna on one of my access points and pointing it at the controller.

Eagle cad photo from website

I fired up an old, free version of Eagle CAD and started working away. Being that I started with Eagle CAD many years ago, and having made many rookie mistakes with using provided parts libraries, I set out to create my own entirely hand-made library from data-sheets of components that I planned to use. I started by looking at the mechanical drawings of the Raspberry Pi 3 (chosen for its newly added on-board WiFi). With a part footprint and schematic drawn up for the Pi, I was able to start making the interface.

Raspberry Pi 3 GPIO header and mounting holes PCB footprint.

I started with the footprint of the Raspberry Pi so that I knew roughly what the layout requirements would be in terms of interfacing with the GPIO and power pins. In this design, I opted to use the I2C interface to avoid using 14 GPIO pins for mundane on/off switching. To multiplex the I2C out, I used the venerable MCP23017 I/O expander. Down-stream from the MCP23017, I used a pair of ULN2003 Darlington arrays since the Raspberry Pi has an output voltage of 3v3 and a current limit of 16mA.

My plan was to drive relays (be they mechanical, or as I ended up choosing, solid state) since the Raspberry Pi could not handle the voltage or current requirements directly.

Board layout for Raspberry Pi power supply section

Relays would switch the standard 24VAC used in irrigation systems. Knowing that I would have to step-down 110VAC to 24VAC, I selected a step-down transformer ($17!!) with enough current handling to both drive the irrigation solenoids, as well as power the Raspberry Pi.

This gave me the opportunity to make my own power-supply, more or less from scratch. I was also able to design the whole thing to reside on a purpose built PCB as opposed to an assemblage of parts connected by flying wires (as was my previous iteration of this project, prior to PCB design).

Schematic of AC rectification and DC-DC switching and regulation.

With power to the irrigation solenoids and the Raspberry Pi’s AC-to-DC design block, it was time to work out how to actually rectify and condition the 24VAC input.

I ended up using an LM2596 DC-to-DC switching regulator due to its current handling of 3A (plenty for a Raspberry Pi 3B+). For transient protection (this is a field-mounted device, so lightning impulses may be a thing) I chose a 5A MOV and put it across the transformer’s secondary windings. As it turned out, speccing out my one-off power supply was quite a bit more expensive than purchasing a ready-made “power brick” such as the RAC20-05SK (which still comes in at $18 at the time of writing).

In this specific case, I wanted access to the 24VAC required to drive irrigation solenoids, something which my design afforded. Keep in mind that the transformer which I selected cost me $17 alone.

(Solid state) relay driver schematics

Moving along, it was a simple matter of connecting the Pi’s SDA and SCL lines (header pins 3&5 respectively) to pins 13 and 12 on the MCP2307 I/O expander. From the MCP2307, all 14 possible control lines were brought out to control devices.

Of the 14 control lines, 12 were selected to drive TLP222AF photo relays that are capable of handling up to 500mA of AC (or DC) current at up to 60V!

The remaining two control lines were used to drive mechanical relays which would have current ratings high enough to switch on or off a 110/220v irrigation pump. This would allow full control of the system to prevent wasting water in the event of a distribution line rupture (i.e. the pump is only enabled when the system calls for an irrigation zone to be enabled).

Top layer board layout

Ultimately, the project was really straight forward but it allowed me to roll my first custom power supply, as well as learn a few things the hard way in terms of PCB design. This was not my first project where I would have a design sent out to a PCB fab house; I’ve been in the game for quite a few years now as a hobbyist. I have to say, things have changed! The quality, price and turn-around time are phenomenal from off-shore sources! I find it difficult to understand how these fab houses make any money.

PCB (top side) back from fab house

My latest version of the design came back and is what I’ve been using for a couple of years now with absolutely no regrets. The design meets all of my needs; I am the weak link in the system. My programming skills have gotten VERY lax and so the potential of my irrigation controller is not even close to being met. My future hope is to leverage the OpenWeatherMap API for evapo-transpiration / irrigation calculations and smart watering based on good data. Right now I have a way over-designed on-off timer. Lol.

Raspberry Pi 3 and irrigation control board housed in an 8x8x4″ plastic junction box for weather protection

The controller has been serving me well for a couple of years now, and offers a remote temperature sensing station in the back yard. I have a few other plans for the Raspberry Pi’s processing power which more or less sits idle.

Perhaps this Raspberry Pi will see an interface to a WSPR station or another radio related use. We shall see.

This entry was posted in General and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

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