IntroI'm rebuilding my aquaponics system with a new greenhouse. I decided that I would try to automate as much as possible due to the fact that I travel often for work. I want a way to remotely check-in on my system and see if things are going bad and have enough data to be able to give instructions to my wife (or whoever is babysitting the system) on how to fix whatever is going wrong. Also it's nice to have a history so you can identify trends in the behaviour of your AP system.
The Arduino ControllerI turned to the Arduino for the sensor interface. I originally intended to use a bare ATMEGA but the simplicity of the Arduino let me get up and running quicker.
Here is a list of the components I used. I got almost everything from eBay. I would post links but they will probably expire in a month.
1 x Arduino Mega2560 R3 - Cheap chinese clone
1 x Arduino Ethernet Shield - Again, not the original.
5 x DS18B20 water proof temperature sensors in stainless steel sleeve. Tank, sump, growbed1, growbed2 and growbed3.
2 x DHT-22 temperature and humidity sensors. One inside the greenhouse and one outside.
1 x HC-SR04 Ultrasonic Ranger to measure tank water depth.
1 x Atlas Scientific pH test kit.
1 x Atlas Scientific Dissolved Oxygen test kit (Has not arrived yet).
1 x Tiny RTC DS1307 Real Time Clock module.
1 x Hall Effect Flow Meter.
1 x Relay Module. Opto-isolated, 8 channel. For controlling lights, fans, pumps, heaters, etc.
1 x 40x4 LCD module with HD44780 controller.
1 x LM2596 Buck Voltage Regulator module.
1 x Light Dependant Resistor to measure ambient light.
3 x Vibration Switches to detect activity on the bell siphons.
1 x Float Switch to detect low water level in sump.
This is the setup as it is sitting on the test bench now.


Fritzing diagram. Not as complicated as it looks.

The power fail switch-over circuitry schematic. This is responsible for switching over to battery power when the AC fails. The Arduino can sense when AC power fails and take appropriate action.

Here is the Arduino sketch. Bear in mind that this is my first Arduino project though I used to be an embedded device programmer so it's not my first rodeo. I used to code exclusively in AVR ASM and I think that style is reflected in my code (most obviously in my lack of the use of functions). I've included all library's required in the zip file. Also, this is work in progress so there is bound to be many changes to come. A lot of the code comes from various examples around the net so license is open. If you make millions of dollars off of my code, please buy me dinner.
aquaponics_chiumanfu.zipFunctionality descriptionCheck growbed and tank temperature sensors. Turn water heater on if tank too cold.
Check inside and outside air temp and humidity. Turn fans on if inside temp is above threshold or inside humidity is higher than outside humidity. If inside temperature too cold, turn the pump off at night to prevent growbeds acting as heatsinks.
Check pH and DO. Push button to start calibration.
Check light level. Turn grow lights on if it is daytime and ambient light level is low and tank temp is below a temperature threshold.
Check flow meter. Determine if pump is operating at peak efficiency.
Check ultrasonic water level sensor. Turn off pump if water too high.
Check Real Time Clock.
Check bell siphon sensors. If no activity in 1 hour, trigger alert.
Check AC Power Status. Relays auto-switch to backup battery and inverter when AC power is lost. Everything turns off except controller and pumps.
Send REST to Grovestreams for interval sensors every 15 minutes.
Send REST to Grovestreams for random sensors when they are triggered obeying the 10 second timout.
To do :
Relay fish feeder on RTC schedule
Reset RTC from NTP every week
Webserver running on Arduino to allow changing thresholds
Log all data to local SD card
Grovestreams InterfaceI started using Xively for cloud presence and data visualization and really liked it. Unfortunately, they have moved to a corporate model and all us hobbiest are left in the dust. In my search for a new service, I came across
Grovestreams. Although it is still under development, I find it already more mature and feature rich than Xively. It is free if you stay under 20 sensors and 10000 transactions per month... easily doable with a hobbiest system. I just hope grovestreams doesn't go the way of all the rest and change their billing model.
Here is a shot of the Grovestreams dashboard. There are many different graphs, dials, bar charts and tables to choose from. Each widget can be embedded into your own webpage. You can also share a read-only link to your dashboard. If you'd like to see my live dashboard, pm me. I won't make it public because if too many people hit it, I may exceed my free transactions. Bear in mind, this is all just data from my test bench. The controller is not installed in a real system yet.

Here is a shot of a single sensor view. The spike is just me testing the sensor in a glass of ice.

Setting up sensor streams is simple.

Grovestreams is capable of setting up complex alerting schemes. You can configure multiple trigger conditions and multiple actions including email, sms, html, etc. Delivery frequncy lets you set a really critical error to send alerts more frequently than a non-critical warning.
The Aquaponics SystemThe plans are finalized and I've started collecting materials and preparing the ground. Part of it is in space that is already occupied so I will have to wait until my tomatos stop producing before I can finish digging the sump hole and erecting the greenhouse. It is a standard CHIFT PIST system.



more to come...