IoT based water quality monitoring system for aquaponics

Most tasks can be done remotely nowadays with the help of the Internet of Things (IoT). IoT can also be applied in the agriculture sector such as aquaponics where water quality is crucial to be kept track at all time to avoid loss of resources. Personnel used for water quality checking on-site is becoming less practical for the technologies available today. Remote monitoring system using IoT is essential for water quality monitoring. However, the lack of attention was given by local farmers for applying it in aquaponics. In this study, an IoT based water quality monitoring system for aquaponics was developed to shift from monitoring water quality on-site to remote monitoring via the Internet. Several open-source software was used in developing the monitoring system. The system covers a web server which is accessible via the Internet for user convenience today. Several tests were carried out on aquaponics in the Malaysian Institute of Sustainable Agriculture (MISA). The result shows that the system can display measurements over time and alert users via the dashboard. Other than that, observation indicates that the reporting system is stable and reliable to be used in an aquaponics system.


Introduction
Nowadays, connectivity is a hot issue and the new "big thing". Then comes the Internet of Things (IoT), a new technology which extends connectivity to almost anything. Improving our daily life using IoT is currently a progressive trend which surrounds us day by day [1]. This trend will change humans life and work soon [2]. Application of IoT is wide these days such as smart appliances, homes and cities. However, the application of IoT in the agriculture sector is still low. Despite the advancement of technology, agriculture is still and always be an important sector worldwide as it feeds us, human being and keep us living out of hunger. The increasing human population worldwide requires more food from the agriculture sector [3]. Among the approach can be taken is making agriculture more efficient with the aid of technology without endangering the environment. Aquaponics combines plant and fish farming in a harmony system [4]. As the fishes live in a water tank at the lower level of the aquaponics, the plants grow on the upper level of the aquaponics with the water pumped to flow through the plants' root and back down to the water tank. Thus, aquaponics is one of an efficient and environmentally friendly approach in food production in agriculture and fisheries [5]. However, water quality, especially in term of pH level of the aquaponics, is very crucial to be kept at a near to neutral level at all time. Too acidic water may harm the fishes inside the aquaponics. The monitoring pH level of the water on-site daily today is inefficient in the use of the human resource as technological devices have the potential to be another option to replace human routine works. Therefore, an IoT based water quality monitoring ICTEC 2019 Journal of Physics: Conference Series 1502 (2020) 012020 IOP Publishing doi:10.1088/1742-6596/1502/1/012020 2 system for aquaponics is proposed in this study which to aims to reduce human on-site work by extending monitoring capability on the aquaponics via the Internet using IoT. Although water quality covers multiple parameters, the only pH is taken into consideration in this study as it is the most important parameter to monitor in an aquaponics. Approach taken in this study is using common lowcost electronics (hardware) components available in the market and combining it with open-source software (OSS) available on the Internet. Design of the electronic components' integration is a combination of multiple designs from previous works. Several works have been studied related to the application of IoT in a water quality monitoring system. A work by [6] uses an Arduino as core in the design with a Wi-Fi module for transferring data via the Internet which promos the simplest hardware design. However, the system heavily relied on Internet connectivity and cloud service for data storage and visualization which might involve extra cost. Two works by [7] and [8] shared the same hardware design using Raspberry Pi as the core with an IoT module to send data via the Internet using Wi-Fi to a cloud service for data storage and visualization. A work by [9] uses Raspberry Pi as the core of the design but without an IoT module but directly send data to a cloud service. Based on reviews, a combination of a Raspberry Pi and an Arduino with web server hosting is preferred in this study for better performance and reliability of the system. This study takes a slightly different approach in the application layer by using Docker containers to reduce application response time and improves user experience [10].

Architecture Design
This study uses the three-layer IoT architecture model. Based on the model, the study covers all the three layers; perception, network, and application layers as shown in Figure 1. In the perception layer where sensing takes place, pH level sensor, water level sensor, and ambient light sensor are used. In the network layer where data transmission occurs, Wi-Fi signal is used for local network connection via the device's local Internet Protocol (IP) address and 3G signal is used for Internet connection which requires port forwarding on the used modem and dynamic Domain Name System (DNS) service by Duck DNS. In the application layer which covers data storage and visualisation, local and cloud storage are used. For local storage, a log file, DAT files, and InfluxDB time-series database (TSDB) software are used. While for cloud storage, Google Firebase TSDB cloud service which requires Internet connection is used. In data visualisation, Grafana software is used with the aid of several other software to display the data in gauge and graph forms. A mobile application is not covered in this study. However, with the use of Firebase is used in this study, the monitoring system is capable to be extended to include a mobile application, if available.

Hardware Design
A Raspberry Pi 3 Model B+ microcomputer is used as the core of the design supported by an Arduino Nano microcontroller where all the sensors are connected as shown in Figure 2. Three sensors are used in the system; pH level sensor, water level sensor, and ambient light sensor which all are analogue sensors. The used of Arduino reduces the need of an analogue-to-digital converter (ADC) and a logic level converter as the Arduino already have them built-in. It handles data collection from the sensors independently from the Raspberry Pi except for power supply. A Universal Serial Bus (USB) cable is used for power supply to the Arduino and data transfer to the Raspberry Pi. A mini breadboard and jumper wires are used for connecting the three sensors and a liquid-crystal display (LCD) screen to the Arduino. The LCD screen displays the real-time sensors measurements for on-site monitoring. As the Raspberry Pi has a built-in Wi-Fi module and the monitoring system is based on hosting a web server for remote monitoring, a Wi-Fi signal with Internet connectivity is preferred. Thus, a portable Wi-Fi modem is used in the design which can be substituted for any on-site available Wi-Fi router with Internet connectivity to extend access of the webserver from the Internet. For the portable Wi-Fi modem, an Internet subscribed SIM card is required for Internet connectivity access. Port forwarding is also necessary to be done on any used modem to allow access from the Internet to the webserver. Lastly, to be highlighted that this design is only for a single device on a site application. Multiple devices on a site require modification on the design to be more efficient in resource usage.

Software Design
Raspbian operating system is used as it is the official and most compatible operating system with Raspberry Pi. The concept of 'containers' is applied by using Docker to ease management of software without directly involving the operating system. This study takes the approach of integrating available open-source software for the study's application which is more effective in building it from scratch. Docker was installed on the Raspberry Pi to provide the container platform. Portainer was installed on the Docker to provide a user-friendly interface for managing the Docker. Grafana was installed on the Docker platform to visualising data into gauge and graph forms. InfluxDB was also installed on the Docker platform for local data storage. Other than that, Telegraf was installed on the Raspberry Pi as a metric collecting agent. Figure 3 shows a clearer picture of the software design. The Arduino was programmed to take and process measurements from the sensors in infinite loops. Then, a Python script retrieves measurements from the Arduino via serial communication and writes it into two forms; a log file and DAT files. Another Python script sends the measurements based on values in the DAT files to Firebase as an intermediate to a mobile application, if available. Telegraf agent sends the measurements based on the log file to InfluxDB database on the Docker. Next, Grafana plots the measurements in the InfluxDB database into gauge form for real-time values and graph form for the latest measurement trend observation. Duck DNS service is used for providing dynamic DNS of http://iwater.duckdns.org:3000. For information, port 3000 is the default port of Grafana web server hosting. Therefore, the monitoring system can be accessed in the local network using its local IP address; 192.168.1.205:3000 or via the Internet using the dynamic DNS as Uniform Resource Locator (URL) at any web browser on any device such as a personal computer, tablet, or smartphone for monitoring as shown in Figure 4.

Experiment on the System
Calibration was done on the pH sensor using solutions with standard pH values and measurement from the sensor is converted into pH value as displayed measurement. The water level sensor was tested for measurements it produces based on several water level points. The light ambient sensor was also tested for measurements it produces based on daylight. Measurement of the water level sensor and light ambient sensor are left in ADC values for simpler programming code. The system was tested on-site at Malaysian Institute of Sustainable Agriculture (MISA), a non-profit organization focusing on urban farming for its stability and reliability as shown in Figure 5.  Figure 6 shows the measurement of the aquaponics' pH, water, and ambient light level in the form of a gauge meter and graph plotting. The highest refresh rate can be set in Grafana is five seconds. However, data is continuously being sent to the database almost every second by the system. Apart from that, temperature measurement, CPU usage, and disk space used are also displayed to monitor the health status of the Raspberry Pi. Grafana was also configured to give an alert on the dashboard in case of water level drop or pH level went out of suitable range for the aquaponics. In this test, the pH value of the water varies and the system shows that the alerting mechanism can detect the change of pH level to unsuitable level. Measurement of ambient light sensor shows values greater than 900 in daylight and lower than 100 at night. While water level shows a steady decrease throughout the period. Furthermore, the monitoring system runs smoothly throughout the experiment at MISA without experiencing data loss and stability issues such as crash or freeze. Therefore, the monitoring system proves to be stable and reliable for aquaponics monitoring use.

Conclusion
A prototype device for monitoring water quality in terms of pH level for aquaponics has been successfully developed and tested in MISA. Besides, the device also can measure water and ambient light levels for additional monitoring features. The monitoring system can be accessed from the local network and the Internet for remote monitoring which extend the monitoring capability on the aquaponics to a greater distance. It eliminates the necessity for on-site routine pH and water level monitoring of the aquaponics. However, there is much more improvement can be done such as including an alerting system via messaging app such as Telegram and using a cloud platform instead of hosting a web server from the device. This is a step towards integrating the technological element into managing agriculture for the benefit of mankind.