[image] [image] Ressource protégée - Inria - Institut national de recherche en sciences et technologies du numérique [Accéder directement au contenu](#)

[image] [image]

* [Documentation](#)

* FR
  Français (FR)

* Anglais (EN)
  Se connecter

* [Portail HAL Inria](#)

* Recherche
  Loading...

## Recherche avancée

Information de documents

Titres

○ Titres

○ Sous-titre

○ Titre de l'ouvrage

○ Titre du volume (Série)

○ Champ de recherche par défaut (multicritères) + texte intégral des PDF

○ Résumé

○ Texte intégral indexé des documents PDF

○ Mots-clés

○ Type de document

○ Sous-type de document

○ Tous les identifiants du document

○ Identifiant HAL du dépôt

○ Langue du document (texte)

○ Pays (Texte)

○ Ville

○ À paraître (true ou false)

Ajouter
# Hydric Resources and Meteorological Monitoring IoT System

Raúl Sousa Carvalho, João Miguel Santos, João C. Martins, João Miguel Santos, Patrícia Palma, José Jasnau Caeiro

► To cite this version:

Raúl Sousa Carvalho, João Miguel Santos, João C. Martins, João Miguel Santos, Patrícia Palma, et al.. Hydric Resources and Meteorological Monitoring IoT System. 4th IFIP International Internet of Things Conference (IFIPIoT), Nov 2021, Virtual, Netherlands. pp.252-267, 10.1007/978-3-030-96466-5_16 . hal-04471549

HAL Id: hal-04471549

https://inria.hal.science/hal-04471549v1

Submitted on 21 Feb 2024

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
## Auteur

### Auteur (multicritères)

○ Auteur (multicritères)

○ Auteur : Nom complet

○ Auteur : Nom de famille

○ Auteur : Prénom

○ Auteur : Complément de nom, deuxième prénom

○ Auteur : Organisme payeur

○ Auteur : IdHal (chaîne de caractères)

○ Auteur : Fonction

○ Auteur : personID (entier)

○ Auteur : Identifiant de l'organisme payeur

○ Auteur : Identifiant de la structure

○ Directeur de thèse

○ Éditeur

○ Éditeur scientifique

○ Éditeur de la série

## Ajouter

### Structure

#### Structure (multicritères)

○ Structure (multicritères)

○ Structure : Acronyme

○ Structure : Nom

○ Structure : Code

○ Structure : Pays

○ Structure : Type

○ Structure : État dans le référentiel

○ Structure : Identifiant HAL de la structure

○ Structure/équipe de recherche : Pays

○ Structure/regroupement d'équipes : Pays

○ Structure/laboratoire : Pays

○ Structure/regroupement de laboratoires : Pays

○ Structure/institution : Pays

○ Structure/regroupement d'institutions : Pays

## Ajouter
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
Autres

Champ de recherche par défaut (multicritères)

○ <u>Champ de recherche par défaut (multicritères)</u>

○

○ <u>Revues (multicritères)</u>

○ <u>Revue : Éditeur</u>

○ <u>Revue : Titre abrégé</u>

○ <u>Revue : Titre</u>

○ <u>Revue : Identifiant interne</u>

○ <u>Revue : Date de début de publication</u>

○ <u>Revue : ISSN électronique</u>

○ <u>Revue : ISSN</u>

○ <u>Revue : Éditeur</u>

○ <u>Revue : Couleur dans SHERPA/RoMEO</u>

○ <u>Revue : État dans le référentiel</u>

○

○ <u>Colloque (multicritères)</u>

○ <u>Colloque : Titre</u>

○ <u>Colloque : Organisateur</u>

○ <u>Colloque : date de début (Année)</u>

○ <u>Colloque : date de fin (Année)</u>

○ <u>Conférence invitée (oui/non)</u>

○

○ <u>Projets ANR (multicritères)</u>

○ <u>Projet ANR : Acronyme</u>

○ <u>Projet ANR : Acronyme du programme</u>

○ <u>Projet ANR : Code décision (référence)</u>

○ <u>Projet ANR : Nom</u>

○ <u>Projet ANR : Identifiant interne</u>

○ <u>Projet ANR : État dans le référentiel</u>

○

○ <u>Projets européens (multicritères)</u>

○ <u>Projet européen : Acronyme</u>

○ <u>Projet européen : Identifiant de l'appel à projet</u>

○ <u>Projet européen : Référence</u>

○ <u>Projet européen : Nom</u>

○ <u>Projet européen : Date de fin</u>

○ <u>Projet européen : Financement</u>

○ <u>Projet européen : Date de début</u>
# Hydric Resources and Meteorological
Monitoring IoT System
The Software Architecture

Raúl Sousa Carvalho¹, João Miguel Santos¹, João C. Martins¹, João Filipe
Santos¹, Patrícia Palma¹, and José Jasnau Caeiro¹

Instituto Politécnico de Beja, Beja, Portugal

joao.santos@ipbeja.pt

**Abstract.** An Internet of Things system designed for the collection and processing of surface water quality and meteorological data is presented. The open source software architecture is an important aspect of the design of this system, based on common commercial of the shelf components. It integrates: low power microcontrollers and single board computers to acquire and process the data from the most common parameters measured by water quality monitoring systems; long range communications using the LoRaWAN protocol allowing the system to be deployed over large and remote areas; asynchronous and reliable communications; a container based software design for easy, scalable and controllable deployment, thus reducing the complexity of the reproduction of the experimental setup in systems research. This paper also describes the design and implementation of a geospatial database using free and open source software. The system allows the user to visualize and plot the acquired data from the measurement of water quality parameters and meteorological data of various water-bodies at different time periods. Real-time measurements of parameters such as: air and water temperature; electrical conductivity; pH and evaporation, among others, can be correlated with other important properties. Remote sensing data providing real-time information to predict, prevent and act on water quality is also incorporated in the system.

**Keywords:** Water Quality, Monitoring, IoT, Sensing, LoRa, Containers and Software Architecture

## 1 Introduction

Water quality is one of the main challenges related to the sustainability and development of human life as part of the urgent effort to combat climate change (United Nations, 2018) [19]. Water management systems belong to the set of critical infrastructures. The development and rapid growth of the world population contribute to the deterioration of the environment, with a strong impact on the quality of available water.

Making its evaluation, constant monitoring and management crucial tasks. Water scarcity has been one of the main constraints in the development of the
○ Projet européen : État dans le référentiel

○ Projet européen : Identifiant interne

○

○ Date de production : année

○ Date de mise en ligne : année

○ Date de publication : année

○ Date d'écriture : année

○ Date de modification du dépôt : année

○ Date de dépôt : année

○ Date de publication électronique : année

○

○ Collection HAL (multicritères)

○ Collection HAL : catégorie

○ Collection HAL : Code

○ Collection HAL : Nom

○ Collection HAL : Identifiant interne

○

○ Identifiant interne du contributeur/déposant

○ Nom complet du contributeur/déposant

○

○ Domaines

○ Domaine primaire

○ Domaine racine

○ Sous-domaine niveau 1

○ Sous-domaine niveau 2

○ Sous-domaine niveau 3

○

○ Statut du document

○ Version du document

○ Type de dépôt

○ Type de document

○ ISBN

○ Numéro - référence

○ Identifiant DOI

○

○ Classification

○ Audience

○ Vulgarisation

○ Comité de lecture - texte (oui ou non)

○ Actes de colloque
Alentejo region, limiting the modernization of agriculture and the sustainability of the public water supply. The Alentejo region is characterized by a semi-arid climate with the precipitation going from about 450 mm per year until near or more than 800 mm on the highest altitudes, with the precipitation being below potential evapotranspiration for most of the year, which emphasizes the importance of irrigated agriculture. To accomplish this availability-demand task, the role of high storage capacity reservoir, in order to regulate the supply between dry and wet periods, is an essential aspect, built mainly with the purpose of water storage and for the smoothing of interannual precipitation variability[12], especially when the region is affected by 3-4 year cycle droughts, when using the Standardized Precipitation Index (SPI) for the south of Portugal [15].

Currently, the methodologies used to monitor water quality are based on laboratory analysis, not allowing real-time monitoring and limiting the results to a small geographical area. The Internet of Things (IoT) is based on the possibility that uniquely identifiable things, with sensing and/or actuation and/or processing capabilities, can be connected via the Internet into a huge network of collaborating agents. Among the current environmental problems that can benefit from this ecosystem of technologies is the monitoring and management of water quality. Two of the 17 sustainable development goals (SDGs), adopted by all United Nations member states in 2015 [18] are: goal 6, *Achieve access to water and sanitation for all* and goal 13, *Take urgent action to combat climate change and its impacts*.

Recent advances in sensors, microcontrollers (MCU), single board computers (SBC), and communication technologies, with a significant drop in power consumption and cost, made possible to meet the growing need for water quality monitoring using systems with IoT based architectures, an approach that has been the subject of study over the past few years [14],[1],[17].

Automatic *in-situ* monitoring substantially reduces the labor costs involved in sampling, which requires to travel to the sites under study, in addition to maintenance services at those sites. IoT-based systems, in particular those made with open source hardware and software, have lower costs making them better suited to replication and scalability. This allows a significant increase in the amount of available real-time data from *in-situ* monitoring that can be combined with data from other sources, such as remote sensing and laboratory analysis. On the other hand, the continuous monitoring of water allows a real understanding of the limnological and physicochemical dynamics of the water bodies.

The system carries out a comparative analysis of the results obtained with the limits defined in the standards. The variation of the water quality provides an indication of possible abnormalities in the water system. It will help in the decision-making of water utilities to reduce the contamination risk.

This paper presents the software architecture aspects of a prototype of an IoT-based system for monitoring the surface water quality of rivers and lakes in regions far from monitoring centers, or with difficult access. Starting from a hardware architecture that collects a set of physical and chemical parameters of the water and atmosphere, the software architecture suitable for reading, pro-
○ Référence interne

○ Financement

○ Collaborations

Ajouter

Lancer la recherche
Recherche experte (SolR)

Recherche experte (SolR)

Lancer la recherche
Vers la recherche avancée

• Déposer

Portail INRIA.HAL.SCIENCE
Les publications, logiciels... des scientifiques Inria

• Accueil

• Publications Inria

○ Consulter les derniers dépôts

○ Par équipe de recherche

○ Par auteur

○ Rapports de recherche et techniques

○ Livres blancs

○ Rapports d'activité des équipes

○ Statistiques

• Boite à Outils

○ X2Hal : importer par lot

○ Logiciels : créer le Codemeta.json

○ Créer mon IDHal

○ Créer mon CVHal

○ Haltools : créer ma page de publications

○ Haltools : extraire des données (réservé Inria)

○ Les bonnes pratiques

■ Comment bien s'affilier ?
cessing and visualizing the data is presented. Sensor data is acquired by a set of
local modules and transmitted using the LoraWAN protocol to a gateway that
can be kilometers away. The gateway transmits the data to a central server run-
ning a database management system (DBMS), allowing real-time management
and display. In addition to information on water quality and atmospheric param-
eters, georeferenced information is added with the stations locations (geographic
information system (GIS)). Communications are based on the LoRa technology
and are supported by the ChirpStack software stack. All software infrastructure
components are launched using container technology, reducing the complexity
of software management, deployment and portability. The possibility of repli-
cating and adapting the developed hardware and software architecture to other
sensors and the possibility to add more local modules highlights the diversity of
possibilities that this prototype offers.

Section 2 presents a survey of published work using this kind of IoT sys-
tems, demonstrating and contextualizing the environment in which the project
is inserted. Projects with identical bases or similar aims are also indicated, high-
lighting specific characteristics. The system architecture is presented in section 3,
including the framework of the IoT platform with an emphasis on the software ar-
chitecture. In section 4, experimental analysis, a field testing activity for gaining
a preliminary understanding of the water quality monitoring project is provided.
The components that make up the software framework of the IoT platform car-
ried out are presented, identified, specified and evaluated. Section 5, concludes
the paper by summarizing the main contributions and suggesting possible future
work.

## 2 A Review of IoT Based Surface Water Quality Monitoring Systems

Surface water quality monitoring implies the acquisition of data at a set of dif-
ferent locations along the water surface, at different depths and at regular time
intervals [3, 5]. IoT is playing a major role in monitoring the water quality and
quantity, in real and in continuous time. An IoT system comprises both the
monitoring of a single *thing* up to the interconnection of millions of *things*, with
the ability to deliver complex services and applications [9]. Research has been
done in recent times to develop intelligent systems for the identification and
monitoring of water parameters. From published reviews on the subject [4, 11,
17] three main subsystems stand out: the data collection subsystem; the data
transmission subsystem and the data management subsystem [8]. Some the oper-
ational challenges include the power consumption, security and interoperability.
In general, the three subsystems are interconnected as described below. Sensors
are responsible for gathering information either about themselves or about their
environment. The collection of data from sensors is carried out through MCUs
and/or SBCs, connected through different protocols like UART, I²C or SPI.
Once collected, the data is transmitted using communication technologies, for
example: WiFi, Bluetooth, ZigBee, LoRa, NBIoT, 3G/4G/5G, etc. The data col-
■ Quelle version puis-je déposer ?

■ Choisir le bon « type de document »

■ Mettre en valeur ses publications

○ Les tutos IES Inria

■ Lier les notices dans HAL

■ Umbrhal Inria pour l'accessibilité

■ Personnaliser son CVHAL

■ Créer et Personnaliser sa collection

• Documentation

○ Aide en ligne HAL

○ Aide en ligne Haltools

○ Aide en ligne X2hal

○ Tutoriels video HAL

○ Documentation API HAL

○ Ajouter des vignettes

○ Identifiant auteur IdHAL et CV

○ Compléter son dossier ORCID avec ses dépôts HAL

○ Inria et la Science Ouverte

X

X

X

Loading...

X

Le document que vous demandez est en access restreint
jusqu'au 2025-01-01 !

Revenir a la notice

Retourner à l'accueil

Contact

•

Ressources
lected is processed, cleaned, modeled, analyzed and stored, usually in a DBMS. The data collected from various IoT devices is combined to provide valuable information to the end user. The goal is to provide information as simply and transparently as possible across multiple platforms: tablets, smartphones and desktops.

A survey over published work presenting this kind of systems was carried out to collect the most common options and their evolution within these three subsystems.

A low-cost aquaculture water quality monitoring system with communication based on LoRaWAN is presented in [7]. The system has remote collection and data storage of multi-sensor processor information. A Raspberry Pi controlled LoRa gateway receives data from field devices and transfers water quality parameters into a database. The data is presented on a Website, with a responsive web design, and with the remote monitoring screen, users can track changes of water quality and make timely adjustments with no need to be at the aquaculture site. The database is implemented with MySQL, using XAMPP, in a Window OS.

An agro-intelligence IoT system, with communications also based on LoRa technology, was proposed in [20]. Some nodes were developed to measure a set of environmental parameters, including air and soil temperature, solar radiation, precipitation and barometric pressure, which are sent to a server through a LoRa gateway. The data is decoded and sent over Ethernet to an Internet-of-Things analytic platform where it is aggregated, viewed and analyzed. The nodes are based on Heltec MCUs with LoRa radios and sensors connected to the MCUs over SDI-12 and I²C interfaces.

ARM microcontrollers from the SMT32 family are used in two systems presented by [22] and by [21]. In the first system a water quality monitoring system collects and stores values of quality parameters of water used in aquaculture. Pre-processed data is stored on a local server that can be accessed remotely. Time-series data is displayed with the Grafana software package. In the second system, water quality monitoring sensor data is acquired and pre-processed by the ARM MCU and transmitted over WiFi to a cloud server for analysis and storage in a SQL Server database. The web client (mobile app) reads information from the interactive through the HTTP protocol.

An IoT system the monitoring water quality using a publisher/subscriber architecture with Message Queuing Telemetry Transport (MQTT) protocol with HiveMQ broker was proposed in [13]. The system is composed of a network of relay nodes (publishers), the sensors are controlled by an Arduino and communicate using the Zigbee protocol with a gateway node (subscriber). Data is also sent to a server via the Zigbee protocol.

Also making use of the MQTT protocol, the design and implementation of a IoT water quality monitoring system for crab farming to help the farmer to maintain acceptable levels of water quality is described by [10]. The MQTT system consists of sensor nodes acting as publishers, an SBC acting as broker and mobile client devices as subscribers. Sensor nodes are built with MCUs, LoRa
* Documentation

* FAQ

* API

* OAI-PMH

* AuréHAL

## Informations

* À propos

* Données personnelles

* Mentions légales

* Accessibilité

* Conformité RGAA

## Questions juridiques

* Je publie, quels sont mes droits ?

* Loi pour une République numérique

* Stratégie de non-cession des droits

* SHERPA/RoMEO

## Portails

* Portails institutionnels

* HAL

* HAL SHS

* HAL Thèses

* MédiHAL

## CCSD

* CCSD

* Episciences

* Sciencesconf
radios and water quality sensors. The monitoring system allows remote access to water quality levels through Node-RED. In [2] an environmental and water management monitoring system, using standard water quality monitoring sensors is presented. The probe is connected to a Raspberry Pi via RS232 and the SBC is connected via WiFi to a router/modem which connects the system to the Internet. Data transmission to a SQLite database is done over the MQTT protocol, as in the two previous systems. For data storage, the authors use a DBMS app and a database system built over MariaDB. To monitor sensor devices, the data visualization app uses a Web UI system using PHP and HighChart Javascript to display graphics.

A solution in the field of aquaculture that aims to help fish farmers with intelligent control and water quality management is proposed in [6]. The data collected from sensors using a MCU is transmitted using LoRa technology. The resulting information is transmitted through a GPRS module to a remote server and stored in a database, making it available for visualization. App software development was based on the Browser/Server mode framework and used the LAMP framework development system. For front-end construction, the mature HTML5+CSS+JSP+JQUERY mobile technology stack was used. For the back end, the Java programming language and MYSQL database technology was adopted.

## 3 System Architecture

The subject of this section is the presentation and description of the IoT based system architecture for water quality monitoring with emphasis on the software structure.

A widely adopted IoT reference layered architecture is the one defined by the International Telecommunication Union (ITU), consisting of four layers: devices; network; service support and application support [8]. The layer-based diagram is presented in Figure 1. It shows how the data starts to be collected at the lowest levels and flows through the system up to the point where it is presented to the users. At the lowest level there is the data sources: surface water and atmosphere parameters. It comprises sensors, MCUs and SBCs. Sensors are responsible for providing a measure of the physical and chemical parameters from the surface water and from the surrounding atmosphere. Using data acquisition computing modules, communications hardware, and software protocols, MCUs and SBCs receive and transmit the collected data to the network layer responsible to send data at a long distance to other network devices and servers. The network layer comprises the communication technologies and data transmission protocols. The choice of communication technologies is determined by the existing conditions at the data collection site, in particular the physical conditions, the availability of communications, and the type of power sources.

The top level includes the visualization of the collected and processed data, interacts with users through screens, forms, menus, reports, etc. It is the most visible layer of the application. It defines how the application looks. Comprises
<figure><img src="image_3.png" /><figcaption>**Fig. 1.** A layer diagram of a general IoT water data collection system: each layer consists of modules that offer a cohesive set of services.</figcaption></figure>

the data storage, analysis apps, and visualization layers. This level entails the treatment, analysis and storage of the collected data. The data must be stored and used for smart monitoring and actuation.

The proposed architecture of a water quality and weather data collection and analysis system is represented in Figure 2, Figure 3 and Figure 4. The system may be roughly divided into the following types of data processing subsystems: data collection, data transmission and data management, which includes storage and high-level processing. The data collection subsystems are represented in Figure 2. These include the Water Quality Module and the Weather Station Module. Both modules deliver data to the gateway via LoRa technology. The Water Quality Module provides the acquisition of the most common physical and chemical water quality parameters, namely: pH; ORP; DO and EC. The Weather Station is a device which provides meteorological data from the surrounding environment, namely: air temperature, air humidity, air pressure, precipitation, wind velocity and wind direction, luminosity and UV radiation.

The data transmission system adopts ChirpStack, an open source LoRaWAN Network Server stack with five major components: a LoRa Gateway Bridge; a LoRa Network server; a LoRa Application Server and a MQTT Broker [23], Figure 3. The LoRa Gateway receives the information from the data collection modules, that can be placed at distances ranging from some tens of meters to some kilometers. A single LoRaWAN Gateway can accommodate thousands of devices or nodes. It transforms the format produced by the Packet Forwarder, and the LoRa gateway forwards the data using an MQTT broker to publish the sensor data and exchange control data with the LoRaWAN network/application server. The LoRa Gateway Bridge converts the packet forwarded UDP protocol
<figure><img src="image_4.png" /><figcaption>Fig. 2. Data Collection and Device Communication Architecture.</figcaption></figure>

data into JSON and sends/publishes it to the LoRa Network Server, using a subscription on a MQTT server. The LoRa Network Server eliminates duplicated or redundant information and handles the received uplink frames from gateway(s), handles the LoraWAN MAC layer and schedules the downlink data transmissions. The LoRa Application Server handles the join-requests, encryption of application payloads and offers external services.

LoRaWAN defines a protocol to implement security from the end device to the application server, encrypting the messages exchanged between the two. This protocol uses the AES-128 algorithm to encrypt the message with two different keys. The first key (NwkSKey) is used to encrypt all the messages between the end-device and the network server. The second key (AppSKey) is used to encrypt only the data between the end-device and the application server. In the architecture, the network server and the gateway have no access to the data encrypted with AppSKey. The MQTT Broker requires authentication to implement security during connection establishment. It supports both username/password based authentication and TLS certificate based authentication.
<figure><img src="image_5.png" /><figcaption>Fig. 3. LoRaWAN Communication Architecture.</figcaption></figure>

The LoRaWAN protocol is designed to allow long-range communications at a low bit rate for things (connected objects), operating on battery with low power requirements. Provides low bandwidth communication, this being almost the ideal solution for practical IoT deployments that require less data. The data produced by data collection modules, water quality monitoring or environment control, are applications with a reduced number of periodic messages and relaxed delay constraints. One or two readings per hour is acceptable, with a small amount of data, which does not bring any constraints to the LoRa network. The LoRaWAN characteristics can be summarized as:

- covers long distances, making it well suited for rural and inland solutions;

- consumes less power, which makes the technology convenient for battery powered devices;

- provides low bandwidth communication, this provides a solution for practical IoT deployments that require less data;

- it has relatively low deployment costs, compared to mobile or WiFi due to the lower number of Gateway devices required;

- supports bi-directional communication.

A single LoRaWAN gateway can accommodate 1,000s of devices or nodes, and multiple gateways can provide resilience to smart solutions.

The data management subsystem, Figure 4, comprises DBMS data storage, web server, GIS system, data storing and visualization app, and Node-RED. The MQTT Broker that interfaces between the LoRa Gateway Bridge and the LoRa Network Server, publishes the data from the data collection modules. The *Data Storing App* subscribes the *MQTT broker* for all the topics from the sensors and stores the information at the *DBMS data storage*. In the field of database technology, there are two primary types of databases to store data: relational databases and non-relational databases. There are numerous commercial and
<figure><img src="image_6.png" /><figcaption>Fig. 4. The general data management software architecture.</figcaption></figure>

open-source options for each type of DBMS. It was chosen the relational PostgreSQL database management system, with the geographical PostGIS extensions, and the geographical information system QGIS because they are provided as open source software and have a simple integration procedure. The *Node.js* based *Node-RED* server provides a browser-based low code flow editor for fast and flexible prototyping. Flows can be easily created [24] thus making this software a popular tool for the rapid deployment of IoT systems.

The *data visualization app* filters the information in the database and provides information to users through a web server based on the NGINX proxy server and the Gunicorn UWSGI web server. This application is written in Python and adopts the Flask web framework, Figure 5. The Flask web framework uses a standard Model-View-Controller approach andSQLAlchemy is used as the Model component. The View and Controller are already part of Flask. A sample of the visualization output is presented in Figure 6. The Javascript *Just-Gage* library and the Python * matplotlib* packages are used for this visualization.
<figure><img src="image_7.png" /><figcaption>**Fig. 5.** Flask web application (Python ecosystem microframework). It processes the data in real-time and makes it available with a web environment using JavaScript, CSS, and HTML.</figcaption></figure>

The deployment of the software services is based on several major choices: reliable deployment using modern container technologies; the choice of the Python programming language for most of the development, and open source code. The servers are based on the Linux Ubuntu Server 20.04 LTS (Long Term Service) distribution. The servers are deployed and managed with Docker, with Dockerfiles and docker-compose configuration files. The data storage and processing applications are written in Python and use the available APIs for PostgreSQL (psycog2) and QGIS.

# 4 Software Setup

It was conducted preliminary field testing for water quality monitoring at the Lage Dam, located in Alentejo near Pias, at the south of Portugal (Figure 7), at approximately 160 m altitude. The implemented IoT solution utilizes a LoRaWAN network. The data is provided as represented in Figure 8. The top layer is represented by the applications that store, process and visualize the data received from the ChirpStack LoRaWan stack. This data is received, using MQTT, from the lower level end devices. The water quality and Weather Station modules are each considered and registered as devices in the LoRaWAN network/application server. An MQTT broker interfaces between the LoRa Gateway Bridge and the LoRa Network Server. The data is published by the data collection modules (end devices). The LoRa Network Server subscribes and receives data from the LoRa Gateway Bridge over MQTT and sends the data to the LoRa Application Server. The *Data Storing App*, shown in Figure 9, subscribes the MQTT broker for all the topics from the sensors and stores the information using the data storage management system, presented in greater detail in Figure 10. The database's growth was monitored and recorded an increase of less
<figure><img src="image_8.png" /><figcaption>**Fig. 6.** Result of the execution of the data visualization application. Displays real-time readings from each sensor in the water quality monitoring module and graphically displays the readings history.</figcaption></figure>

than 50KB per day, with 2 readings per hour from each data acquisition station. It is estimated to be less than 20MB per year.

The *Data Visualization App* module filters the information in the database and provides information to users through a web server. To make geographic information available on the internet a QGIS Server is used to deploy maps as a service. The service is deployed using the proxy web server NGINX with a FastCGI (Common Fast Gateway Interface). The geographical information system consists of the PostGIS extensions and the QGIS Server. PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL [25].

## 5 Conclusions

A design and implementation of a real-time water quality monitoring system with an IoT hardware and software structure that collects a wide set of physical and chemical parameters of the water and atmosphere is presented. The
<figure><img src="image_9.png" /><figcaption>**Fig. 7.** GIS system image. Provides real-time data from the water quality monitoring station located in the Laje Dam (Alentejo, Portugal), including the date of the last reading, device name, and the parameters read from the sensors.</figcaption></figure>

system stores data in a database management system, allowing real-time man-
agement and display, generating knowledge and facilitating real-time environ-
mental decisions. Essential attributes are: low cost, namely by adopting open
source software; easy to deploy, maintain and scale services, by choosing a con-
tainer based technology approach, and a consistent programming environment
with the Python programming language. The data is collected with the support
of a LoraWan stack, stored within a relational database with geographical exten-
sions and visualized with the help of a web framework. Additional visualization
using Node-RED is also provided. It is important to stress the integration level
that is achieved by the geographical information system, connecting the water
and weather data collected by the hardware, to the data introduced from other
georeferenced sources.

The presented proposal distinguishes itself from others, mainly in the imple-
mentation of a robust and easy to deploy and maintain software architecture.
It's easy adapt to any other type of IoT project, with scopes different from water
quality monitoring.

In the future the system software will provide data on the power consumption
of all devices. It is foreseen the integration of this monitoring system with a
smart lysimeter module and the entry of non-periodic manual chemical data,
<figure><img src="image_10.png" /><figcaption>**Fig. 8.** Communications structure using container technology. The data collected by the devices are sent to the MQTT broker, through LoRa gateway. The data published by the MQTT broker is subscribed by the applications for analysis, processing and storage.</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>**Fig. 9.** Data storage application architecture. The data subscribed and received from the MQTT broker is stored in the DBMS with an application written in Python using the SQLAlchemy package.</figcaption></figure>
<figure><img src="image_12.png" /><figcaption>**Fig. 10.** Database management and geographical information systems. The data is stored in a database with geographical extensions. It is accessed for different purposes and forms through different software platforms and applications.</figcaption></figure>

resulting from water samples analyzed in laboratory. Due to the critical nature of water data, an external blockchain technology system for data storage and sharing, is thought to offer the benefit of providing a safe, easy-to-manage, and accessible mechanism to share data. The evolution of this system will encompass building a data model of modern pattern recognition systems, machine learning, and artificial intelligence software that allows relating all data collected to be able to predict events and allows monitoring long-term threats to water quality, anticipating of environmental issues. To predict the long-term impacts of water management measures and input of agricultural chemicals (loss of nutrients), the application of The Soil and Water Assessment Tool (SWAT) model, will be considered [16].

This system is envisaged to become a first class instrument for water resources sensing and analysis with wide scientific possibilities.

## References

1. Benedict, S., Gowtham, N., Giri, D. and Sreelakshmi, N. Real Time Water Quality Analysis Framework using Monitoring and Prediction Mechanisms. *2018 Conference On Information And Communication Technology, CICT 2018*. (2018)

2. Budiarti, R., Tjahjono, A., Hariadi, M. and Purnomo, M. Development of IoT for Automated Water Quality Monitoring System. *2019 International Conference On Computer Science, Information Technology, And Electrical Engineering (ICOMI-TEE)*. pp. 211-216 (2019)

3. Chapman, D., Organization, W., Unesco and Programme, U. Water Quality Assessments : A Guide to the Use of Biota, Sediments and Water in Environmental Monitoring. (London : E and FN Spon,1996)
4. Dong, J., Wang, G., Yan, H., Xu, J. and Zhang, X. A survey of smart water quality monitoring system. *Environmental Science And Pollution Research*. 22, 4893-4906 (2015)

5. EPA Parameters of Water Quality: Interpretation and Standards. (Environmental Protection Agency, Ireland, 2001)

6. Gao, G., Xiao, K. and Chen, M. An Intelligent IoT-Based Control and Traceability System to Forecast and Maintain Water Quality in Freshwater Fish Farms. *Computers And Electronics In Agriculture*. 166 pp. 105013 (2019)

7. Hsieh, C., Tsai, Y., Stefanie, C., Wang, C. and Chang, W. The Preliminary Design of Water Quality Monitor System for the Ecological Pond based on LoRaWAN. *2020 International Symposium On Computer, Consumer And Control (IS3C)*. pp. 365-367 (2020)

8. ITU, İTU-T Recommendation Y.4000/Y.2060: Global Information Infrastructure, Internet Protocol Aspects and Next-Generation Networks, Next Generation Networks-Frameworks and Functional Architecture Models, Overview of the Internet of Things. (ITU, 2012), https://www.itu.int/rec/T-REC-Y.2060-201206-I

9. Minerva, R., Biru, A. and Rotondi, D. Towards a Definition of the Internet of Things (IoT). (IEEE Internet of Things, 2015)

10. Niswar, M., Wainalang, S., Ilham, A., Zainuddin, Z., Fujaya, Y., Muslimin, Z., Paundu, A., Kashihara, S. and Fall, D. IoT-Based Water Quality Monitoring System for Soft-Shell Crab Farming. *2018 IEEE International Conference On Internet Of Things And Intelligence System (IOTAIS)*. pp. 6-9 (2018)

11. Olatinwo, S. and Joubert, T. Enabling Communication Networks for Water Quality Monitoring Applications: A Survey. *IEEE Access*. 7 pp. 100332-100362 (2019)

12. Palma, P., Ledo, L., Soares, S., Barbosa, I. and Alvarenga, P. Spatial and temporal variability of the water and sediments quality in the Alqueva reservoir (Guadiana Basin; southern Portugal). *Science Of The Total Environment*. 470-471 pp. 780-790 (2014), https://www.sciencedirect.com/science/article/pii/S0048969713011790

13. Pranata, Lee and Kim Towards an IoT-Based Water Quality Monitoring System with Brokerless Pub/Sub Architecture. *2017 IEEE International Symposium On Local And Metropolitan Area Networks (LANMAN)*. pp. 1-6 (2017)

14. Sadgir, P. and Parag Assessment of Multi Parameters of Water Quality in Surface Water Bodies-A Review. ISSN: 2321-9653. (2015), https://www.researchgate.net/publication/282356694

15. Santos, J., Pulido-Calvo, I. and Portela, M. Spatial and temporal variability of droughts in Portugal. *Water Resources Research*. 46 (2010), https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2009WR008071

16. SWAT Soil and Water Assessment Tool, https://swat.tamu.edu/

17. Santos, J., Caeiro, J., Martins, J., Santos, F. and Palma, P. Physical and chemical water quality parameters sensing IoT systems for improving water productivity. *Water Productivity Journal*. 1, 33-46 (2020)

18. UN-2018 Sustainable Development Goal 6: Synthesis Report 2018 on Water and Sanitation. (United Nations, 2018)

19. UN Sustainable Development Goal 6 Synthesis Report 2018 on Water and Sanitation. *United Nations*. pp. 199 (2018)

20. Valente, A., Silva, S., Duarte, D., Pinto, F. and Soares, S. Low-cost lo-rawan node for agro-intelligence iot. *Electronics (Switzerland)*. 9, 987 (2020,6), www.mdpi.com/journal/electronics

21. Zhang, C., Wu, J. and Liu, J. Water Quality Monitoring System Based on Internet of Things. *2020 3rd International Conference On Electron Device And Mechanical Engineering (ICEDME)*. pp. 727-730 (2020)
22. Zhang, Z., Mao, W., Wang, Z., Tan, X., Wu, F., Wang, D. and Fang, X. Development of Remote Monitoring System for Aquaculture Water Quality Based on Internet of Things. IOP Conference Series: Materials Science And Engineering. 768 pp. 052033 (2020)

23. Chirpstack ChirpStack open-source LoRaWAN Network Server. , https://www.chirpstack.io/

24. Node-RED Node-RED. , https://nodered.org/

25. PostGIS PostGIS — Spatial and Geographic Objects for PostgreSQL. , https://postgis.net/