An Internet of Things Based Platform for Real-Time Management of Energy Consumption in Water Resource Recovery Facilities

. The article describes the design of an Internet of Things based platform having as main objective the real-time management of energy consumption in water resource recovery facilities and their integration in a future demand side management environment. The monitoring of several electrical parameters, including energy consumption, is done via a dedicated energy meter, whose design is detailed in the article. The high level data communication from the energy meters to a central platform of the wastewater utility is done via the MQTT protocol. Within the water resource recovery facility, the access network is based either on Wi-Fi or LoRa, which are two enabling technologies for the Internet of Things. The meters are deployed in pilot demonstrators located in two water resource recovery facilities in Lisbon, Portugal.


Introduction
The Internet of Things (IoT) is the support for a large number of applications.Many of these applications are fundamental for implementing the concept of smart cities, namely in domains like e-health, smart buildings, transportation systems, energy grids and wastewater management.In this paper we focus into a smart wastewater management application, supported in an IoT infrastructure, having in view the real-time control of energy consumption in Water Resource Recovery Facilities (WRRF) of a Portuguese Wastewater Utility.
Energy is often the second-highest operating cost at WRRF after the labor cost; it can be above 50% of an utility´s total operating costs [1].The reason for this is that most of the processes that occur in WRRF require energy for their operation and are intensive energy consumers.Also, when the drainage system is not gravitational, energy is required for operating pumping stations.In Portugal, the Águas de Portugal (AdP) Group, which is the utility in charge of water distribution and wastewater treatment plants in Portugal, represents about 1.4% of the total electrical consumption of the country and the energy cost represents 60% of the operating costs of AdP.
On the other hand, nowadays, new challenges appear due to the limited water and nutrient resources, to the existence of the circular economy framework and to climate changes concerns associated with the fossil fuel consumption; additionally there is an increasing cost of energy for the utility.In this context, a new paradigm for the use of the domestic wastewater was created.Domestic wastewater is being looked more as a resource than a waste and the wastewater treatment plants now are known as WRRF, where it is possible to recover nutrients and water to achieve a more sustainable use of the wastewater energy potential, and become a driver for the circular economy [2].
Águas do Tejo Atlântico (AdTA), which is one of the companies of the AdP group, is in charge of the wastewater treatment in the Lisbon region and in the west region of Portugal.AdTA is a consortium member of the running European Union H2020 research project "Intelligent Grid Technologies for Renewables Integration and Interactive Consumer Participation Enabling Interoperable Market Solutions and Interconnected Stakeholders", which has the acronym INTEGRID.The main objectives of INTEGRID are to test the flexibility of electrical energy consumption for domestic and industrial consumers, to test energy storage systems and make forecasts of renewable energy production and consumption.The main role of AdTA in this project is to manage the flexibility of its internal processes in order to minimize the energy costs according to the market and to the requirements of the grid operators, leading to an optimization of the AdTA internal processes.
The AdTA focus on the flexibility of energy consumption and in the new challenges of turning a wastewater treatment plant into a WRRF is an important path towards its objective of achieving operational optimization and flexibility of processes.To optimize and make processes more flexible it is essential to know the performance of the processes.Thus, one of the variables to monitor is the energy consumption of the process or equipment.This paper is related with the specific work done for real-time monitoring of the electrical energy consumption in WRRF.It is being developed by AdTA, within the INTEGRID project, in collaboration with INOV, a Portuguese research institute.
The objective of this collaboration is to design and implement a low cost smart energy meter capable of being integrated in an Internet of Things (IoT) environment.The meter will periodically measure electrical energy consumption and several other electrical parameters, and will communicate those measurements to a central system and a database.The meter has a bi-directional communication with the central system, being allowed a remote control of the meter, namely for altering the configuration parameters.The meter is equipped with a state of the art communication technology compatible with the IoT communication protocols.Low cost for the meter is a must, as a large number of meters will be required for the complete universe of WRRF.Pilot demonstrators are being deployed in two WRRF in Lisbon, Portugal.The demonstrators have a total of 30 energy meters, and two different IoT communication technologies were chosen to be tested in the two pilots.Each of the pilots also follows an IoT deployment framework with respect, not only to the communication protocols, but also to the used platforms.
The article is organized as follows.In section 2 related work is reviewed, and in section 3 the communication architecture is presented.Section 4 deals with the meter structure.The pilot deployment is treated in section 5 and the last section concludes the paper.

Related Work
In the context of the ability to collect, transmit and process data, with a view to make the most of the collected information by transforming it into knowledge, there was a need at AdTA to implement systematic and integrated approaches, i.e., the implementation of decision support tools.Thus, the AQUASAFE platform was developed at AdTA [3], integrating data already existing in the company, in order to produce answers to the specific needs of the operation and management.The AQUASAFE platform is a structure that allows managing all the information flows necessary to obtain an adequate response in the context of the management problems (overflows, energy management, emergency response, etc.).The measured data, mainly from water flows, is imported in real-time and the models run periodically in the forecast mode in simulation scenarios chosen by the user.The AQUASAFE platform is in full use in AdTA nowadays.
With regard to energy use, energy systems are sensitive to energy consumption spikes and, therefore, measurements have to be taken, either to optimize energy generation and distribution or better to reduce or shift peak power demands.While there is plenty of experience in optimizing energy generation and distribution, it is the demand side management that is receiving increasing attention by research and industry [4].Thus far, there still exists a gap between energy consumption and costs since there is no generalized cost model describing current energy tariff structures to evaluate operating costs at WRRF [5].In most energy studies, the energy consumption is multiplied by an average energy price.However, operating costs significantly depend on the energy tariff structure applied.Different time-of-use and/or peak penalty charges may change the cost efficiency of a control solution completely [6].
For the first time, an application of a real energy pricing structure was applied to a calibrated model for evaluating operational strategies in two large WRRF, in the context of the Portuguese "SmartWater4Energy" project [7].The importance and need of mathematical modelling for energy optimization of specific energy costs at real WRRF processes was assessed.Time periods with potential for further optimization were identified, supporting a smart grid basis in terms of water and energy markets that respond to the demands [6].This work was developed in the AQUASAFE platform, where the different models and the data from different sensors (flow, energy consumption, dissolved oxygen concentration, NO3 concentration, etc) were included for calibrating and evaluating the models.However, in the AQUASAFE platform, the energy consumption measurements are done in an indirect way, through the SCADA system.
There is, however, a need to have accurate measurements on the energy consumption and other electrical parameters in real-time for all the WRRFs.Also, those measurements need to be communicated to a central platform with analytical capability, which allows extracting information from the data being measured.Based on the analytical studies performed at the platform it will be possible to devise a strategy for shifting peak loads and reducing energy consumption on the whole.These are the main reasons that originated the current developments described in this paper.
On what concerns the development of dedicated energy meters to measure several electrical parameters like current, voltage and power in real-time, and adapted for wireless sensor network communications, there is previous work already done for the smart grid environment [8] [9].In the present case, the energy meters will be different from those ones as they must have the following distinctive characteristics: i) to be adapted to the constraints of a WRRF deployment; ii) to measure the parameters required in WRRF; iii) to comply with the IoT communications paradigm and platform architecture, which is the state of the art for smart cities deployment; iv) to be low cost.

Communication Architecture
The basic design idea for the communication architecture is to consider each meter, and the respective equipment to which it is connected, as a "thing" in an IoT context and collect the information from all the "things" in a central platform of AdTA, where the data can be stored in a database and data analytics be performed.Secure communication is a must and for that purpose we have available the AdTA private communication network that provides a security guarantee for the wide area communication.
The first decision to be taken was concerned with the IoT communication protocol(s) to use.From the universe of IoT communication protocols [10], we have considered that Wi-Fi and LoRa are two appropriate standard communication technologies for use in this solution and, therefore, in the pilot demonstrators.Wi-Fi is a well -known technology, having low cost communication modules for the meters, a low cost Access Point (AP), and high data rates (Mbps).As low cost is a key objective, the choice of Wi-Fi as one of the candidate technologies looked promising.
LoRa was the second candidate technology selected for the tests.LoRa is the physical layer containing the wireless modulation utilized to create a long range communication link.The complete stack of protocols used over LoRa is known as LoRaWAN.Compared to Wi-Fi, LoRa is a higher cost technology, namely for the LoRaWAN gateway, and has lower data rates (Kbps).However, it enables a longer communication distance than Wi-Fi, which is very useful for the communication between some remote equipment in the WRRF and the LoRaWAN gateway.The decision for the pilot demonstrations was to test both technologies, Wi-Fi in one WRRF (Chelas WRRF) and LoRa in the second one (Beirolas WRRF).
As it is required to transmit the data from the meters to the Control Centre, we had to establish a communication architecture that allows a seamless and secure transmission.The chosen architecture is shown in Fig. 1 for the Wi-Fi access case.

Fig. 1. System communication architecture based on Wi-Fi access
There might be several Wi-Fi APs installed in a WRRF.The WRRF energy meters, from now on called AdP meters, are deployed at the different WRRF equipments, e.g., recirculating pumps, equalization pumps, ventilators, etc.The meters communicate to the nearest Wi-Fi AP, sending a message containing the meter identification, followed by the electrical measurements.The data is forwarded from the Wi-Fi AP to the Communication Server (CS) located at the Control Centre via the AdTA private communication network.The CS will upload the data into the database, by means of the SQL protocol.The users can access the data either via a direct connection to the database or indirectly through a Web server.
Fig. 2 shows a simplified protocol stack of the Wi-Fi based access network.A conventional TCP/IP stack of protocols is used over the Wi-Fi Medium Access Control (MAC) and Physical (PHY) layers.The Network server is implemented as one of the components of the CS in the Control Centre.The Wi-Fi AP converts Wi-Fi into Ethernet and communicates with the CS via the AdTA private wide area network.

Fig. 2. Protocol stack of the Wi-Fi based access network
For LoRa, the system communication architecture is similar to the one shown in Fig. 1, having as main difference the use of a LoRaWAN Gateway instead of the Wi-Fi AP.
Fig. 3 shows the protocol stack of LoRaWAN, which comprises 4 layers: RF layer, Physical layer, MAC layer and Application layer.The RF layer defines the radio frequency bands that could be used in LoRa, namely for Europe and USA.We adopted the 868 MHz band available for Industry, Scientific and Medical (ISM) applications in Europe.
The LoRa physical layer implements a derivative of the Chirp Spread Spectrum (CSS) scheme.CSS was first developed in 1951 at Bell Telephone Laboratories for the military radars.It aimed to offer the same efficiency in range, resolution and speed of acquisition, but without the high peak power of the traditional short pulse mechanism.The MAC layer defines 3 classes of end nodes, respectively Class A, B and C. In this project we use only Class A, since it is the most energy efficient and the only one that is mandatory.To achieve this high energy efficiency, the nodes in this class are 99% of the time not active (neither transmitting nor receiving) and are only ready to receive immediately after transmitting a message.The Application layer is related with the user application layer.
As LoRa is a communication technology dealing with many connected nodes, it needs a robust end-to-end security.LoRa achieves this by implementing security at two different levels: the first one at the network level and a second one at the application level.Network security ensures authenticity of the node in the network and application security ensures that the operator has not access to the end user's application data.The basic components of the LoRaWAN architecture are the following: nodes, gateways and network server.The nodes are the elements of the LoRa network where the sensing or control is undertaken.The gateway receives the data from the LoRa nodes and then transfers them into the backhaul system.The gateways are connected to the network server using standard IP connections.On this way the data communication uses a standard protocol, but any other communication network, either public or private, can be used.The LoRa network server manages the network, acting to eliminate duplicate packets, scheduling acknowledgements, and adapting data rates.The network server is also included in the CS, as it happened in the Wi-Fi solution.Fig. 4 shows a simplified protocol stack of the three components interconnected.The high level communication between the AdP meter and the CS (see Fig. 1) uses the Message Queuing Telemetry Transport (MQTT) protocol.MQTT is an IoT connectivity protocol.It was designed as a lightweight broker-based publish/subscribe messaging protocol, which is open, simple, lightweight and easy to implement.These characteristics make it ideal for use in constrained environments, for example, where the network has low bandwidth or is unreliable, as is the case of wireless sensor communications, or when run on an embedded device with limited processor or memory resources, as is the case of the AdP meters.
The AdP meter contains a MQTT client and the CS a MQTT Server or Broker.Periodically, e.g., every 5 minutes, the meter sends a MQTT Publish message to the MQTT Broker, located in the CS, with the following structure: Meter ID, Voltage, Current, Power, Power Factor, Energy, Service Time, Timestamp.For configuration of the different parameters in the AdP Meter the MQTT Server uses Subscribe messages with different topics, namely: Change of the measurement period, Change of the communication parameters (specific of Wi-Fi or LoRA), Set date/time, Set the initial value of the energy counter, Set current transformer ratio, Set Power Threshold (defines the power threshold to consider the equipment is in service), Set Meter mode (tri-phasic or 3 x mono-phasic).
In the MQTT architecture the elements that generate information are called Publishers and the elements that receive information are called Subscribers.The Publishers and Subscribers are interconnected through the MQTT Broker, as shown in Fig. 5.The CS transmits the received information to the database by using the Structured Query Language (SQL).In the CS a software module converts the received messages coming from the Wi-Fi or LoRa based meter to a SQL message and transmits it to the database.

4
The AdP Meter The AdP meter was designed to allow the monitoring, not only from energy consumption, but also of other electrical parameters like current, voltage, power and power factor.The AdP meter has the electrical interfaces shown in Fig. 6, and can be connected to a tri-phase electrical system.The Measurement module and the Processing and Communication module are galvanic isolated for user protection, namely for the antenna connector and antenna cable handling.This requires a dual power supply with one of them connected to the Measurement module and the other to the Processing and Communication module.The Galvanic Isolation module requires to be connected to both.The power, power factor, energy consumption and service time are calculated internally in the AdP meter from the voltage and current readings.They are transmitted to the CS, via MQTT protocol messages, using the following units for the different parameters: Voltage: 0.1 Volt, Current: 0.1 Ampere, Power: Watt, Power Factor: 0-100 (100 correspond to PF=1), Energy: 0.1 kWh (accumulated value), Service Time: minutes (accumulated value), Time Stamp: seconds.

Deployment
The meters are being tested in two large WRRF in the Lisbon area, named Chelas and Beirolas.Meters with the Wi-Fi module are installed in Chelas, while meters with the LoRa module are installed in Beirolas.The first objective is to test both communication technologies in order to make an evaluation of their strong and weak aspects, from the technical and economic points of view.The second objective is that AdTA is able to perform demand side management operations.By having the knowledge on the realtime energy consumption and on the values of other electrical parameters, in a demand management situation, AdTA will be able to shift loads in a controlled way so that the impact is minimized in the WRRF.The Chelas WRRF covers an area of around 37,500 m2 (250 m x 150 m) in a central area of Lisbon.Fig. 9 shows the plant of the Chelas WRRF where Pi signals the points where the meters equipped with Wi-Fi are located.There are two meters in each Pi.The meters are connected to different WRRF equipment, such as pumps and ventilators.The total number of Wi-Fi APs to be deployed depends on the result of the on-going communication tests.

Conclusion
An IoT based platform for real-time management of energy consumption in WRRF was presented.The developed work included the design and implementation of the adequate meters for measuring different electrical parameters (including energy consumption), the deployment of those meters in two WRRFs in the Lisbon area, the economical and performance analysis of two IoT communication protocols (Wi-Fi and LoRa) for access networks in the WRRF and the transmission of the data from either Wi-Fi APs or LoRa gateway to a central platform and database, where data analytics will be performed.The objective of the pilots is, in first place, to decide on the communication technology to be used, when a more extended deployment of the system is done for other WRRF.The second objective is to be able to do demand side management operations, having in view the shifting of loads from peak load situations so that a better balance of the energy consumption can be achieved.
This work has to do with the so-called smart wastewater management, which is an important component of the smart city concept.It is worthwhile noticing too, that the project uses IoT technologies and architecture, which makes it up to date with the status of communications and platforms in smart cities.The future work includes the running of the platforms, extraction of the meter data and performance of data analytics on those data, so that guidelines can be designed for the extension of the platform to other WRRF.

Fig. 4 .
Fig. 4. Protocol stack of the LoRa based access network

Fig. 7 .
Fig. 7. AdP meter prototype The AdP meter block diagram is shown in Fig. 8 and comprises four main modules: Measurement module, Processing and Communication module, Galvanic Isolation module and AC/DC dual power supply module.