Introduction: Raspberry Pi Controlled Aquaponics

Picture of 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.

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 for graphing, and future expansion will include sensors for water level and PH values for additional control.

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

The video below shows the script execution towards the end:

Step 1: Materials


  1. IBC Shipping Container, prepared using instructions at

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

Picture of 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 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

Picture of 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

Picture of 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 script:

cd ~
git clone

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

sudo python

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 script inside another screen command.

sudo python

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


vunguyen390 (author)2018-01-09

the cloud solution for aquaponics using raspberry pi is here:

bqbowden (author)2017-02-23

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

bqbowden (author)2017-02-16

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.

jacobsonr (author)2016-10-14

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

matthewh415 (author)jacobsonr2016-10-14

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.

juanjosepimentel (author)2014-06-22

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.

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

lucypullen (author)matthewh4152016-04-19

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!


Hey juanjosepimentel, did you ever get around to making that web app? I'd be interested in checking it out.

poundchannel (author)nadaklan2015-02-13

I am interested in that as well! Perhaps I can assist being as I am a web developer as well.

MichaelH282 (author)2016-01-10

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

lucypullen (author)MichaelH2822016-04-19

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

pablompole (author)2016-01-10

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

File "", 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...

Joshgreene24 (author)2015-11-17

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

skipthompson81 (author)2015-03-03

any comment on why you chose pi instead of arduino?

BlakeS12 (author)skipthompson812015-11-04

Because pi is awesome?

danielh14 (author)2015-02-07

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

danielh14 (author)danielh142015-02-07

ignore me I was being a blonker

gundamdud (author)2014-11-18

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.

pwnage_ (author)2014-10-02

Hi, what pump did you use?

matthewh415 (author)pwnage_2014-11-16

I'm using this pump from Amazon:

michaelgc (author)2014-09-24

Love the aquaponics, how is this going for you?

bestlife123 (author)2014-09-20

The system architecture embedded code?

madmedix (author)2014-08-17

I like this too; the cold frame/insulation idea would increase your growing time. As an aside, a cold frame for the growing section and a couple of brewing heat belts might just guarantee year round comfort for the fish and food for you. For an auto feeder, there's a whack of instructables on feeding your cats hacking old VCRs etc.

Thanks for sharing!

xanxer82 (author)2014-08-05

I think anywhere north of TX, insulating the shed and adding a cold frame on top of the grow bed would be wise to do. Very cool project!.

spectacular job...great detail and solid build design!

xarlock667 (author)2014-06-19

Yes, but where is your fish launching cannon? What use are all these fish with no way to shoot them? LOLZ. No, seriously I love the idea of aquaponics. I was all set to turn our warehouse here in Houston into an aquaponics facility and try raising nile tilapia, tiger prawn, and blue crab and my boss pulled the plug. Grrrrrrrrrrrrrrrr.... Nothing like 2 weeks of wasted research to brighten your mood. One thing you might try is to make it into a streaming system. This is a similar system in most respects but creates an artificial channel in wich to raise the fish, rather than a stationary pond. It utilizes more space but nets more fish. (Pun intended). Anyway, good luck, and make a fish cannon. Fish cannons are kewl and make more efficient use of fish than merely throwing them back into the sea as some commercial trawlers do. Target? Why the fish trawlers of course. If anyone asks, it was a fish mutiny, NOT a fish cannon! You saw nothing!

pooter1433 (author)xarlock6672014-06-21

Indeed! LOL!

HoboTeaParty (author)2014-06-19

Have you thought about adding a auto feeder that is connected to the system. With it connected you can have it stop feeding the fish during our short cold weeks. Also what part of texas?

matthewh415 (author)HoboTeaParty2014-06-19

Definitely - my wife is already getting annoyed with feeding the fish while I'm at work. I've looked for some commercial feeders that I could tie into, but I'm not finding many that are fully waterproof and hackable, so will likely build my own soon. San Antonio, TX

HoboTeaParty (author)matthewh4152014-06-20

I was looking into a diy auto feeder and was thinking of a stepper motor that you would pulse with a digitally controlled voltage source. I am not sure if the PI can do that or if it can pulse the relays correctly to get the same result so I may have to use a microcontroller like a A-uno or something.

damionflynn (author)HoboTeaParty2014-06-19

Good idea.

Also, should this be implemented, it would be a good idea to put in an inline water tester that tests for ammonia. nitrite and nitrate. If you notice spikes, it could automatically reduce feeding and alert operator by text message.

matthewh415 (author)damionflynn2014-06-19

That would be ideal... right now I'm sampling all those manually and it's another great automation opportunity. I've found a few digital probes for pH monitoring, but haven't seen any that can continuously sample for ammonia and nitrates... if you come across any please let me know!

damionflynn (author)matthewh4152014-06-19

There are numerous that test anything from PH, Temperature, TDS, Ammonia, Nitrite, Nitrate, Hardness (GH and KH) and even some that will monitor iron (important as you will almost always be adding iron to your system) and calcium as well as other trace minerals as well.

I do not have any specific examples but a quick search for them will return results.
Personally, I do not use them. As I am frequently checking AP and hydro systems all over the MS Coast, it is much easier for me to use strips or the API master kit when I am out at other locations.

stvgrc (author)2014-06-19

This is awesome. Very clean build. And what a great use of a Ras Pi.

plotlygraphs (author)2014-06-18


tim_n (author)2014-06-16

Fish being kept totally in the dark?

matthewh415 (author)tim_n2014-06-16

Not completely; I live in Texas which has daylight for most of the year and seeps in pretty well through the slats in the sides/door/access lid.

craftclarity (author)2014-06-16

Super clean implementation, and really nice build! Thanks for sharing this.

About This Instructable




More by matthewh415:Raspberry Pi Controlled Aquaponics
Add instructable to: