**1. Introduction**

Water is a scarce and precious resource that is being put under pressure due to the fast-growing population that is extracting too much water and polluting our rivers, lakes, and groundwater with municipal, agricultural, and industrial wastes. Climate change, loss of biodiversity, unsustainable use of natural resources, and environmental pressures have a negative impact on water quality and quantity which are inextricably linked, with over extraction causing low river flows, low ground water levels, and drying up of wetlands. The deteriorating water environment, accelerating the shortage of water and affecting human health, has become an important problem that restricts the development of cities.

One of the most important environmental problems today is, undoubtedly, the contamination of water by nitrates, especially in areas with significant agricultural activity, as occurs in the southeast of Spain [1,2]. The nitrates are natural components of soil and water, both surface and underground, which come, in part, from the decomposition of nitrogenous organic matter, although their presence in the soil and in aquifers increases with the use of nitrogenous fertilizers and manure in areas with a high level of agricultural activity. Farmers invest large amounts of nitrogenous fertilizers in the fields to maintain adequate production and increase yields. Most of these are not absorbed by plants, so they settle in the soil and gradually filter through it, reaching groundwater. Similarly, these compounds can circulate through surface runoff and cause contamination problems in surface, fresh, or marine waters [3].

An excessive contribution of nutrients in surface waters, especially nitrogen and phosphorus, gives rise to a rapid proliferation of aquatic vegetation, as a consequence of oxygen depletion on the surface, which favors the appearance of eutrophication processes [4]. The Mar Menor (Region of Murcia, southeast of Spain) has been in the news in recent years due to the eutrophication, which refers to the processes of the ecosystem originated by the enrichment of nutrients of the water, especially nitrogen and/or phosphorus [5,6]. This situation, added to by the fact that most of the effluents from the wastewater treatment plants (WWTP) in this area are used for irrigation in agriculture, implies an increase in responsibility of the water industry to adopt a more sustainable management of urban water systems for this type of compound [7]. One of the most effective approaches to address this challenge of sustainability is wastewater treatment, in which water quality monitoring (WQM) plays a key role.

WQM can be described as a method for periodically sampling and analyzing water conditions and characteristics [8]. This method forms the basis for water environmental management, as it is vital to monitor source waters and the aquatic systems that receive inputs from industrial waste and sewage treatment plants, stormwater systems, and runoff from urban and agricultural lands [9]. Similarly, domestic sewage and water flows resulting from chemical processes and waste in industry and sanitation should be monitored in wastewater treatment plants that purify the water to decontaminate it before releasing it into the sea (or other large bodies of water), or be used for other applications such as irrigation, and to detect possible toxic or radioactive discharges [10]. Wastewater, also known as sewage, contains more than 99% water and is characterized by volume or rate of flow, physical condition, chemical constituents, and the bacteriological organisms that it contains. The quality of treated wastewater is defined by physical-chemical parameters such as pH, temperature, conductivity, turbidity, Biological Oxygen Demand (BOD), Chemical Oxygen Demand (COD), Total Organic Carbon (TOC), Total Suspended Solids (TSS), and nitrogen and phosphorus compounds [11,12]. From an environmental perspective, the concentrations of phosphate, nitrate and nitrite in water are crucial due to their role in eutrophication. They are important analytes for environmental, food and human health monitoring and thus their detection and quantification is essential [13]. The sensor implemented in this paper within the developed integrated system for water quality monitoring is a low-cost device that consists of a nitrate and nitrite analyzer based on a novel ion chromatography detection method [14].

Wastewater treatment is an important component in the water cycle, as it ensures that the environmental impact of human usage of water is significantly reduced. Wastewater treatment plants (WWTPs) use a series of treatment stages to clean up the contaminated water so that the treated effluent is safely discharged to inland water, estuaries and the sea. Wastewater treatment consists of several processes (physical, biological, and chemical) that aim to reduce nitrogen, phosphorous, organic matter, and suspended solids content [15]. The purpose of WQM is to support the control of these processes by accurately monitoring water parameters (e.g., nitrate, nitrite, phosphate, and pH) mainly in the influent and effluent of each WWTP. Specifically, WQM performs (i) the detection and quantification of these parameters in the influent wastewater that could affect the treatment processes, providing the plant operator with valuable information to foresee such effects, and (ii) the analytical control of the effluent to verify that the treated waters comply with the standards required

by the current regulations [16], ensuring the environmental sustainability of water. In the European context, environmental legislation requires improvements in water quality and effluent discharged to waterways due to the Water Framework Directive [17] and related Directives, e.g., the Urban Wastewater Treatment Directive [18] and the Nitrates Directive [19]. The need for compliance with these Directives has created a demand among Government Monitoring Agencies and legislative bodies throughout Europe for frequent monitoring, both temporally and spatially. Traditional WQM methods involve the manual collection of water samples at different locations, followed by laboratory analytical techniques in order to characterize the water quality. Such methods take a long time and are no longer considered efficient. Although these methodologies analyze physical, chemical, and biological agents, they have several drawbacks: (i) poor spatiotemporal coverage [20], (ii) they are labor intensive and high cost (labor, operation, and equipment), and (iii) the lack of near-real-time water quality information to enable critical decisions for public health and environment protection [21]. Therefore, there is a need for WQM systems that enable reliable performance of WWTPs through effective data management and the online near real-time monitoring capability. The WQM system presented in this work is tested in a wastewater treatment real scenario and reported results are compared with analytical techniques values.

In the recent years, the vision of the Internet of Things (IoT) [22] augmented with advances in software technologies, such as service-oriented architecture (SOA), software as a service (SaaS), cloud computing, and others, has stimulated the development of smart water quality monitoring systems (SWQMSs) [23,24]. These systems combine technologies and components from microsystems (miniaturized electric, mechanical, optical, and fluid devices) with knowledge, technology, and functionality from disciplines like biology, chemistry, nanosciences, and cognitive sciences. Fortunately, the use of IoT software platforms helps to overcome the challenges associated with the broad set of technologies, systems, and design principles of the IoT [25,26]. SWQMSs are a new generation of systems architecture (hardware, software, network technologies, and managed services) that provides near-real-time awareness based on inputs from machines, people, video streams, maps, news feeds, sensors, and more that integrate people, processes, and knowledge to enable collective awareness and decision making where devices can offer more advanced access to their functionality [27]. As such, event-based information can be acquired, and then processed on-device and in-network. This capability provides new ground for approaches that can be more dynamic and highly sophisticated and that can take advantage of the available context (readings of water quality parameters). For this reason, SWQMSs allow to optimize the performance of the WWTP in particular and the treatment system in general achieving a smart wastewater management. Wired SWQMSs are still the main approach to monitor the parameters in existing wastewater treatment plants. However, this type of system has the drawbacks of high cost, poor expansion capability and difficult maintenance due to inefficient operating environment [28]. In order to overcome these previously mentioned drawbacks, a cost-effective decentralized SWQMS is designed in this work, using a low-cost water quality monitoring device that is integrated in an IoT software platform and in a Wireless Sensor Network (WSN) [29].

Wireless Sensor Networks have proven to be a very effective technology for numerous environmental monitoring applications. WSNs currently enable the automatic monitoring of air pollution [30], noise pollution [31–33], forest fires [34], climatological conditions [35], and much more over wide areas, something previously impossible. The use of WSNs for WQM is particularly appealing due to the low cost of the sensor nodes and hence the cost-effectiveness of this solution. These simple and low-cost networks allow monitoring of processes remotely, in near-real-time and with minimal human intervention. Considerable research has been conducted to monitor water quality through the development of WSNs. Adu-Manu and Pule [36,37] study and analyze recent developments in the sensor devices, data acquisition procedures, communication and network architectures, and power management schemes of WSNs to maintain a long-lived operational SWQMSs. Adamo [38] presents a SWQMS that supports to strategic decisions concerning critical environment issues of the marine ecosystem by implementing an smart buoy prototype designed for in situ and in continuous space-time monitoring of water temperature, salinity/conductivity, turbidity, and chlorophyll-a concentration as biological indicators of water eutrophication. Jiang [39] developed a WSN based on ZigBee technology for online auto-monitoring of the water temperature and pH value of an artificial lake.

In the field of wastewater treatment, WSNs represent a promising technology because of their rapid deployment and their ability to acquire, process and transmit data at a number of distributed sampling points. The application of WSNs to WQM has opened up a new avenue of research towards the development of decentralized SWQMSs that evolve with the changing wastewater infrastructure to meet the water requirements of smart cities [40–42]. These decentralized SWQMSs (i) offer great potential for cost reduction, (ii) allow for precise matching of growing wastewater capacity requirements, (iii) take advantage of the relative homogeneity of wastewater streams at their point of origin, (iv) do not need large sewer systems nor require extensive networks for the distribution of treated water, and (v) present probability of failure significantly lower than that of failure of centralized system. The advent of WSNs allows the replacement of traditional WQM methods or the expansion of existing wired SWQMS. Tadokoro and Wang [43,44] describe the design of SWQMSs using wired and wireless technologies for online near-real-time supervisory, control, and data acquisition (SCADA) of wastewater treatment processes. The designs conceived support many functions directed at multiple wastewater treatment plants, such as decentralized control, centralized management, remote diagnosis and fault early warning. Regarding WSNs sensor nodes, there is research work focused on the design of devices to monitor diverse parameters. In this sense, the work presented by Geetha [24] is based on the single-chip TI CC3200 microcontroller to monitor pH, conductivity, water level and turbidity and upload them to the Ubidots cloud. Reference [45] is based on Arduino to monitor pH, conductivity and dissolved oxygen and upload them to the ThingSpeak cloud, whereas the work presented by Saravanan [46] is based on Arduino to monitor flow, temperature, color, and turbidity, and upload them to the SWQMS cloud server. However, the prototypes cited previously are far from the close-to-market stage.

This paper presents the integration to a WSN and a preliminary validation in a wastewater treatment plant scenario of a low-cost water quality monitoring device in the close-to-market stage. This device consists of a nitrate and nitrite analyzer based on a novel ion chromatography detection method. The analytical device is integrated using an Internet of Things software platform and tested under real conditions in a wastewater treatment plant scenario. By doing so, a decentralized SWQMS conceived and developed for wastewater quality monitoring and management is accomplished. This investigation is part of an ongoing research project, referred to as LIFE EcoSens Aquamonitrix [47], which aims to validate and optimize this solution to achieve a low-cost, fully automated in situ analyzer for environmental water monitoring ready to be launched in the market after the project.

The paper is structured as follows. After this introduction, Section 2 describes the analytical device, the IoT software platform, the developed SWQMS called the EcoSens Aquamonitrix System, and the methodology followed for the validation of the system implemented in a real wastewater treatment scenario. In Section 3, the features of the EcoSens Aquamonitrix System are shown and the results obtained from the experiments to validate the analytical device are discussed. Finally, Section 4 presents the general conclusions of this study and proposes future work.
