Raspberry Pi Controlled Aquaponics




Aquaponics /ˈækwəˈpɒnɨks /, is a food production system that combines conventional aquaculture (raising aquatic animals such as snails, fish, crayfish or prawns in tanks) with hydroponics (cultivating plants in water) in a symbiotic environment. In normal aquaculture, excretions from the animals being raised can accumulate in the water, increasing toxicity. In an aquaponic system, water from an aquaculture system is fed to a hydroponic system where the by-products are broken down by nitrogen-fixing bacteria into nitrates and nitrites, which are utilized by the plants as nutrients. The water is then recirculated back to the aquaculture system. http://en.wikipedia.org/wiki/Aquaponics

This build uses the IBC method of Aquaponics, with modifications to include a Raspberry Pi for controlling a pump, solenoid drain, and temperature probes for water and air temperatures. The relays and timing is controlled with python scripting. Temperature and control data is collected every minute and sent to plot.ly for graphing, and future expansion will include sensors for water level and PH values for additional control.

All of my scripts are available at github.com, feel free to use them for your aquaponics setup. Thanks to Chris @ plot.ly for the help with streaming data to their service, and to the amazingly detailed build instructions provided at IBCofAquaponics.com.

The video below shows the script execution towards the end:

Step 1: Materials


  1. IBC Shipping Container, prepared using instructions at http://ibcofaquaponics.com/

Supervisory Control and Data Acquisition System:

  1. Raspberry PI Adafruit
  2. SainSmart 8-Channel Relay Module Amazon
  3. Brass Liquid Solenoid Valve Adafruit
  4. DS18b20 Waterproof Temperature Sensors Adafruit

  5. Long range WiFi Adapter Amazon


  1. 4x4s, 2x4s, 2x6, Cedar wood fence planks

Step 2: Build IBC Aquaponics / Shed

  1. The shed was laid on 25 1ftx1ft pavers on gravel/sand base.
  2. I followed the instructions/video detailed at http://ibcofaquaponics.com/ to build Aquaponics base and growbed.
  3. Shed frame was built with 4x4s, 2x4s, and 2,6 on top for supporting weight of growbed

Step 3: Wiring Raspberry PI

The raspberry Pi wiring uses three GPIO ports, two for controlling relays for the pump and drain, and another for reading the value of two Waterproof DS18820 temperature sensors.

GPIO 18: Relay Pump
GPIO 24: Relay Drain
GPIO 04: Temperature Probes

Step 4: Raspberry Pi Configuration and Controller Script

Prepare Raspberry PI:

Install Python and Python GPIO libraries:

sudo apt-get update
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio

Download controller and Plot.ly script:

cd ~
git clone https://github.com/matthewh415/PiPonics

Since this script will be running for several days, I recommend running in background process or using screen command.

sudo python pumpController.py

Press Control-AD to exit screen command while controller script is executing.

To return to the session, you use the screen -list command to find screen ID, then screen -r <screen id>:

pi@aquaponics ~/Aquaponics/PiPonics $ screen -list
There is a screen on: 6614.pts-0.aquaponics (09/06/14 20:32:37) (Detached) 1 Socket in /var/run/screen/S-pi.

screen -r 6614

Once controller script is executing, start Plot.ly script inside another screen command.

sudo python status_Plotly.py

Press Control-AD to exit screen command while plot.ly script is executing.



    • Warm and Fuzzy Contest

      Warm and Fuzzy Contest
    • Toys Contest

      Toys Contest
    • Epilog X Contest

      Epilog X Contest

    39 Discussions


    1 year ago

    the cloud solution for aquaponics using raspberry pi is here: https://smart-hub.cloud/


    1 year ago

    Are you measuring ph in your system and if so what sensors are you using?


    1 year ago

    I have wondered if electronic monitoring of my system could be easily done. Not fluent with pie but this looks like a project I could adapt to my needs.


    2 years ago

    Do you think sprinkler valves would in place of brass valves?

    1 reply

    Reply 2 years ago

    No - I experimented with sprinkler valves first. What I found was that they required constant pressure to open and close, and since the drain didn't have much pressure they just stayed closed.

    Great project Matthew, I going to create mine at home. I forked your github project I going to transform your script into a web app. I going to add more features.

    4 replies

    I'll update this instructable soon. I've actually started using a dashing dashboard http://dashing.io/ which displays the data locally now. The timing scripts are all still executed through command line, since they don't change very often.


    Reply 2 years ago

    Hi Matthew, you've got a great idea here. I'm writing to ask if you could you elaborate on step #3. I'm not sure about how to wire the components to the Pi. More detailed instructions would be great!



    3 years ago

    what about ph level monitoring and i am sure other items aside from water and air temp and cycle time of the water

    1 reply

    Reply 2 years ago

    I too am curious about this. It would be great to monitor PH, nitrates and nitrites.....


    3 years ago

    trying to learn to code to add some rules... in the meantime I get :-

    File "status_Plotly.py", line 14, in <module>

    device_file_list = [glob.glob(base_dir + '28*')[0] + '/w1_slave',glob.glob(base_dir + '28*')[1] + '/w1_slave']

    IndexError: list index out of range

    any takers?

    the sensor is connected and working...


    3 years ago

    I keep gettng a syntax error on datetime.datetime.now () for cycle_count. Any suggestions?


    3 years ago on Introduction

    hi for some reason it's asking me for your user name and password when I try and clone from GitHub, can you help

    1 reply

    4 years ago on Introduction

    I love this setup and was wondering if it would be easy to use the same Raspberry Pi configuration for a normal Hydro system? I think the only addition would be adding light and fan control.