Tux

Penguin-powered hydroponics!

Linux takes the labor out of gardening







This page serves to document my ongoing project to monitor and automate a hydroponic gardening system.  The goal is to create a sophisticated system which will reduce or eliminate the need for frequent human intervention.


Photos of the prototype system

(click for details)


nutrient dosing
The nutrient dosing system, including air pump
and mini-solenoid valves.



fill/flush system
Fill and drain system



controller board
Prototype controller board



NFT system
NFT channels under construction



NFT system
After planting with lettuce and herbs


Four operations are performed:  fresh water fill, reservoir drain, nutrient dosing, and AC power control.  Also, parameters are measured (such as temperature, pH, and electroconductivity.)

Since this is a prototype, the hardware was constructed out of readily available materials.  The software is implemented mostly on a PC to allow for quick and easy development.  The final goal would be to develop custom mechanical and electronic hardware, most likely controlled by a midrange embedded microcontroller.  For developement and prototyping, a linux PC was chosen to help accelerate algorithm development and testing.

Nutrient dosing

Standard hydro nutrients are contained their original 32 oz bottles.  A small aquarium air pump (3 psi max) is used to pressurize the bottles.  Four mini-solenoid valves dispense accurate doses of individual nutrients.  The intention is to use a three-part nutrient formula and a pH control.

Fill and Drain System

The reservoir must be topped off with fresh water, as well as drained periodically.  I wanted to avoid using yet another pump to do this, so I'm experimenting with a venturi vacuum device normally used to fill and drain a waterbed using a regular faucet.  Three cheap ($10) lawn-sprinkler solenoid valves from are used to direct the flow either through the venturi or, after passing through a flow-restriction valve, to the reservoir.  Turning on one valve fills the reservoir, turing on two others drains the reservoir.  3/4 inch PVC tubing is used to connect everything, along with a 1/2 inch poly hose which runs to the NFT bench.   

Controller

A small controller board was designed to control AC power for three outlets (for an HPS lamp, water pump, and the air pump), low voltage DC for the fill/drain valves, and drivers for the mini-solenoids.  This board also contains the analog circuitry for the sensors.  Click <here> for the circuit schematics.   All communications are via I2C serial bus.  A very simple circuit converts a standard PC parallel port into an I2C master.  This is a bit longer distance than I2C is normally used, but we are still within spec.

Hydroponic system

I'm using a newly constructed small indoor NFT system.  Here I wanted something cheap but functional.  Commercial systems were several-hundred dollars, but this wood frame, with poly-covered wooden channels, was constructed on the cheap.  (Home Depot saves the day.)  The small circulation pump, which is controlled by software, will feed the tops of the NFT channels, with the return flowing into the reservoir.  (I will be using some of the components of my outdoor system while it is down for the winter.)  The nutrient dispenser valves will overhang the reservoir edge.  The remote fill and drain system is connected to the reservoir and controller via a long polyethylene hose, bound alongside two pairs of copper wire.

The plants will get sunlight during the day, from two perpendicular south-facing windows.  Supplemental light may be provided by an HPS lamp, also controlled by software.

Hardware / Software

The software to control the system is written in C and shell scripts and is currently running under Linux.  My system is a 400MHz Dell laptop.  All communication with the controller board is via I2C (a low-speed serial interface @ 100kbps).  A very simple I2C interface board is connected to the parallel port.  A bit-banging linux I2C driver controls the lines, and all the software accesses the bus in userspace through the /dev/i2c-0 port.  This makes it relatively easy to read and write any device on the bus.  The software is basically a state machine with code to handle the various i2c devices.

The controller board consists of two 16-bit parallel I/O expanders (MAX7311) which drive all the relays and measure digital inputs like the float switch, a 4 channel I2C analog to digital converter (MAX1138) to measure the pH and dispenser pressure, and a simple electroconductivity circuit, which produces a variable frequency output which varies with the nutrient concentration.  A binary ripple counter is used to count these pulses and it is read periodically by  software to determine the frequency of oscillation.  (A future enhancement would be to combine the ADC and frequency counting functions on a single 8-pin PIC microcontroller which implements an I2C slave.).  An I2C temp sensor measures ambient air temperature.  Another sensor will measure reservoir temp.  The controller board provides 120VAC control for three devices: HPS lamp (500W max), water pump, air pump.  Four 12VDC drivers control the nutrient solenoids.  A spare Motorola air-pressure sensor connects to the airline tubing.  Measuring the exact pressure in the bottles will allow me to accurately guage the volume of nutrient dispensed.  (Since this sensor measures absolute pressure, it can also determine the atmospheric barometric pressure when the pump is off and bottle pressure has dissipated.)

The hardware is all hacked together on a protoboard, but I'm considering spinning a PCB.  I just need the time to do it.  Ideally the board could fit into a slightly larger version of a standard power strip.  This form factor would make it convenient and familiar.  The remote wires can connect to set of terminal blocks along one side.





The basic algorithm:

Before I can control anything I need to accurately calibrate the system.  To do this I first develop and maintain a constant air pressure in the nutrient bottles, using the aquarium airpump.  The pressure sensor is providing feedback.   I wrote a small routine to automate this.  I dispense successively longer bursts of nutrient into small cups.  Each cup, in turn, sits on a small digital scale.  After each burst, I pause momentarily to allow me to record the weight of the cup.   After completing several rounds of bursts, I enter all the individual weights into the program and it calculates the flow rate of nutrients at the various burst lengths.  It is likely that short burst will dispense less liquid proportionally than a longer burst, due to the inertia of the fluid.  Usually the amount of nutrient dispensed will be in the 1/4 to 8 tsp range.  I want to have accurate flow rates known for each of part of this range.  A burst can only be as long as we can maintain a nearly constant air pressure in the bottles using the airpump.  Right now the routine simply computes averages.  I would like to improve this to do many cycles and compute statistics on the overall accuracy and deviation. 

I would like to have a webpage for the controller also, to combine with the hmeter pages.  The user should be able to enter target EC/TDS/CF, target pH, as well as set flushing and light cycles.

All source code is released under the GPL license.  Source code and schematics are (will be) available on Sourceforge.

source code links (Sourceforge)
hardware pdf (Sourceforge)
Parts list



Last updated December 10, 2004
bkuschak at yahoo dot com