Bulletin of Electrical Engineering and Informatics

Received Nov 10, 2022 Revised Dec 11, 2022 Accepted Dec 23, 2022 Fish farming is still controlled and managed in the traditional way where water quality and fish feeding are manually controlled. There is a need to use computer and communication technology in fish farms for remote monitoring and control. This paper deals with the design and implementation of an internet of things (IoT) based system for real-time monitoring, control and management of fish farming. The design of such a system is based on measuring different types of variables and using the information to control fish growth and increase productivity. Each fish pond is a node in a wireless sensor network. The node contains an embedded microcontroller connected to a set of sensors and actuators and a wireless communication module. Two fuzzy controllers are designed to control the water quality in the ponds as well as the environment using five sensors in each pond plus three environmental sensors. Practical results indicate the accuracy of the measurement system compared to the results obtained from commercial devices used on the farm. These results also showed that the proposed approach achieves the best performance of the real-time monitoring and control system in fish ponds.


INTRODUCTION
Industries and population growth have contributed significantly to the increase in pollution, so there is a need to take effective decisions to control pollution quickly.A real-time environmental pollution monitoring system is an ideal approach to monitoring and studying the impact of polluting elements on the environment.Monitoring systems containing a number of sensors were used to supply the level of pollution, in addition to statistical data placed on the internet in an organized and easy way to be available to the public [1], [2].Water pollution and climate change are among the most important factors affecting fish farming projects that contribute to the availability of food for an increasing number of population.Fish farmers face other challenges represented in the regular feeding of fish and operating costs [3], [4] in addition to the loss of fish due to diseases caused by water pollution [5], [6].These challenges have encouraged researchers to incorporate modern computer and communication technologies into water quality monitoring and control systems when fish environment become unhealthy [7], [8].
Recently, internet of things (IoT) technology is widely used in many applications in most areas of life.as it is an advanced model of environmental interaction [9], [10].In the field of agriculture and aquaculture, IoT technology has been used to monitor water quality in aquaculture in general and fish in  [11].Fish farmers cannot employ workers to handle the day-to-day operations that usually consist of controlling the water level, water quality, temperature, and feeding the fish [12].Through the use of IoT technology, sensors can be deployed in the environment to obtain real-time data related to weather parameters, air pollution and water quality, while providing relevant statistics available via mobile phone and the internet [13], [14].Water quality is of great importance to the survival and growth of fish, so recent research has focused on designing controllers to control water quality parameters in order to improve water quality and provide a healthy environment for fish.According to Basuel and Reyes [15] developed an IoT based system that determines the quality of water for fish farming by monitoring the earth's surface temperature, water acidity (pH), and dissolved oxygen (DO) in the water.The proposed system also provides periodic recording of water quality for analysis and processing to generate information that fish farmers can easily understand.Short message service has also been integrated into the system to alert stakeholders when water standards are not appropriate.An IoT-based solution that provides real-time monitoring of fish farming has been proposed [5].The system includes set of sensors that measure key parameters to determine water quality.Some systems included a mobile application that allows farmers to remotely monitor fish ponds in order to maintain effective pond management.
Recent published research and studies [14], [16], [17] indicate that incorporating IoT technology into fish farming control systems leads to improved productivity and scalability while developing businesses using next-generation technologies.The IoT is one of the most recent technologies that has presented promising opportunities to create powerful industrial and domestic applications.Among these applications are remote measurement, monitoring, warning, and control.In fish farming, a number of units are built in the deep sea or water ponds equipped with the appropriate sensors and control units.Many studies and research have dealt with monitoring and controlling the quality of pond water to provide a safe environment [7], [18].Some research has proposed an IoT-based system for monitoring water quality in fish farming units, as well as enabling farms to monitor units and control water circulation remotely through a mobile application [5], [6], [19].While other research went to use the concepts of artificial intelligence [3], machine learning [20], and the IoT to monitor water quality and determine the growth of fish based on the change in a number of parameters such as pH, water level, temperature, bad odor and turbidity (Tur).
In the field of fish farming, artificial intelligence has been used in real-time environmental monitoring and control systems.Several research and studies that use soft-computing tools such as fuzzy logic [21], [22], and artificial neural networks [23] to control water quality, track fish size in ponds, and diagnose fish diseases [23], [24].This work presents an IoT-based approach to automating fish farm management and enabling remote monitoring of fish ponds.The rest of the paper is organized as follows; the need for real-time monitoring and control of fish farms is described in section 2. System design requirements are described in section 3. Hardware and software design are discussed in sections 4 and 5. Section 6 addresses the design and performance of fuzzy controllers.Experimental results and discussion are given in section 7. Finally, the most important conclusions are listed in section 8.

FISH POND MONITORING AND CONTROL
The main objective of this research is the intelligent control of water quality because of its great importance in the survival and growth of fish.A number of sensors will be used by the smart controller to control water quality parameters such as DO, pH, total dissolved solids (TDS), and temperature.Through the measurement indicators, an alarm system will be triggered to take immediate action to improve water quality and provide a healthy environment for fish.Alert signals will also be sent to stakeholders informing them of the status of each pond.
Water quality control can be achieved by monitoring many factors including: pH, Tur, water temperature, water conductivity (WC), DO, and TDS.Water quality control is essential for disease prevention in fish farms, and has become essential for international business competition.The temperature clearly affects the chemical reactions in the pond and the growth of the fish.Fish have poor resistance to sudden changes in temperature.Sudden and extreme changes in the water temperature leads to a loss of balance and possibly death of the fish [25].Temperature also affects other factors such as pH, dissolved oxide, conductivity and salinity.Therefore, temperature is very important and has priority in the proposed control system.The pH is a measure to determine whether water is acidic or basic in a reaction.The acidity of the body of water increases during the day and decreases during the night.Much of the pH changes in pond water are influenced by carbon dioxide, which is an acidic gas.The pH control is necessary to reduce ammonia and H2S toxicity.pH is related to many other parameters and is relatively easier to control.Salinity is one of the main factors affecting fish density and development.Conductivity sensor can be used to measure approximate conductivity and salinity, as there is a relationship between conductivity and TDS.Therefore, it is sufficient to measure only conductivity instead of measuring TDS.

Bulletin of Electr Eng & Inf ISSN: 2302-9285 
IoT-based smart monitoring and management system for fish farming (Abdallah Waddah Al-Mutairi)

1437
DO is one of the most important factors affecting fish farming.It decreases with increasing temperature and salinity (conductivity) and is affected by the pH level.Therefore, it can be said that if the temperature, pH, and conductivity are balanced, then the DO will also be balanced.Water transparency (Tr) is an indicator that shows the biological balance in the pond water, as well as the presence of algae in fish farms.The color of the water gives an indication of the type of Tur.If the water is clear, then this indicates a decrease in biological production (in this case the fish will not develop well).If the water is green, it is due to plankton.Dark green water indicates an increased production of plankton which is provided as food for fish but is caused by the use of more than one fertilizer, droppings or rich nutritional supplement in the pond [26].An enviromental study including water quality, temperature and humidity was conducted for Tilapia fish.Table 1 lists the water quality requirements that must be met in a pond in Sukabumi, Indonesia.
Changes in water temperature, for example, affect the amount of oxygen dissolved in the water and the fish's oxygen consumption.Sudden and extreme changes in the water temperature will have a significant impact on the physiology of the fish and may lose its balance, resulting in death [25].Table 2 shows the action to be taken if an increase or decrease in any indicator occurs in any pond.These procedures were collected from specialists who have experience in this type of fish in Egypt and Indonesia.
The proposed system includes a number of ponds, and each pond contains a set of sensors and actuators that are separately controlled.In addition, there are a number of sensors used outside the ponds.The dimensions of the pond are 3×6 m and a depth of 1.5 m.Fish are transferred between ponds according to size.Some farms have the same size of their ponds, and others have several ponds of different sizes.Accordingly, the proposed monitoring and control system has been designed to suit all types of ponds.If pH is high it kills fish (due to fish waste, food scraps and dirt) -Clean ponds and change the water -Schedule fish feeding -Check the quality of the food Water temperature (T) If T is high it kills fish (25°C is recommendedfor growth) -Cooling the environment, close curtains to block the sun's rays -Cooling the water in the pond (for urgent matters) Oxygen saturation (OS) If OS is low it kills fish -Turn on the oxygen pedals, or air bubble pump -Oxygen air to the water (for urgent matters) Water salinity (WS)

If WS is high it kills fish (Each fish type have level of WS)
The water sample should be checked before starting the project.It is not recommended to use a desalination plant due to its high cost.

Ammonia (A)
If A is high it kills fish (reflected by the pH level) The best methods used to remove ammonia: -Replace part of the water daily, starting from 10 to 30% -Adding a measured amount of ammonia-feeding phytoplankton to the pond -Instead of using phytoplankton, add a measured amount of nitrifying bacteria Transparency Test by using Tr disc.
Reflected by temperature, and the feeding quantity.This use for the organic fertilization processes.

SYSTEM DESIGN
The general layout of the proposed real-time monitoring and control system for fish farming is shown in Figure 1.Each fish pond is a node in the wireless sensor network, it is an embedded microcontroller connected to a number of sensors with a wireless communication module [27].The data is measured in real time, as the date and time of receipt of the measured value is recorded.The data obtained from the sensors was stored in the cloud and retrieved for real-time analysis and control.The main control unit calculates a number of indicators for the purposes of generating control signals that ensure water quality and the right environment for fish growth.The web interface unit is used to display the data received from the sensors in real time.The farmer receives alert signals in real time and can, through a web portal or cellular device, generate the necessary control signals to avert any disaster that might occur.Solar panels can be used to generate power in addition to using batteries to ensure continuous power supply to the monitoring and control system [28], [29].

HARDWARE DESIGN
The architecture of the proposed IoT-based monitoring and control system of a fish farming consists of three units; a local controller for each pond, an environment control unit, and a main control unit, as shown in Figure 2.Each pond is considered as a node in a wireless sensor network.Data is transmitted wirelessly between the main control unit and the local controller in each pond.

Main control unit
The main control unit has a microcontroller type ATmega328 interfaced serially with another microcontroller type Esp8266 used for wireless communication.The main microcontroller is connected to the local server via ethernet, as shown in Figure 2(a).The local server is connected to the cloud server so that the farmer can monitor the farm data from anywhere via the internet.

Pond control unit
Each pond contains a local control unit based on a single-chip microcontroller type (ATmega2560) connected to a set of sensors and actuators, as shown in Figure 2(b).This microcontroller is connected wirelessly to the main control unit through another microcontroller type (Esp8266).Each pond have eight sensors for; pH, TDS, Tur, water temperature, DO, electrical conductivity, pressure, and water level in the pond.The output side of the local controller is connected to a set of solid state relays to control the water inlet and drain, as well as control the oxygen pedals and the oxygen bubble pump.

Environment control unit
The environment controller contains a single chip microcontroller type (ATmega2560) connected to a set of sensors and actuators, as shown in Figure 2(c).The Esp8266 controller is used to provide wireless communication with other units.Three environment sensors were used; air quality sensor, air temperature sensor and light sensor.The environment controller is connected to a set of solid state relays to control fan, exhaust, air conditions and lights.

SOFTWARE DESIGN
The general scheme of software design for real-time monitoring and control of the proposed system is illustrated in Figure 3.The foreground portion, shown in Figure 3(a), includes the tasks of initializing the system, updating the display, and reading new commands.Background tasks are written as an interrupt service routine and include scanning of all sensors and checking the level of each signal for the purpose of generating the necessary control and alarm signals, as illustrated in Figure 3(b).MATLAB is used to design the fuzzy controller for each pond and then uploaded into the memory of the embedded microcontroller.
The main control unit is connected to the internet using the ESP8266 module.This unit connects to a Wi-Fi network and starts sending data to the FTP hosting website using a linux server (WHM).All the data of the ponds readings will be stored in database (MySQL).The farmer will interact with the data through a graphical user interface (GUI) designed and programmed using PHP and CSS.The ESP8266 is used as a client that makes an HTTP POST request to a PHP script to enter data (sensor readings, user input, and device state) into a MySQL database, as illustrated in Figure 3(c).This user interface is designed to be easy to use and helps the farmer to monitor sensor measurements, display the fish feeding schedule as well as manage the fish production cycle.The system also provides the service of sending notifications to farmers and stakeholders when the water quality indicators are higher or lower than the standard values.The goal of this part is to visualize the readings from anywhere in the world by accessing our own server domain in the internet.The farmer or specialist will directly update the set points to improve the fish farm situation.

FUZZY LOGIC CONTROLLERS
Real-time monitoring and control of a fish farm is not an easy task due to the large number of indicators that are affected by weather and water quality change and have a great impact on fish growth.Fuzzy logic is an excellent tool for decision making due to its ability to write human rules in fuzzy linguistic terms [30].A fuzzy controller consists of a fuzzifier, fuzzy inference engine, fuzzy rule-base, and a defuzzifier, as shown in Figure 4(a).Two fuzzy controllers are required for the proposed system; the first controller is used to control the water quality in each pond, while the second controller is used to control the environment.As shown in Figure 4(b), the implemented fuzzy controller has three modules; a fuzzification module, a reasoning module, and a defuzzification module.The measured variables are inverted into suitable linguistic variable during fuzzification stage.The Mamdani-style inference process is used, and the center of gravity defuzzification method is applied to convert the fuzzy output into a crisp value.Pond fuzzy controller has five input variables; pH, Tur, DO, TDS, and WC.It has three outputs; water inlet control, drainage control, and oxygen supply control.The environment controller has three inputs; air temperature, air quality and lighting.It generates four actuating signals; cooling, fans, exhaust, and light.The output variables of the pond controller have four fuzzy sets; low, middle, moderate, and maximum.The choice of the number of fuzzy sets to cover the universe of discourse for each variable depends on the influence of that variable on other indicators and its role in fish growth.Input variables for fuzzy controllers have a significant impact on fish growth.
-The WC is affected by the presence of dissolved substances in the water.The United States Environmental Protection Agency (EPA) has specified that central appalachian currents must be between 300 and 500 µs/cm to protect aquatic life.-The EPA has determined the pH of fresh water between 6.0-9.0 -Some fish are used in local streams with TDS near zero.Others can live at TDS between 300-400 ppm.It also depends on the different materials that are added to the pond, which increases the TDS.-It is recommended that DO for fish be 5-7 mg/l for fish health.Fish deaths may occur if the concentration is less than 2 mg/l.-Tur is the measure of relative clarity of a liquid, the recommended range of Tur is 45-75%.
Accordingly, fuzzy rules are written to describe the relationship between input variables and output variables in each controller.For the pond controller, 32 fuzzy rules are used, as shown in Table 3.While 7 fuzzy rules are used for the environmental control, as shown in Table 4.

RESULTS AND DISCUSSION
The ability of the implemented fuzzy controllers to generate the required control signals according to the changes in the input signals was confirmed.Figure 6 illustrates the behavior of the fuzzy controller to the DO and water change in the pond according to the input signals (WC, pH, TDS, DO, and Tur).The behavior of the environment's fuzzy controller is also confirmed as in Figure 7, where the controller adjusts the output signals according to changes in air temperature and air quality indicators.The implemented system was tested to validate the real-time measurements obtained from the sensors, as well as to verify the wireless transmission of data between system units.These readings were recorded for a full hour on October 14, 2021 at 9:00 PM (Jakarta time), as shown in Figure 8(a).Farmers can monitor the readings and control the work of the system through a smartphone or via the internet, as given in Figure 8(b).Parameters are automatically updated every 5 seconds.These readings were also compared with those obtained from certified gauges at the fish farm.
The results of the comparison indicate the accuracy of the measurement system and the ability of the implemented system to transmit data between units wirelessly.Real data from the system including pond water temperature, air temperature and water quality were compared with data from a fish farm in Sukabumi, Indonesia under the same conditions.An environmental test was conducted to record the maximum and minimum temperatures for June 2021, during which the temperature changed between 20-34 °C.The weather temperature was recorded during in Sukabumi/Indonesia June 2021, as shown in Figure 9(a).The environment and teperature of the water well used to supply the fish ponds were recorded at 1:00 PM on June 12, 2021, as illustrated in Figure 9(b).When comparing the water temperature from the IoT-based implemented system with that recorded from the approved DS18B20 water temperature sensor, it becomes clear that the obtained results indicate the accuracy of the sensors and data acquisition unit in the proposed system.The temperature of the water in the well differs from 6-8 °C from the temperature of the surrounding environment.This difference after the pump becomes within 2-3 °C because the pump heats up while working.These experiments indicate that this environment is suitable for Tilapia fish, which need an environment between 8-38 °C, and are easy to achieve at the lowest cost.
It is necessary to test the quality of the water source in fish farms.The result of examining the water sample from the feeding well for fish ponds was as follows: pH is 6.847, water temperature between 28-30 °C, iron is 0.1213, while the chloride is 34.741.These readings are in accordance with the required specifications.The use of clean water reduces the cost of production, as the need for filters and materials related to improving water quality is reduced.

CONCLUSION
The main objective of the proposed IoT-based system is to design and realize real-time monitoring and control of fish farms to provide a safe environment at the lowest possible cost.This can be achieved by selecting a set of sensors connected to an embedded microcontroller integrated with wireless module for each pond.Two fuzzy controllers were used to generate automatic control signals to control the water quality in the ponds as well as to control the environment affecting the growth of fish.The use of IoT technology has greatly contributed to the wireless transmission of information between the system components.It also provides the farmer with real-time measurements as well as necessary alerts via mobile phone or the internet.
This system is characterized by: i) real-time monitoring and control of the aquaculture environment through a mobile phone or the internet, ii) providing the farmer with automatic warning signals to avoid any risks, iii) monitoring water quality and intelligent control of the oxygen pumps, iv) increasing production by providing a safe, healthy and comfortable environment for fish growth, and v) achieving economic feasibility by reducing employment and increasing production.Many fish farms suffer from the problem of providing electricity to the monitoring and control system, due to their distance from residential complexes.As a future work, it is recommended to use solar panels for power generation in addition to using batteries to ensure continuous power supply.

Figure 1 .
Figure 1.General layout of the proposed monitoring and control system Bulletin of Electr Eng & Inf ISSN: 2302-9285  IoT-based smart monitoring and management system for fish farming (Abdallah Waddah Al-Mutairi) 1439

Figure 2 .
Figure 2. Hardware design of the implemented system (a) main control unit, (b) pond control unit, and (c) environment control unit

Figure 3 .
Figure 3. Software design layout of the implemented system (a) foreground portion, (b) background portion, and (c) remote connection

Figure 4 .Figure 5 .
Figure 4. Fish farm fuzzy controller (a) controller elements and (b) input and output variables

Figure 8 .
Figure 8. Sensors testing and remote monitoring (a) sensors readings test and (b) graphical user interface

Figure 9 .
Figure 9. Temperature in Sukabumi/Indonesia in June 2021 (a) weather temperature and (b) temperature in June 12, 2021

Table 1 .
A summary of water quality requirements for Tilapia fish

Table 2 .
Actions to be taken to control water quality in ponds

Table 3 .
Fuzzy rules for pond controller

Table 4 .
Fuzzy rules for environmental controller.
IoT-based smart monitoring and management system for fish farming (Abdallah Waddah Al-Mutairi) 1443