Aquaponics automation combines fish tank and plant bed monitoring into an integrated system that maintains optimal conditions for both aquatic life and plant growth. Aquaponics — the symbiotic cultivation of fish and plants — is growing rapidly in India as an efficient food production method using 90% less water than conventional farming. This guide covers building a complete automated aquaponics monitoring system with ESP32, water quality sensors, and automated pump control.
Table of Contents
- Aquaponics System Basics
- Critical Water Parameters to Monitor
- Components Required
- Circuit and Wiring
- ESP32 Monitoring and Control Code
- Automation Logic
- Aquaponics in India
- Frequently Asked Questions
Aquaponics System Basics
An aquaponics system cycles water between the fish tank and plant grow beds:
- Fish produce ammonia-rich waste
- Beneficial bacteria (Nitrosomonas) convert ammonia to nitrites, then to nitrates
- Plants absorb nitrates as fertiliser — water is cleaned
- Clean water returns to fish tank
This nitrogen cycle requires maintaining tight parameter ranges. A single failure — pump stoppage, temperature spike, pH drift — can kill both fish and plants within hours. Automated monitoring and alerts prevent catastrophic losses.
Critical Water Parameters to Monitor
| Parameter | Ideal Range | Critical Alarm | Impact |
|---|---|---|---|
| Temperature | 22-28 degrees C | Below 18 or above 32 | Fish stress, bacteria slowdown |
| pH | 6.8-7.2 | Below 6.0 or above 8.0 | Nutrient lock-out, fish death |
| Dissolved Oxygen | Above 5 mg/L | Below 4 mg/L | Fish suffocation |
| Ammonia | Below 0.5 ppm | Above 2 ppm | Fish gill damage |
| Water level | 80-100% full | Below 70% (pump air-dry) | Pump burnout |
Components Required
Products from Zbotic
- 12V DC Mini Submersible Water Pump — for water circulation between fish tank and grow beds
- 5V/12V Relay Control Module — for pump and aerator control
- GY-BME280 Sensor — ambient temperature and humidity monitoring for grow room
Full aquaponics monitor parts list:
- ESP32 development board
- DS18B20 waterproof temperature probe (for water temperature)
- pH sensor module (analog, requires calibration)
- TDS/EC sensor (for nutrient level monitoring)
- Ultrasonic sensor HC-SR04 (waterproof variant) for tank level
- 2-channel relay module for pump and aerator control
- Air pump (for dissolved oxygen aeration)
- Water circulation pump (12V submersible)
- OLED 0.96″ display (for local status)
- Buzzer (emergency alarm)
Circuit and Wiring
Sensor connections:
- DS18B20 data -> GPIO4 (with 4.7k pullup to 3.3V)
- pH sensor AOUT -> GPIO34 (ADC1_CH6)
- TDS sensor AOUT -> GPIO35 (ADC1_CH7)
- HC-SR04 TRIG -> GPIO26, ECHO -> GPIO25 (use JSN-SR04T waterproof variant)
- Relay IN1 -> GPIO27 (water pump), Relay IN2 -> GPIO14 (air pump)
- OLED SDA -> GPIO21, SCL -> GPIO22 (I2C)
- Buzzer -> GPIO13
Keep pH and TDS sensor probes in separate compartments to avoid cross-interference. Clean pH probes weekly with electrode cleaning solution. Store pH probes submerged in KCl storage solution when not in use.
ESP32 Monitoring and Control Code
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_SSD1306.h>
#include <WiFi.h>
OneWire oneWire(4);
DallasTemperature tempSensor(&oneWire);
Adafruit_SSD1306 display(128, 64, &Wire, -1);
#define PUMP_PIN 27
#define AIR_PIN 14
#define BUZZER_PIN 13
#define LEVEL_TRIG 26
#define LEVEL_ECHO 25
const char* ssid = "AquaFarm";
const char* pass = "yourpassword";
// Parameter thresholds
const float TEMP_MIN = 20.0, TEMP_MAX = 30.0;
const float PH_MIN = 6.5, PH_MAX = 7.5;
const float TDS_MIN = 300, TDS_MAX = 1200; // ppm
const float LEVEL_MIN_CM = 10; // Alert if tank too low
float readPH() {
int raw = analogRead(34);
float v = raw * 3.3 / 4095.0;
return -5.70 * v + 21.34; // Calibration values
}
float readTDS() {
int raw = analogRead(35);
float v = raw * 3.3 / 4095.0;
float ec = (133.42 * v * v * v - 255.86 * v * v + 857.39 * v) * 0.5 / 1000.0;
return ec * 640; // Convert mS/cm to ppm
}
float readWaterLevel() {
digitalWrite(LEVEL_TRIG, LOW); delayMicroseconds(2);
digitalWrite(LEVEL_TRIG, HIGH); delayMicroseconds(10);
digitalWrite(LEVEL_TRIG, LOW);
long dur = pulseIn(LEVEL_ECHO, HIGH, 30000);
return dur * 0.017; // Distance in cm (speed of sound / 2)
}
void checkAlarms(float temp, float ph, float tds, float level) {
bool alarm = false;
if (temp < TEMP_MIN || temp > TEMP_MAX) { Serial.println("ALARM: Temperature!"); alarm = true; }
if (ph < PH_MIN || ph > PH_MAX) { Serial.println("ALARM: pH!"); alarm = true; }
if (tds < TDS_MIN || tds > TDS_MAX) { Serial.println("ALARM: TDS!"); alarm = true; }
if (level < LEVEL_MIN_CM) { Serial.println("ALARM: Low water level!"); alarm = true; }
if (alarm) {
for (int i = 0; i < 3; i++) {
digitalWrite(BUZZER_PIN, HIGH); delay(300);
digitalWrite(BUZZER_PIN, LOW); delay(200);
}
}
}
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
tempSensor.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
pinMode(PUMP_PIN, OUTPUT);
pinMode(AIR_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LEVEL_TRIG, OUTPUT);
pinMode(LEVEL_ECHO, INPUT);
// Default: pump and aerator on
digitalWrite(PUMP_PIN, LOW); // Relay active LOW
digitalWrite(AIR_PIN, LOW);
WiFi.begin(ssid, pass);
Serial.println("Aquaponics Monitor Ready");
}
void loop() {
tempSensor.requestTemperatures();
float waterTemp = tempSensor.getTempCByIndex(0);
float ph = readPH();
float tds = readTDS();
float level = readWaterLevel();
checkAlarms(waterTemp, ph, tds, level);
// Display on OLED
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Temp: "); display.print(waterTemp, 1); display.println(" C");
display.print("pH: "); display.println(ph, 2);
display.print("TDS: "); display.print(tds, 0); display.println(" ppm");
display.print("Level:"); display.print(level, 0); display.println(" cm");
display.display();
Serial.printf("T:%.1fC pH:%.2f TDS:%.0fppm Level:%.1fcmn",
waterTemp, ph, tds, level);
delay(30000); // Read every 30 seconds
}
Automation Logic
Beyond monitoring, the system automates key processes:
- Timed pump cycles: Media-bed aquaponics uses flood-and-drain cycles (15 min on, 45 min off) to oxygenate roots
- Low water auto-refill: When level drops below threshold, open solenoid valve to top up from reserve tank
- Temperature response: If water temperature exceeds 30 degrees C, activate chiller or increase aeration rate
- pH dosing: Auto-dose small amounts of food-grade acid (phosphoric acid) when pH drifts above 7.5
- Feed timer: Automatic fish feeder relay on schedule (3x daily)
Aquaponics in India
Aquaponics is gaining traction across India:
- Urban farms (Bengaluru, Pune, Mumbai): Rooftop aquaponics for fresh fish and greens — local premium market
- ICAR research stations: Tilapia-vegetable systems demonstrating 60% higher protein production per square metre vs conventional farming
- Northeast India: Freshwater fish (Rohu, Catla) combined with rice using traditional Dhap farming integrated with IoT
- Arid regions (Rajasthan, Gujarat): 90% water saving vs soil farming — critical for water-scarce areas
Frequently Asked Questions
What fish species work best for aquaponics in India?
Tilapia (Nile) is the most popular — fast-growing, temperature-tolerant (20-32 degrees C), disease-resistant. Common carp, Rohu, and Magur (catfish) are also used. Trout requires cold water (12-18 degrees C) and is suitable for Himachal and Uttarakhand.
How accurate are the cheap pH sensors for aquaponics?
Analogue pH sensors (BNC-type, Rs 300-500) are accurate to ±0.1-0.2 pH units after 2-point calibration with pH 4.0 and 7.0 buffer solutions. Recalibrate every 2 weeks. For research-grade monitoring, invest in Atlas Scientific EZO-pH module (more stable, I2C interface).
Can I run aquaponics on solar power?
Yes, but size the system carefully. Pumps run 15-45 minutes per hour on average. A 100W solar panel with 100Ah battery can run a 50W pump system through cloudy days. Add a battery low-voltage cutoff to prevent deep discharge.
What is the minimum viable system size for commercial aquaponics?
For a viable commercial operation in India, minimum 1000 litres fish tank with 20 square metre grow beds. This supports 50-80 kg fish and 200-300 plants simultaneously, generating Rs 15,000-25,000/month revenue from mixed produce.
Add comment