The Kollmorgen Arduino Watering System Project
Introduction
This was a project undertaken by Darren and Ashley Kollmorgen to create an automated backyard garden watering system using the Arduino electronics platform. Initially, the project's scope was simply to automate the distribution of stored rainwater to different plants with varying requirements, but this soon expanded to include automated plant fertilisation as well as a few other features to be revealed.
Background
Previously, an off-the-shelf tap timer was used for this purpose due to its unique internal mechanism which allowed it to operate under low water pressure, and this was necessary for our use case in which the source of the water was a small rainwater collection tank without a pump.
However, this device could only be instructed to activate each hose line for a constant run time at a constant frequency and did not keep track of absolute real-world time. As such, if the user wanted to specify that a hose line should be watered daily at 5:00AM they would need to switch the device on at that particular time in the morning. It also could not take into account factors such as the temperature of the environment or the amount of rain that had been poured on the garden since its last watering cycle.
It was soon discovered that the internal mechanism of these tap timers could be easily controlled by an external circuit. Internally, the tap timers used a small motor to turn a ball with a hole through it that would only allow water to flow between the input and output hose connectors if it was rotated to the correct position. A small switch would change states when the ball reached either the 'on' or the 'off' position, allowing the microcontroller to know when the ball had just reached the correct position. By rewiring each motor and switch to a relay board and an Arduino Mega, the tap timers could effectively be controlled arbitrarily.
Another piece of pre-existing infrastructure that was repurposed for this project was the outdoor unit of a wireless rain gauge system. During the development of the watering system, the idea was conceived of having the system count how much rain had passed between watering cycles so that the amount of water that the system dispensed could be appropriately reduced. Inspection of the gauge's internals revealed that it was funnelling water into a see-saw-esque container that moved a magnet past a reed switch when it flipped from one side to the other, triggering the system to increment the rain tally by a certain amount. As such, adding rain-counting capabilities to the Arduino Mega was as simple as attaching new wires and a pull-down resistor to the reed switch.
The Features
First and foremost, the system performs a daily watering of the garden at 8:00AM every morning, dispensing an amount of water based on the rainfall and maximum temperature of the previous day. Specifically, the time in seconds for which each line is to be watered is equal to (20 - [rainfall in mm] * 27 + [max temperature in Celsius] * 9), unless this value is below 60, in which case the garden is not watered for that day.
A fertilising cycle is performed at 4:00PM every Sunday, at which point fertiliser and tapwater are poured into a mixing container and distributed across each line over three iterations. The system is also responsible for maintaining the quality of the fertiliser held in the storage tube by stirring it using a pump for two minutes each day.
The system provides a user interface in the form of an OLED screen and a joystick that can be used to navigate a menu of options and features. Moving the joystick to the left or right changes the setting or feature that is being modified or activated whilst up and down movements allow the user to scroll through available choices for that setting or feature. Pressing the joystick inward will select whatever choice the user is currently viewing. As of the time of writing, the available menu pages and choices are as follows:
- Main menu: shows the current state of the system
- Summary screen: shows the current weekday, time, water tank level percentage, predicted total watering time, rainfall count, and temperature
- Last tank percentages: shows the last known water tank level percentages for the past three days, including today
- Last rain levels: shows the last known rain counts for the past three days, including today
- Last max temperatures: shows the last known maximum temperatures for the past three days, including today
- Last watering durations: shows the last known total watering durations for the past three days, including today
- Automatic watering: enables or disables automatic garden watering
- Automatic fertilising: enables or disables automatic garden fertilising
- Automatic pumping: enables or disables automatic fertiliser stirring via pump
- Pump override: allows the pump to be manually switched on or off
- Fertiliser solenoid override: allows the fertiliser solenoid to be manually switched on or off
- Freshwater solenoid override: allows the freshwater solenoid to be manually switched on or off. This causes tapwater to be dumped into the mixing container which is linked to the watering lines and storage tanks, so this feature can be used to fill the tanks or water the garden if necessary
- Fertilise: manually triggers the fertilising cycle
- Fertiliser out: dispences a certain amount of fertiliser into the mixing container
- Watering line control (0-5): manually activates or deactivates the selected watering line either indefinitely, for a period of time, or for a period of time occurring weekly
The Nuts and Bolts
At the heart of the new system is an Arduino Mega 2560 Rev3, which was chosen because of its virtually endless supply of digital I/O pins and sizeable onboard memory. Although the board that was actually purchased was a cheaper clone of the original, this board has since proven itself over many years to have been a reliable drop-in replacement.
A variety of sensors are connected to the Mega for regulating the watering process. A DS3231 real-time clock allows the board to be programmed in terms of real-world dates and times so that it can perform actions at regular daily or weekly intervals with relative accuracy. An HC-SR04 ultrasonic ranging module pointed down through the top of the secondary storage tank provides the board with an ability to judge how much water is being stored. Finally, the outdoor rain gauge unit also allows the board to reduce its watering output based on how much rain has passed since the last watering cycle.
Additionally, an SSD1306 OLED screen and a Jaycar Duinotech X/Y joystick have been added to provide the user with an interface through which they can monitor several aspects of the system and manually operate them if needed.
Twelve of the Mega's digital pins are dedicated to controlling and monitoring the three dual tap timers attached to the system. Six of these pins are wired to an 8-channel relay board that feeds power from a 3V 1A wall wart to the tap timer motors when they are activated, whilst the rest are used as inputs to detect the current state of each tap using the tap timers' built-in switches.
Automatic fertilising is performed by a second relay board connected to a pump and two solenoids that allow the fertiliser in the storage tube to be regularly stirred and dispensed into the garden alongside appropriate quantities of tapwater.
Below is a diagram of the system's plumbing. Rainwater hitting the roof of the surrounding garage is directed into the primary storage tank from which it flows into a secondary tank. These tanks then feeds the three tap timers that govern the six watering hose lines that distribute water across the garden. Attached to the secondary tank is an HC-SR04 ultrasonic ranging module which is used to calculate the amount of water that is currently being stored.
On the other side, a plastic storage container acts as a cauldron for mixing fertiliser and freshwater before sending it down to the tap timers. Two solenoids feed this container; the first allows freshwater to flow in from a tap whilst the second is linked to the fertiliser storage tube. This tube feeds a pump that occasionally activates to move fertiliser from the bottom of the tube to the top to keep it homogenous. While the garden is being fertilised, the pump also pushes fertiliser through the fertiliser solenoid to fill the mixing container. A cutoff switch consisting of a magnet holding a wire attached to a float within the tube disables the pump when fertiliser levels are low enough to risk damaging the pump.
Code
Ashley's Arduino code for this project is available on GitHub at github.com/AshKmo/cucumber.
The following Arduino libraries are requirements of this code:
- "Adafruit BusIO" by Adafruit
- "Adafruit GFX Library" by Adafruit
- "Adafruit SSD1306" by Adafruit
- "DHTlib" by Rob Tillaart
- "DS3231-RTC" by Frank Häfele
Results
After many gradual improvements, a code rewrite and several miniature floods, the watering system has at last been reported to be in a state in which very little ongoing maintenance has been necessary for it to reliably perform its duties, aside from regular refills of fertiliser. The creators have found it quite satisfying to both see the system dutifully water the garden at the appointed times and to eat of the fruit and vegetables that it tends to.