Introduction: 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

Aquaponics:

  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

Shed:

  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.

screen
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.

screen
sudo python status_Plotly.py

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

Comments

author
bqbowden made it!(author)2017-02-23

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

author
bqbowden made it!(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.

author
jacobsonr made it!(author)2016-10-14

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

author
matthewh415 made it!(author)2016-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.

author
juanjosepimentel made it!(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.

author
matthewh415 made it!(author)2015-02-13

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.

Aquaponics_Dashboard.png
author
lucypullen made it!(author)2016-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!

Lucy

author
nadaklan made it!(author)2015-01-17

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

author
poundchannel made it!(author)2015-02-13

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

author
MichaelH282 made it!(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

author
lucypullen made it!(author)2016-04-19

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

author
pablompole made it!(author)2016-01-10

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

author
Joshgreene24 made it!(author)2015-11-17

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

author
skipthompson81 made it!(author)2015-03-03

any comment on why you chose pi instead of arduino?

author
BlakeS12 made it!(author)2015-11-04

Because pi is awesome?

author
danielh14 made it!(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

author
danielh14 made it!(author)2015-02-07

ignore me I was being a blonker

author
gundamdud made it!(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.

author
pwnage_ made it!(author)2014-10-02

Hi, what pump did you use?

author
matthewh415 made it!(author)2014-11-16

I'm using this pump from Amazon:

http://www.amazon.com/gp/product/B002RBGFA4/ref=oh_aui_search_detailpage?ie=UTF8&psc=1

author
michaelgc made it!(author)2014-09-24

Love the aquaponics, how is this going for you?

author
bestlife123 made it!(author)2014-09-20

The system architecture embedded code?

author
madmedix made it!(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!

author
xanxer82 made it!(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!.

author
Bullock+STEAM+MakerSpace made it!(author)2014-08-05

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

author
xarlock667 made it!(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!

author
pooter1433 made it!(author)2014-06-21

Indeed! LOL!

author
HoboTeaParty made it!(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?

author
matthewh415 made it!(author)2014-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

author
HoboTeaParty made it!(author)2014-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.

author
damionflynn made it!(author)2014-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.

author
matthewh415 made it!(author)2014-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!

author
damionflynn made it!(author)2014-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.

author
stvgrc made it!(author)2014-06-19

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

author
plotlygraphs made it!(author)2014-06-18

Beautiful!

author
tim_n made it!(author)2014-06-16

Fish being kept totally in the dark?

author
matthewh415 made it!(author)2014-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.

author
craftclarity made it!(author)2014-06-16

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

About This Instructable

123,475views

913favorites

License:

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