A fruitful endeavour

Building an irrigation system for some freshly potted plants

With spring in full bloom, this was the year I’d try my hand at gardening.

What started off as a Sunday stroll through a garden centre ended up being quite a sizeable project. Over the course of this summer I’ve been busy planting my own fruit and vegetables, and – in part due to my own laziness – building a solar powered irrigation system to nourish them.

Getting my hands dirty

The project started off quite simple. I picked up five small strawberry plants from Homebase and planted them in a trough on my balcony. After a month or so they had just started to bear fruit until a mass downpour after a thunderstorm drenched them. I made the mistake of not drilling holes at the bottom of planters, so I think the roots have rotted (along with the fruit). Unfortunately, two of the plants are completely dead and the other three appear as though they’re on their last legs!

The strawberry plants are no more.

I wasn’t keen for the project to be a complete failure, so took another trip to Homebase and purchased some pepper and chilli plants, and a grape vine.

The planting was done. Next was to build the irrigation system.

Wiring the hardware

I’ve been asked a number of times, “Shonak, is it really such a hassle to water the plants yourself?”…and my answer is, well, not really! But, aside from being fairly forgetful, it’s a routing activity that’s worth modernising and automating with the use of some simple technology.

In summary: an Arduino microcomputer with a soil moisture sensor constantly detects when the soil is below a certain moisture threshold and activates a pump to pull water from a water reservoir to feed the plants via a silicon tube.

The first part of the project was to setup the power source. I don’t have any electrical outlets outdoors and wasn’t keen to run wires from inside my flat, so figured that I’d take advantage of the masses of sunlight by using a solar panel.

I’ve placed the 120-watt panel on the corner of my balcony – it’s quite large and overkill for the power requirements for this project, although should still sufficient to power the Raspberry Pi and Arduino for a couple of weeks during the dim winter months. I’ve run some wire to the brightest area of the balcony where the power controller is based.

The solar panel tucked away on the balcony

The power controller connects the panel with the beasty 110 amp-hour deep cycle lead acid battery to ensure overnight power delivery via the two USB and 12v ports. This part of the setup was pretty straightforward, the only complication was striping the wire sheath and ensuring a secure fit with the controller connectors (there were a few sparks I had to contend with!).

The power controller, with Arduino USB output (top right) and 12V DC pump output (bottom right)


The deep-cycle battery. This thing is typically used to power caravans and it weighs a tonne!

The most complicated aspect of the hardware setup was wiring up the Arduino.

The Arduino itself connects via USB to the power controller. Now, I won’t go through all of the wiring details, but it broadly corresponds to the setup described in this tutorial.

I did take one shortcut which was to power the peristaltic pump directly from the Arduino output pin, which was a bad idea (the peristaltic pump by the way is literally a 12V motor that squeezes against the silicon tubing to push the liquid through the tube). The Arduino supplies hardly any power via its onboard pins and the pump was slow with a horrible grinding sound. Eventually I purchased an adapter to wire the pump directly to the 12V DV output from the controller, with only the on/off instruction now coming from the Arduino.

The peristaltic pump lives inside a tub of fertiliser (for water and soundproofing)

All of the wiring between the moisture sensor, pump, power controller and Arduino interface with a breadboard, which connects them together. This was my first time using a breadboard and it took some getting used to. Ideally the wires should be soldered together but I’ve kept the breadboard in place so I can experiment further in the future.

Yes it looks a real mess. There was plenty of head-scratching getting the wiring setup correctly to the breadboard.

Aside from the main circuitry for the Arduino, I’ve kept my camera equipped Raspberry Pi opposite the plants to let me remotely keep an eye on the plants.

The Raspberry Pi with a homemade waterproofing solution around the camera

Once all the wiring was setup, the last step was to waterproof all of the wiring and boards. Luckily I had built everything during the summer’s endless heatwave so I had time to figure this out. I invested some additional wiring to run the cables underneath the decking and a plastic container to house all of the boards and wiring.


The Arduino is a physical programmable board that connects to a variety of peripheral components. The language is a hybrid of C/C++, and the coding is done via dedicated IDE.

Arduino is intended as an easy-to-use platform and so there isn’t a huge amount of complexity to the code. There’s only two functions to write for the software: one for setup and another that loops over and over again. It’s far less complicated than regular object-oriented programming. The main challenges are to correctly identify each of the input/output pins to their designated components, and to consider the fact that the program runs constantly on loop.

There’s no fancy logic to my code. The Arduino simply observes the moisture value from the sensor every 30 seconds, and if above a pre-defined ‘wet’ value will activate the pump for 10 seconds. There’s some additional code to accelerate and decelerate the motor to preserve its longevity.

Putting it all together

It only took me 3-4 days to get everything running once I had the parts. Over time, though, a few obstacles crept in.

Calibrating the soil moisture sensor is an on-going challenge and has been a trial-and-error exercise. One of the main limitations of the system is that there is only a single soil moisture sensor for 4 different plants, and of course the reading from one isn’t representative for all of them. Hence, I’ve calibrated the ‘wet’ threshold (which activates the pump) conservatively as I’d much rather under-water the plants than over-water them (to avoid the same fate as the strawberry plants)

The soil moisture sensor. Oh, and yes that is a plastic fork! A low-tech solution for keeping the silicon tubing in place.

I tried to go one step further and put some fertilizer in the bucket but it ended up clogging the silicon tubing, which then snapped when I tried to clean it up. Fortunately, I had some spare tubing to hand.

There’s still a few other issues I’m trying to resolve:

  • The four holes in the silicon tubing aren’t quite equal in size, so some plants are receiving more water than others
  • There also seems to be some weird bug in the code which sometimes permanently activates the pump and floods the plants when crossing the ‘wet’ threshold. Unfortunately, debugging is tricky as the Arduino needs to be physically connected to my laptop to print out the sensor readings and pump status (the main workaround here is to buy a wi-fi board and upload to a server, but I don’t have much time to set this up right now).
  • Some slugs have appeared out of nowhere to feast on the plants! I’m not keen on using any industrial insecticides so have devised a concoction of non-lethal and environmentally friendly chilli powder, soap and water to spray on the leaves. So far, it’s working but I fear for the strawberry plants it’s too late!

Future enhancements

The fruit and vegetables are growing well, although there’s still some work to do.

Firstly, I’m keen to expand my collection of plants, though probably next year now as it’s a bit late in the season. I’m keen to grow herbs like basil, coriander and mint as I buy lots from the supermarket but they’re always supplied in an inconvenient quantity and wrapped in throwaway plastic.

This project has given me an appreciation for the challenges of urban farming, and in fact farming in general. The plants have grown rapidly and have almost become like children (yes, I do talk to them!). They need constant caring for and no two plants have the exact same growing requirements. I wouldn’t say the irrigation system has saved me any time watering plants – quite the opposite in fact, but it’s been good fun to put together in any case.

The peppers have really blossomed in the last couple of weeks

..and so have the chillis!

Another realisation was how many plants are required to sustain my diet. I’ve only grown two pepper plants but this year, and despite all my hard work, they will only yield me enough peppers for 3-4 meals of my delicious vegan chilli recipe. Often, we purchase so much pristine fruit and vegetables from supermarkets without thinking twice about how it got there in the first place. Growing some of my own vegetables has made me appreciate the hard work that goes into producing them and the need to avoid wasting them.

On the tech side, I’m excited to dream up my next Arduino project. The boards are incredibly versatile and there are endless practical projects to pursue – right now I’m thinking an outdoor weather station to complement the irrigation system. I really like the simplicity and community support around the Arduino project.

I think there’s a huge future in urban farming. Speaking on my own behalf at least, I’m increasingly keen to eat fresh food sourced locally rather than from the other side of the planet. As the world looks to decarbonise and mitigate the impact of intensive agriculture, it’s only logical to migrate food production nearer to the point of consumption. Not to mention, there’s always something quite satisfying munching on the fruits of your own labour!


About the Author

Write Your Comment

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>