Design, automation and remote management of a water purification plant

This study presents a water purification plant that uses the waste cake from the process of oil extraction of Moringa oleifera seeds. The particularity of this purification plant is that it should be autonomous to work in isolated areas. To do so, the design counts on solar panels and batteries controlled by a Supervisory Control And Data Acquisition (SCADA) system. The main objective of this study is the design and automation of the purification power plant so it can be used either manually or remotely by means of a web server and a micro controller in charge of data collection and to proceed orders from and to the web platform. In pursue of a cost reduction, caused by the development and implementation of hardware and software, this project is conceived using open source systems. Additionally, the plant counts on an Energy Management System that should optimize the energy consumption of the control system and actuators. This system is designed in such a way that it can be used independently in isolated mode or connected to the grid in regions where local authority regulations allows the connection of energy storage systems to the grid.


Introduction
The access to drinkable water is considered a Human Right since 2010 by the United Nations General Assembly.In spite of the efforts and cooperation projects related to drinkable water and sanitation access, there are still 663 million people without access to drinkable water according to the World Health Organization [1].Therefore, the differences in quantity and quality of the water supply, especially in impoverished countries, supposes the main cause of diseases due to intestinal parasites, having a significant effect on infant population [2].
Additionally, due to regulations regarding the environmental impact in farming and stock breeding zones, agro industry should introduce water treatment systems to treat water before returning it to rivers or water basins to eliminate nitrates and fertilizers that are very pollutant [3].It is in these scenarios where the necessity to implement com-pact, portable and autonomous water treatment plants is stated.Due to the difficulties to reach these isolated water treatment plants in person, it is appreciated to install the capability to control and supervise remotely its functioning and working state.
There are multiple studies related to water treatment processes, such as the ones presented in the recent comparison done by Lopez-Grimau et al. [4] that shows how some studies consider the development of pilot plants to treat urban wastewater while other focus the attention on industrial wastewater.The novelty of the system presented in this study in comparison to other pilot water treatment plants is the possibility to be used in isolated locations without access to electricity.In fact, this study presents the working details of the pilot water treatment plant that presented better environmental results in a previous work [5].
Considering that the plant should work in isolated places, where human intervention is more difficult, the automation of the plant is justified.However, automation needs control.In this case, automation is done using a Supervisory Control And Data Acquisition (SCADA) sys-

M.M Rafique et al. / Desalination and Water Treatment
(2017) 1-8 2 tem that allows equally the control of the plant in a manual or a remote mode.
Nowadays, software to optimize water and energetic resources is used in a wide range of productive sectors [4].Particularly, in the sector of water purification automated plants, the control of water and energy consumption together with the monitoring and activation of actuators is done by SCADA [6].The SCADA plays an important role in the industrial communication in real time.These systems combine hardware and software such as the Main Terminal Unit (MTU), Remote Terminal Units (RTU), actuators, sensors and Human Machine Interfaces (HMI) [7].Moreover, SCADA systems can be designed and implemented in such a way that they can work either with expensive but function oriented private software or with low cost open source programming software [8].Generally, the automation takes advantage of Programmable Logic Controllers (PLC) [9] to run the supervision and control of sensors and actuators connected through an OCP server to communicate between them [10].
Being possibly installed in isolated locations, the presented prototype should be capable to work powered by distributed electricity generation systems for the cases where no electricity grid is in reach, increasing the cost of the solution.This paper also presents an interesting alternative of batteries to power the water treatment plant in such cases.
In summary, the proposed system stands out because it is compact, economic, energetically sustainable and reliability, so it allows the implementation of the water purification plant almost anywhere.

Methodology
The design of the plant has several requirements to follow: First, the plant should be compact; second, the plant should be inexpensive, reason why it uses free software; and third, the plant should be self-sufficient, so the energy consumption of all the control, sensors and actuators has to be measured to correctly dimension the amount of solar panels and the number of battery packs to store energy.
The presented water purification plant follows the basics of the Patent P201430600 that takes advantage of gravity to operate.This base plant is totally mechanical, using the difference in height and in volume of three containers (water to treat, dissolution and treatment or agitation containers) to dose the coagulants/flocculants by means of a Venturi tube and to proceed with the fast and slow agitation phases that are necessary to properly eliminate the solids in suspension and to disinfect [2] water.
This study uses a similar compact concept adding an automation system, which entails the need of electricity power.Electricity could be obtained by connecting the water treatment plant to the electricity grid, if available, or using electricity generation systems such as solar panels and lithium ion batteries, which is the case of the designed prototype presented in this study.Notice that the batteries used in this prototype come from a waste product, as they are taken from dismantled electric vehicles (EV).In fact, EV batteries are considered no longer useful for traction purposes when they have lost a 20% of its capacity [11].When this happens, these batteries are taken out from the car and they are normally recycled.In this case, though, it is considered that an 80% capacity is good enough to fulfill the power plant needs.By incorporating re-used EV batteries, the plant incorporates compact batteries as Li-ion batteries have higher energy density than all other battery types at the moment [12] and reduces the acquisition costs [13].
The resulting prototype is shown in Fig. 1, which has a tarpaulin to protect it from the rain (upper-right image).
Roughly, the system works as follows: In container number 1 (Fig. 1) the system stores the water to treat.In a preliminary stage, the tests were generally done mixing kaolin to drinkable water, but several synthetic waters where also satisfactorily tested.In the following container (2) there is a beater that shreds the M. oleifera waste cake to prepare the coagulant/flocculants mixing the M. oleifera with water that is dosed through a Venturi tube to the water to treat.The residual cake used comes from a process that presses M. oleifera seeds to obtain oil.The process to obtain oil is simple, using standard presses having holes in the lower part that allow the oil to flow while capturing the rests, although other possible continuous presses could be used [14].This residual cake may have big parts of seeds, in consequence, the prototype incorporates the aforementioned beater.
As it is visible in Fig. 1, this container counts with a mixer to prepare the coagulant based on the Moringa oleifera residual cake but it also has a 0.45 µm glass fiber filter.This is done in the central tanks, circled in orange in Fig. 1 with a dosage of coagulant of 100 mg/L for turbidities between 30 and 150 NTU.For better results, the system may incorporate sodium chloride (NaCl) 0.25 M to the M. oleifera coagulant in tank number 3. If another coagulant should be used, the system should inject the predefined dose of this other coagulant in this container.This mix is pumped (manually or electrically) into the elevated tank (number 5 in Fig. 1) where water follows the processes of fast (150 rpm) and slow (20 rpm) agitation for 10 and 30 min respectively.After that, there is 1 h resting period to facilitate the natural sedimentation.Containers 4 and 5 are dimensioned so the slow agitation is done naturally in the manual configuration thanks to the entrance at 90º of the tube that has a length of 1 m and a diameter of 20 cm.Treated water is stored in container 6.When purged, all containers send the residual mud to container 7. The purge operation is defined to be done once every 3 treatment batches.The different size and

M.M Rafique et al. / Desalination and Water Treatment (2017) 1-8 3
positioning of the containers respond to the possibility to use the plant in a manual or electrically powered mode.In this prototype plant there are two optional tanks, the first one contains water to treat and the last one (the one more to the left in Fig. 1) will accumulate slot.This process is better explained in the results section.
With the presented configuration, the prototype is able to work in totally isolated areas using the manual configuration (having no instant control of the purification quality).In electrically isolated areas the system could be powered by solar panels and a battery stack using wireless systems to remotely communicate with the system controller (such as the ones used in mobile phones).Finally, in locations where it can be connected to the electricity grid there is no need to install the solar panels and batteries.
The study continues with the implementation and programming of the SCADA that manages and controls the water purification plant.A representation of the piping and instrumentation diagram (P&ID) is visible in Fig. 2.This diagram shows how water is pumped and how it is transferred from one container to another by pipes and valves.Notice that the coagulant/flocculants, consisting in the residual cake of the process of oil extraction from M. oleifera seeds, is grinded and then mixed with water.To dose and program the agitation time and pauses so the purification and disinfection processes are done correctly, the system uses a table relating these parameters according to the degree of turbidity of the water to treat.
As shown in Fig. 2, the system counts on sixteen valves, three electric motors (one for the beater that shreds the residual cake, another to prepare the coagulant and the last one for the fast and slow agitation), five ultrasonic sensors to control the water level in the containers and one turbidity sensor (although another one is expected to be incorporated in the nearby future).
All these elements are also visible in Table 1 together with a description of their use and the PIN used in the Arduino Mega board (which is presented in the results section).All these variables are essential for the correct use of the purification plant under the remote mode.
The control of the water treatment plant counts on the low cost micro controller Atmega 2560, which is powerful enough and it is easy to integrate to SCADA systems following industrial communication protocols [15].Additionally, Atmega 2560 is an open source hardware installed in an Arduino Mega board.
For communications between the automated water treatment plant and user, the network counts on a master (web platform), in charge of the reception and sending of orders from and to the screen controller.As depicted in Fig. 3, the communication between these two devices can be done by LAN or WAN network using the Web sockets internet communication protocol detailed in the document RFC 6455 [16].
The control interface (HMI) and the data storage follow a LAMP (Linux Apache Mysql) architecture due to the collection of open source elements that it can combine to create all type of Web applications [17].In our case, the web server is Apache, the database is Mysql managed by Phpmyadmin and for the rest of control applications the system uses Java, due to a higher robustness, stability [18] and security in comparison to PHP [19].
The web platform is configured in a server on the TR5 building in the Terrassa Campus of the Universtitat Politècnica de Catalunya.All the aforementioned structure is implemented between this server and the water purification pilot plant installed in the rooftop of this same building.
Finally, the HMI interface design was done in the integrated development environment of Netbeans that is compatible with Java.Netbeans is a robust and user friendly

M.M Rafique et al. / Desalination and Water Treatment (2017) 1-8 5
environment that supports several program languages and web applications.
To dimension the electricity generation system, the study measured the consumption and power of the SCADA, sensors, motors and actuators of the water purification plant.For the energy storage, the study takes into account that the systems should be able to work for 2 d even though there is no sun in the cases where the plant is located in isolated places.However, being the actual implementation of the water treatment plant on the rooftop of the R5 building of the Terrassa Campus of the UPC, there is no need to install that amount of solar panels or storage capacity, as the treatment plant may take the energy from the electricity grid if necessary.In consequence, an energy management system (EMS) was specially designed to take the maximum profit of the use of energy.The fact that the prototype re-uses EV battery modules permitted a reduction in the costs and to provide an additional value to a waste from the automotive sector that still has an 80% of its initial capacity [20] The last part of the study presents a comparison of the raw and treated water characteristics to evaluate the efficiency of the proposed process based on previous works that studied the life cycle assessment of this methodology in Burkina Faso using two coagulants: the traditional aluminum sulfate (Al 2 (SO 4 ) 3 ) and M. oleifera.

Results
A representative scheme of the water treatment process including all the control and automation elements is visible in Fig. 4. As it can be appreciated, the minimized system counts on four tanks.Tank 1 and 2 are needed to shred the M. oleifera and to prepare the coagulant respectively.Then, by means of a Venturi tube, the coagulant/ flocculants is dosed naturally when water to treat passes through a transversal tube.This mix enters into the third tank, where the processes of fast and slow agitation (15 min for the fast agitation and 1 h in slow agitation mode) takes place.During this process, the coagulant/ flocculants catch the suspended solids that fall to the bottom of the tank by decantation.The fourth tank is conceived to store all treated and drinkable water.It can be also appreciated that there is a purgative system in all tanks to clean them.
The SCADA counts on an Arduino mega 2560 together with an Ethernet Wiznet W5100 board, which characteristics are presented in Table 2.

M.M Rafique et al. / Desalination and Water Treatment (2017) 1-8 6
Both boards were assembled to build the controller.These boards and the developed algorithm permit the control of all sensors and actuators of the system.The Ethernet board assigns to the Arduino card an IP direction and configures it with the protocol TCP-IP to allow remote access through an intranet or by internet.
All the other sensors in the treatment plant are described below: • Ultrasonic module HC-SR04: Precision distance 2-450 cm, measurement angle <15º and working voltage of 5 V • Turbidity meter: Analogic 0-5 V exit signal • End of movement: incorporated to the electro-valves.
Regarding the actuators, the system counts with: • Water pump Calpeda MMM 1/AE: Nominal power of 0.37 kW (0.5 HP) and a flow of 1-4.2 m 3 /h and a range of height of 16.3-22 m. • Electric beater Novital: Nominal power 0.72 kW, diameter 2.5, 4, 6 and 8 mm.• Mixer Rubimix9: Nominal power of 1.2 kW, two velocities: 620 rpm y 820 rpm.• Electro valves: Voltage 12 V DC and 1.8 A current.Some laboratory tests were performed to evaluate the automation system.In the first place the system was built substituting sensors by power regulators, LEDs and pushers as Fig. 5 (left) shows.This process was useful to validate the electric schema (Fig. 5

right).
Then, to validate and verify the program, all sensors and actuators where added one by one independently until it was clear that the system was able to control all of them correctly.More details of the plant are accessible in [21].Finally, tests where done in the definitive circuit and the whole device was installed to the prototype water treatment plant.
To design the HMI, a client, server and controller were defined.The controller receives the state values from sensors and actuators through the messages from the client (the purification plant in this case).The server sends HTML code to present results graphically and stores the operations in a database.
Communications through web socket between the server and the controller of the plant were verified prior to its final implementation.The system refreshes the parameters that rule the plant every one second.In fact, shorter refreshing periods entailed problems in the reception and sending of messages.Thus, as the water treatment process does not require fast responses, this delay in time response is acceptable.
In the actual implementation on the rooftop of the R5 building at the university, when the water treatment plant works on automatic mode, it is able to take the energy from the different power sources.These sources are: solar panels, 2 nd life EV batteries and the electricity grid that powers the entire building.The EMS choses the power source by calculating the best economic option taking into account the building and plant consumptions together with the electricity tariff, as graphically depicted in Fig. 6.
The water treatment plant is capable to treat 1000 l of water in about 2 h.Thus, the energy consumption of the plant, taking into account all the elements described and that it should work 16 h to produce 8000 l of drinkable water, is close to 11,178 kWh per day.
In such circumstances, considering the characteristics of the installed solar panels (210 W/m 2 ) and that it should be able to work for almost 2 days without any additional power supply in the case of being installed in isolated locations, the plant needs an extension of 40 m 2 of solar panels and a capacity of the battery to store near 22 kWh, which is almost the average of the actual battery capacity of commercial EV.
Finally, a summary of the raw and treated water characteristics presented in further detail in [23] is described to verify the goodness of the process.

M.M Rafique et al. / Desalination and Water Treatment (2017) 1-8 7
The dosage of coagulant applied was based on the studies carried out by Pritchard et al. [24] and by Bhuptawat et al. [25] multipurpose tree whose seeds contain a high quality edible oil (up to 40% by weight, which is comprised between 25 mg/L, 50 mg/L and 100 mg/L for turbidities within the range of 30 and 150 NTU.These studies demonstrated that concentrations of 100 mg/L reached a 95% of turbidity removal, which was the initial concentration selected to carry out the tests (Table 3).
As it is appreciable in Table 3, the lower concentrations of M. oleifera and alum did not comply with the international Standards.In consequence, to increase the effectiveness of M. oleifera as a natural coagulant, the addition of 0.25 M of sodium chloride (NaCl) increased the turbidity removal dramatically (going from 40 NTU to 3.3 NTU).In addition, it should be mentioned that the pH of water was not altered by M. oleifera, and its impact on conductivity is minimal, being still into the international standards [8].
Moreover, Fig. 7 compares the visual aspect of the raw water used in the tests against the treated water.As it can be observed, the process clearly improves the turbidity of the sample.The chemical analysis done afterwards confirmed the good response of the process.
As mentioned above, the capacity of M. oleifera as coagulant/flocculants is clearly boosted when mixing it with 0.025 M of sodium chloride (NaCl).
From the experience in developing this prototype, there are some aspects that should be considered for its future replicability.For example, the addition of an UPS (uninterrupted power supply) is recommended to avoid the loss of data or control of the plant in case of shutdown.Secondly, communication messages through web socket are limited to 120 characters, which is too low for some applications that might need auxiliary systems to avoid collapse and connection loses.

Conclusions
This study presents a remote control water purification plant that can work either in automated or manual mode.The plant uses the residual cake from the oil extraction process from M. oleifera seeds.This method provides and additional value to the waste from oil production process to treat water.
This study presents the SCADA structure, the elements of the plant and the HMI that allows the remote control of the water purification plant.Additionally, the system was designed to be autonomous, sustainable and compact.To do so, the project took advantage of solar panels and lithium ion batteries.In fact, these batteries come from old electric vehicles, when they are not useful for traction purposes.Therefore, this is another step of re-valorization of waste, in this case, from the automotive sector.
Thus, the final design, exploitation and maintenance costs are low.In the first place, the investment costs are low because most of the elements used where conceived to be inexpensive (containers, software, re-used batteries…).Secondly, because the system uses a waste product as the principal input material, not needing additional expenses for the plant to work.
The compact water treatment plant is able to treat 1000 L of water every 2 h, and it proved to give satisfactory results water treatment.

Fig. 1 .
Fig. 1.Image of the water purification prototype plant.

Fig. 2 .
Fig. 2. Piping and instrumentation diagram of the water purification plant.

Fig. 3 .
Fig. 3. Scheme of the network used for the communications between the user and the plant controller.

Fig. 4 .
Fig. 4. Screen shot of the web representation of the water treatment plant.

Table 1
Detail of the variables in the web platform, Pin used in the Arduino board and identification in the P&ID