Arduino Aquaponics – Automating fish care

Arduino Aquaponics? Check out this project one of our members made to feed his fish with Arduino.

Dimitris , Dimitris , quite ingenious,
How does your garden grow?
With Arduino, and relay modules,
And pretty tanks all in a row.

This project was submitted by one of our members.  You can see more of our member's projects here.

Not a member yet?  Sign up here.

Project purpose:

Dimitris (a member of Programming Electronics Academy) has an aquaponics garden at his home, but often has to leave for several days at a time. He needed his garden to be tended while he was away because an aquaponics garden is a system that needs a few processes to happen to maintain it.

He turned to an Arduino solution even though he had no experience with it to begin with.

AND I MADE my first working sketch.

Dimitris Balafas

What Even Is Aquaponics?

Aquaponics combines hydroponics (growing plants in water without soil), and aquaculture (raising fish in a tank or pool). This type of system has inputs of light, oxygen, and fish food; and outputs fish and veggies.

The fish eat fish food, which is turned in nutrients for the plants, the plants and helpful bacteria filter the water by using the nutrients in the water, which is then ready for the fish again.

In between, light comes in for the plants, and sometimes plants and fish can be removed for consumption.

This particular Aquaponics system consists of three tanks:

  • The main fish tank (65L) is occupied by four Comet Goldfish
  • The second (45L) full of expanded clay (where the most of the bacteria lives) and to support the roots of the plants.
  • Third comes the last tank (45L) with a floating raft for the plants, a small floating seed starter, a smaller nursery tank for young fish (one week old) and four guppies.

Processes the Arduino takes care of:

While Dimitris is away several processes need to happen to keep his garden healthy:

  • Feeding the fish from a hopper
  • Turning the grow lights on and off for the plants
  • Pumping water through filters
  • Filling the plant tanks with the water

The main materials for this project:

  • Arduino Uno
  • A water level sensor to detect whether pumping between tanks is necessary
  • 4-channel relay module, the Arduino uses it to control the pumps, servo, and grow lights
  • Hobby servo modified to just run on DC voltage to open and close a fish feeder hopper
  • Small immersible pump moves water from tank to tank

Like any proud father, Dimitris is very happy with his project that he put together in just 6 weeks! It’s fantastic that Dimitris jumped into Arduino and not only made his first sketch, but used it to solve a problem in his life and make it better.

He reports that the project fulfills its purpose, and he enjoyed overcoming the normal development challenges for any project.

Dimitris looks forward to other projects and expanding his command of programming in the future.  Nice work!

Arduino Code:

/*Aquaponics DIY starter kit
 * A multitask program with delay (data type unsigned long).
 * We can create a loop from 2 milliseconds short to 4,294,967,295 milliseconds(49.7 days)long.
 * For my sketch I need a loop of 24h.
 * We can use as many GPIO pins as we like.
 * Before we start I have to tell that for me the name of the fuction (delay) is misleading, 
 * the most appropriate name  I thing is (rearange interval)
 */

int Light = 11;
int FGF = 10;//Feed GoldFish
int WF_A = 9;//Water Filter with Air
int WaterPump = 8;
int W_L_S = A0; //Water Level Sensor
int val;
#define ON 0
#define OFF 1

void setup() {
  pinMode(Light,OUTPUT);
  pinMode(FGF,OUTPUT);
  pinMode(WF_A,OUTPUT);
  pinMode(WaterPump,OUTPUT);
  }

void loop() {
  
  digitalWrite(Light, ON);//In this part we declare the state of the degital pins, ON or OFF.
  digitalWrite(FGF, OFF);// If we do not change it, its goin to last till the end of the loop.
  digitalWrite(WF_A, OFF);
  digitalWrite(WaterPump, OFF);
  delay(600000);//10min
  digitalWrite(FGF, ON);// In this part we rearange the state of FGF pin
  delay(2000);          //All the other pins keep on the same state.
  digitalWrite(FGF, OFF);
  digitalWrite(WF_A, ON);
  delay(43200000);//12h
  digitalWrite(FGF, ON);
  digitalWrite(WF_A, OFF);
  delay(2000);
  digitalWrite(FGF, OFF);
  delay(600000);//10min
  digitalWrite(Light,OFF);
  delay(2400000);//40min
  val=analogRead(W_L_S);  //Here the analog pin decides to whitch state ON or OFF she is
  if(val<100){            //and keeps it until the end of the loop
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);    //exept if after a delay we prombt the controler to have another look
  if(val<100){
    digitalWrite(WaterPump, ON);//In my case I progamed my controler to do it every 24h
  }                             //because the water on my tanks after 24h was only 4mm under the optimum level line
  else if(val>100){             //and my water pump needs only 1 min to foolfeel this
    digitalWrite(WaterPump, OFF);//So I have to make 4 sections of 15 seconds if I dont want to overfill my tanks
  }                          //Expecting in the summer to need double amount of water I made 8 sections of 15 secods its.
  delay(15000);              //As soon as the level inticator shows full(at any one of the 8 sections) the pump stops
  val=analogRead(W_L_S);     //The same we can make with any sensor and we can programe to do it at any intervals in the loop.
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  val=analogRead(W_L_S);
  if(val<100){
    digitalWrite(WaterPump, ON);
  }
  else if(val>100){
    digitalWrite(WaterPump, OFF);
  }
  delay(15000);
  digitalWrite(WaterPump, OFF);//In case till this line the pump is still ON 
                               //we have to stop the pump becouse if we dont, it keeps
                               //to be ON till the end of the loop.
  delay(39600000);//11h

}
installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

1 Comment

  1. […] has a three tank aquaponics garden that he wanted to […]

Leave a Comment