IoTIntermediatePRJ-161

IoT Smart Aquarium (Monitor + Auto Feeder) Using ESP32

Watches water temperature and clarity, and feeds the fish on a timer.

Built and tested by Drisya K S · Industrial Robotics Institute

Circuit diagram of the IoT Smart Aquarium (Monitor + Auto Feeder) using ESP32
Circuit diagram · ESP32
LevelIntermediate
Build time3–4 hours
BoardESP32
Parts8 components

What is the IoT Smart Aquarium (Monitor + Auto Feeder)?

A smart aquarium controller. A waterproof DS18B20 measures water temperature and a turbidity sensor checks how cloudy the water is; both are sent to the Blynk app, with a buzzer alert if either goes out of the safe range. A servo-driven feeder drops food automatically at a set interval.

How it works

  1. The DS18B20 measures water temperature; the turbidity sensor measures cloudiness.
  2. Both values go to Blynk V1 and V2 every few seconds.
  3. Temperature above 30 °C or turbidity above 500 sounds the buzzer and sends "Water Condition Alert!" on V3.
  4. Every feeding interval (12 hours by default) the servo turns to drop food, then returns.

Parts list

ComponentQty
ESP32 Dev Board1
Waterproof Temperature Sensor (DS18B20)1
Resistor 4.7kΩ (pull-up)1
Turbidity Sensor (or pH sensor)1
Servo Motor (feeder)1
Buzzer1
Jumper Wires / BreadboardAs needed
5V Power Supply1

Software

  • Arduino IDE
  • Blynk IoT app
  • OneWire library
  • DallasTemperature library
  • ESP32Servo library

Wiring and connections

FromConnect to
DS18B20 VCC3.3V
DS18B20 GNDGND
DS18B20 DATAGPIO 4 (4.7kΩ to 3.3V)
Turbidity VCC5V
Turbidity GNDGND
Turbidity OUTGPIO 34 (via divider to 3.3V)
Servo VCC5V
Servo GNDGND
Servo signalGPIO 5
Buzzer +GPIO 26

How to build the IoT Smart Aquarium (Monitor + Auto Feeder)

  1. Connect the DS18B20 data to GPIO 4 with a 4.7kΩ pull-up to 3.3V.
  2. Connect the turbidity sensor output to GPIO 34 through a voltage divider.
  3. Mount the servo on a small food container so turning it drops a pinch of food; connect it to GPIO 5.
  4. Connect the buzzer to GPIO 26.
  5. In Blynk, create datastreams V1 temperature, V2 turbidity and V3 alert, with gauges and a label.
  6. Install the libraries, add your Blynk details and Wi-Fi, set feedInterval and upload.

IoT Smart Aquarium (Monitor + Auto Feeder) code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.

#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Smart Aquarium"
#define BLYNK_AUTH_TOKEN "YourAuthToken"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP32Servo.h>

char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";

#define ONE_WIRE_BUS 4
#define turbidityPin 34
#define buzzerPin 26
#define servoPin 5

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Servo feeder;

float tempThreshold = 30.0;
int turbidityThreshold = 500;

unsigned long feedInterval = 12UL * 60 * 60 * 1000;   // every 12 hours
unsigned long lastFeed = 0;

void feedFish() {
  feeder.write(90);
  delay(1000);
  feeder.write(0);
}

void setup() {
  Serial.begin(115200);
  sensors.begin();
  feeder.attach(servoPin);
  feeder.write(0);
  pinMode(buzzerPin, OUTPUT);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

void loop() {
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  int turbidity = analogRead(turbidityPin);

  Blynk.virtualWrite(V1, temperature);
  Blynk.virtualWrite(V2, turbidity);

  if (temperature > tempThreshold || turbidity > turbidityThreshold) {
    digitalWrite(buzzerPin, HIGH);
    Blynk.virtualWrite(V3, "Water Condition Alert!");
  } else {
    digitalWrite(buzzerPin, LOW);
    Blynk.virtualWrite(V3, "Water OK");
  }

  // Automatic feeding on a timer
  if (millis() - lastFeed >= feedInterval) {
    lastFeed = millis();
    feedFish();
  }

  Blynk.run();
  delay(2000);
}

Real-world uses

  • Home aquariums
  • Fish shops
  • Aquaculture and fish farms
  • Learning water sensing

Frequently asked questions

What is a IoT Smart Aquarium (Monitor + Auto Feeder)?

A smart aquarium controller. A waterproof DS18B20 measures water temperature and a turbidity sensor checks how cloudy the water is; both are sent to the Blynk app, with a buzzer alert if either goes out of the safe range.

What components are needed for the IoT Smart Aquarium (Monitor + Auto Feeder)?

You need: ESP32 Dev Board (1), Waterproof Temperature Sensor (DS18B20) (1), Resistor 4.7kΩ (pull-up) (1), Turbidity Sensor (or pH sensor) (1), Servo Motor (feeder) (1), Buzzer (1), Jumper Wires / Breadboard, 5V Power Supply (1). Software: Arduino IDE, Blynk IoT app, OneWire library, DallasTemperature library, ESP32Servo library.

Is the IoT Smart Aquarium (Monitor + Auto Feeder) project good for beginners?

It is rated intermediate and takes about 3–4 hours to build, using the ESP32. The guide on this page explains every connection and step.

Where can I get the code for the IoT Smart Aquarium (Monitor + Auto Feeder)?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the IoT Smart Aquarium (Monitor + Auto Feeder)?

Yes. IRI sells a kit with the parts for this project (PRJ-161). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo