This project implements an embedded monitoring and control system for automated fish tank maintenance using an ESP32 microcontroller. The system continuously monitors water conditions and automatically controls pumps and heating elements to maintain a stable environment for the fish.
The firmware integrates environmental sensing, actuator control, and a lightweight web interface into a single embedded application. Sensor data is collected periodically and processed by a deterministic control loop responsible for regulating water level, temperature, and water quality.
The system was designed to remain lightweight and easy to deploy while still following structured embedded software design practices.
- Real-time monitoring through a web dashboard
- Automatic water level regulation
- Automatic temperature control
- Water replacement based on luminosity/turbidity conditions
- Remote actuator control through HTTP requests
- Wi-Fi station mode or ESP32 access point mode
- Lightweight single-file embedded firmware architecture
The project controls water circulation between three tanks:
- Main fish tank
- Clean water tank
- Dirty water tank
The ESP32 reads environmental data from multiple sensors and decides when to activate the actuators according to predefined thresholds and priorities.
| Sensor | Function |
|---|---|
| DS18B20 | Water temperature measurement |
| HC-SR04 | Water level measurement |
| LDR | Water luminosity / turbidity estimation |
| Device | Function |
|---|---|
| Water Pump (Fill) | Adds clean water to the tank |
| Water Pump (Drain) | Removes dirty water |
| Heater | Maintains water temperature |
The firmware operates using periodic non-blocking tasks. Each sensor is sampled at a predefined interval and the system updates its internal state accordingly.
The actuator control logic follows a priority hierarchy:
- Water level protection
- Temperature regulation
- Luminosity-based cleaning
This prevents conflicting actuator states and ensures deterministic system behavior.
The ultrasonic sensor continuously measures the distance between the sensor and the water surface. If the level becomes too high or too low, the system automatically activates the appropriate pump.
The DS18B20 temperature sensor monitors the water temperature. If the temperature falls below the configured threshold, the heater is activated. If the temperature exceeds the upper threshold, the system can trigger water circulation for cooling.
An LDR sensor is used as a simple approximation of water clarity. When luminosity values indicate excessive turbidity, the system drains dirty water and replaces it with clean water.
The ESP32 hosts a lightweight embedded web server that provides:
- Real-time telemetry visualization
- Sensor monitoring
- Pump state visualization
- Remote actuator control
- System event feedback
The interface is implemented using embedded HTML, CSS, and JavaScript stored directly in program memory.
- ESP32
- DS18B20 temperature sensor
- HC-SR04 ultrasonic sensor
- LDR luminosity sensor
- Relay modules
- Water pumps
- Aquarium heater
Arduino.hWiFi.hWebServer.hOneWire.hDallasTemperature.hArduinoJson.h
Edit the network credentials in the source code:
#define LOCAL_SSID "YOUR_WIFI"
#define LOCAL_PASS "YOUR_PASSWORD"Alternatively, the ESP32 can operate in Access Point mode.
Compile and upload the firmware to the ESP32.
After booting, the ESP32 prints its IP address to the Serial Monitor:
IP: 192.168.x.x
Open the address in a browser to access the monitoring dashboard.