Design of a Printed Circuit Board for Real-time Monitoring and Control of Pipeline’s Cathodic Protection System via IoT and a Cloud Platform

The integration of Internet of Things (IoT) and cloud-based cathodic protection (CP) systems is an innovative approach that can lead to improve pipeline protection from corrosion. Using a printed circuit board (PCB) to measure and control current and voltage makes it possible to monitor PC systems in real time. The web interface that is connected to the PCB circuit through IoT technology provides a platform for instant evaluation of the data obtained, thereby enabling early detection of potential problems. One of the key benefits of real-time monitoring is improved data management and security. The data obtained can be stored on a cloud server, making it easier to access and analyze. This eliminates the need for manual inspections, which can be time-consuming and error-prone. Additionally, real-time monitoring can reduce downtime, as problems can be detected and resolved quickly, preventing the need for lengthy manual inspections and maintenance. This innovative approach has tremendous potential for the future of pipeline protection and corrosion control. The developed PCB circuit features a mobile UART that provides program protection, and the interface can control multiple PCB cards and relays independently. The monitoring system can be updated without interrupting data acquisition. The use of open-source software, database hosting, and low-cost PCB development facilitates commercialization. This study could inspire new applications in asset management and monitoring.


INTRODUCTION 1
Pipelines are critical infrastructure that plays a vital role in the movement of energy and other essential products. They are durable and can withstand a variety of environmental conditions, but require regular maintenance and inspections to ensure their reliability and safety [1]. Corrosion is a natural process that occurs when metals react with the harsh environment, causing material loss and structural changes in the metal [2].
Corrosion is one of the biggest challenges facing pipelines because it weakens the pipeline material over time. To prevent corrosion, pipeline operators use coatings and protective materials, as well as CP systems that use electrical currents to prevent corrosion [3]. Another challenge is the potential for property damage to pipelines by external factors such as construction, natural disasters and human activities. To mitigate this risk, pipeline operators use a variety of measures, including the use of aerial and ground surveys, regular monitoring of construction activities in the vicinity of pipelines. In the oil industry, pipelines are often subjected to harsh conditions, including exposure to corrosive liquids and gases, high temperatures, and pressures. These conditions can increase the risk of corrosion and make it more challenging to protect the pipeline from corrosion. CP is often regarded as the most effective way of avoiding pipeline corrosion [1].
Corrosion properties of materials can significantly affect the durability and reliability of oil and gas systems, which can result in additional costs for companies to control corrosion [4].
Cloud computing and IoT are often combined to enhance modern technological applications. Cloud computing offers internet-based access to computer resources that are flexible, reliable, and decentralized, while IoT is a system of internet-connected devices that gather and send data. When these two technologies are utilized together, it is known as Cloud-IoT [5]. In this integration, the Cloud supplies the essential framework for storing, handling, and organizing IoT data, whereas IoT provides the devices and data.
Advanced communication and internet technologies, such as IoT [6], Cloud [7], Artificial Intelligence (AI) [ [15], surveillance [16] and smart cities [17]. In these applications, smart sensors are used to monitor, identify possible problems, anticipate incidents, and improve safety while using less energy.
This collection [18][19][20][21][22][23] includes articles on gas detection, management of air or water quality using sensors, and machine learning. These articles cover equipment configuration, sensor use, decision support systems, intelligent management of air/water quality and a dashboard for the water distribution network and provide real-time data.
The following papers, discussed in the literature, explore various emerging techniques and technologies for monitoring and control of CP systems in underground pipelines. These include the implementation of wireless sensors networks (WSN) [24], Cloud-based systems and real-time data analysis. These approaches involve the utilization of different processing units, PCBs, communication networks, and protocols. The integration of these solutions into databases and platforms.
Kodali and Soratkal [25] utilized message queuing telemetry transport (MQTT) in a prototype designed for remote monitoring and control using Wi-Fi. They established connections between sensors and actuators with ESP8266, leveraging a Cloud platform for data analysis and visualization. The system also integrated a customized graphical interface to improve user interaction. Mononen and Mattila [26] have proposed an affordable open-source supervisory control and data acquisition (SCADA) system that utilizes a microprocessor to process data and transmit it to the Cloud through the user datagram protocol (UDP) and an ethernet frame. Medrano et al. [27] developed an affordable SCADA system using IoT technology. The system connects field devices to remote terminal units using the transmission control protocol (TCP), internet protocol (IP) and is based on a NoSQL database. Kara et al. [28] propose the design and construction of linear wireless sensor networks (LWSN) for use in monitoring CP in exceedingly difficult areas. Li and Wang [29] developed a terminal device with an S3C2440A microprocessor and various sensors for parameter monitoring. It ensures secure remote data transmission and storage in the Cloud using a 4G DTU communication module and the TCP protocol.
A hybrid architecture was proposed by Singh et al. [30] to monitor oil pipelines by combining 2.4 GHzbased ZigBee, LoRa and Wi-Fi communications to overcome the problems of using one of these two architectures alone. Aba et al. [31] combined an Arduino and a Wi-Fi module, programmed and used them to produce a wireless communication device that communicates with the ThingSpeak IoT analytics platform. As mentioned by Puviarasi et al. [32], it is possible to ensure appropriate pressure in the pipelines through continuous monitoring via the ThingSpeak Cloud network. In the event of abnormal sensor readings, a GSM900A module connected to the Raspberry Pi sends an alert SMS to the workers. According to Priyanka et al. [33], the utilization of Wi-Fi IoT modules enables wireless interaction with Cloud servers through MQTT protocol and hypertext transfer protocol (HTTP). Additionally, the web Monitor platform facilitates realtime data analysis and control, enhancing the optimization of oil pipeline transportation management. Chavala et al. [34] proposed an architecture to monitor the management metrics of oil pipelines through the utilization of IoT and LoRa WAN network. They performed simulations using the OPNET simulator to assess the effectiveness of the suggested technology. Yas and Al Qassab [35] developed a monitoring system using an Arduino Mega microcontroller and the ESP-01 module, with real-time monitoring on the Blynk IoT platform.
Li et al. [36] have created a distributed mixed reality and IoT system for operating and maintaining an underground pipeline network. Overall, these papers highlight the potential of IoT technology in improving the efficiency and reliability of CP systems for underground pipelines, along with the requirement to persist in exploring and advancing in this field. The authors have proposed different frameworks and systems for monitor and control CP in a diverse manner.
The use 4G DTU communication, Wi-Fi, ZigBee and LoRa modules to communicate between devices. They integrate TCP/IP, MQTT, HTTP, UDP, and Ethernet frame to handle data processing and transmission to the Cloud platform. Additionally, they investigate various platforms such as the BLYNK IoT platform, the ThingSpeak IoT analytics platform, and connectivity options through the ThingSpeak Cloud network and LoRa WAN network, among others to communicate between devices and the Cloud networks. Furthermore, the research explores the choice of database, considering both MySQL, a relational database management system, and NoSQL options.
Our research introduces a cost-effective solution that effectively addresses the limitations encountered in commercial systems through the utilization of opensource hardware and software technologies.
Several references have explored the use of PCB in previous works [28][29][30][31]33]. It is important to mention that our contribution is unique in the following aspects, which sets it apart from other works: -In the design of our PCB, we have chosen a different hardware configuration than what is commonly used. Instead of combining an Arduino Nano V3 microcontroller and the Wi-Fi module (BOLT IoT) [33], we have opted to use a single component, the Wi-Fi ESP_12E module, which offers integrated Wi-Fi capabilities better suited for IoT applications.
-To enhance the hardware security of program access, we did not use the ESP8266-based NodeMCU development board as stated by Kodali and Soratkal [25], but rather an ESP_12E.
However, it should be noted that the ESP_12E does not have a direct method for power supply and program transfer. Additional circuits are required to provide a voltage of 3.3 V to power our microcontroller. The program transfer is done using a USB to UART TTL serial adapter. Once the transfer is complete, the adapter is disconnected and removed, ensuring a secure connection.
-The processing power of the Arduino Nano (ATmega328) is set at 16 MHz, which is suitable for general tasks, whereas the ESP-12E (ESP8266) operates at a higher frequency range of 80-160 MHz, thus providing enhanced processing capacity.
-To ensure connectivity, we established a wireless connection to the Cloud server using Wi-Fi.
-Furthermore, data is efficiently transmitted through the utilization of the HTTP protocol. We opted to store the database using MySQL. It is worth mentioning that we did not utilize any IoT platforms such as BLYNK IoT [35] platform or ThingSpeak IoT [31] in our work.
The goal of the proposed PCB is to provide a more affordable and reliable solution for monitoring and managing pipelines using open source based IoT technology. Additionally, there were no costs incurred in implementing the IoT technology and maintaining the Cloud server. We have implemented the hardware and software sections ourselves, from scratch; we made it without using any prepared tools or software. There are challenges related to security and connectivity due to the limitations in coverage, the requirement to operate with both 12V/5V DC voltages. To address the limitation of having only one analog input on the ESP_12, there is a need to develop multiple analog inputs capable of acquiring both voltage and current analog values.
Several sections make up the paper's structure. Section 2 discusses the strategies for protecting pipes against corrosion. The limitations of traditional pipeline monitoring methods are examined in section 3. hardware and software solutions to monitoring and control are detailed in section 4 along with a novel real-time monitoring system that makes use of Cloud networks. Section 5 presents the results of tests conducted to evaluate the effectiveness of the monitoring and control systems, as well as their respective methodologies. Finally, section 6 provides a conclusion based on the findings presented in the previous sections.

CATHODIC PROTECTION (CP)
CP is a technique that prevents metal corrosion by making the metal surface the cathode in an electrochemical cell. To do this, direct current is applied to the metal and connected to a more easily corroded metal (anode) that provides electrons. The flow of electrons from the anode to the cathode neutralizes the corrosion process and protects the metal. This method is often used to protect metal structures in contact with water, such as ships, pipelines, and offshore oil platforms. The two CP methods that can be used are: Sacrificial anode: involves using a metal with higher susceptibility to corrosion as the anode, physically connected to the metal to be protected.
Impressed current: involves an electrical current impressed onto the metal and a separate anode supplying electrons. and that's what we are going to use in our system.

THE LIMITS OF TRADITIONAL CP MONITORING
Traditional CP involves the need to regularly move technicians to take potential readings along pipelines using a multimeter. The measurements are recorded on checklists and sent to an engineer for analysis, processing and interpretation. However, this method can no longer be considered effective as the actions and information returned are not performed in real time, which does not allow for constant and effective monitoring. Consequently, it is necessary to upgrade this method of monitoring CP. Figure 1 shows the classic supervision.

A PROPOSED REAL-TIME MONITORING SOLUTION FOR CP
As a solution, an automatic monitoring system was proposed that eliminates the technician actor and the register as shown in Figure 2.
The system is made up of two major components: The transmitter is installed at each measuring point and functions as a voltmeter, sending the measured values to the supervisory station in real time.
The receiver, which is installed at the supervisory station, and can be software or a web application, receives the data and performs a variety of operations such as displaying potential values, plotting curves against time, storing all values in a database [37], and automatically notifying in the event of a danger. It will be able to control the biocide injection pump remotely.

1. The CP System With Cloud Networks Topology
We have proposed the Cloud networks as topology on this system according to the importance of the factors and priority in realization (minimum cost, reliability, short and easy to install, and accessible for remote control).
Each model will be connected to an internet modem through this topology, allowing each one to send its own data to the Cloud and display it in an interface.
Securing Cloud data by controlling user access and eligibility to restrict usage to authorized users only [38]. Figure 3 shows Topology through the Cloud.

2. Materials and Methods for Supervision
This section discusses a remote CP system that is capable of measuring current and voltage potential. To improve CP monitoring, we are developing a web page that displays sensor readings in a graphical format that can be accessed from anywhere in the world. The task is divided into two sections: hardware and software. Figure 4 shows the supervision process.

2. 1. Hardware section
In this part, we need the different circuits and electronic components to realize our PCB. The use of printed circuit boards in expensive switchboards can significantly reduce the cost of CP installations. Inexpensive and readily available sensors can provide reliable monitoring data at low cost.
The six most important blocks that make up our PCB are: 1. Wi-Fi module (ESP_12E) for make the connection between the web interface that transfers the measured data.  On the online, open-source Easy EDA platform, the PCB layout and design are completed, with proper component placement and high-quality wiring ensuring a 0% short-circuit rate. The result as PCB desigin is shown in Figure 5.
We worked with JLCPCB to create five printed circuit boards (PCBs), two of which were assembled with modules and components. The total cost for manufacturing and assembly was €116.99.
In practice, miniature PCBs with a Wi-Fi modem are used to integrate them into a Transformer-Rectifier Unit (TRU) to connect multiple remote measurement points. The TRU ensures a continuous supply of 24V DC between the anode and the pipeline weld for enhanced cathodic protection.
The power supply of our PCB is provided by a preregulator that delivers a voltage of 3.3V. Voltage and current sensors are connected to the PCBs using voltage dividers. The system is scalable, allowing for the connection of unlimited measurement points. Voltage data is securely transmitted via Wi-Fi to an IoT platform and the Cloud, enabling real-time analysis and adjustments to the rectifier as needed.
The IoT technology enables communication between the PCB and the web interface.

2. 2. Software Section
After finishing the design of our PCB, we began writing scripts in a variety of programming languages in order to get our system running in real time. Among these scripts we find: • C++ script We utilized the C++ programming language to develop a measuring device that enables the measurement of potential and transmission to the Cloud IoT through the HTTP POST communication protocol.
The analog-to-digital converter is used to convert the input value analog to voltage value. We used two resistors R1 and R2 are connected in series like a divider tension. in V applied as input to the two resistors and the output voltage out V is measured across R2. After numerical computation, we find: Means that : out V : is the potential measured by ESP_12E in pin 0 A , then we can say that : : is the potential can be provided to power the ESP_12E board.
In this case in V will be in bits but we need the equivalent in volts, the ESP 8266 receives potential values in bits from 0 to 1024 bits, therefore: • Server To ensure accessibility of the web interface from anywhere with an internet connection, we have created an account on a free server, "000webhost.com" which allows us to load our scripts (MySQL, PHP, HTML, and CSS support), as well as having the possibility of providing us with a local database.
• Database Creation We have set up a MySQL database on our server, with a storage capacity of 1 GB, meeting our specific needs. To ensure the system's accuracy and reliability, the measurement potential data (input) must be suitably stored in a dedicated table called TBO within the Cloud IoT environment.
• Creating an SQL table (TBO) We can create a table in the database using this SQL code.
• Communication We needed to establish a link between the PHP script and the database. A connexion script is shown in Figure 6.
• Display on the database Figure 6. A connexion script We have created a PHP script to receive the data from the PCB and send it to the TBO table.
• Web Interface After acquiring the data, we needed a script to convert the data into graphs and tables.
For this, we used HTML, CSS, and a free API called "Highchart" written in JavaScript. The cloud server's data is shown on the web interface in JSON format for organized transmission. The communication between the cloud and the web interface is facilitated by employing the respective API key, which plays a vital role in enabling seamless communication between the IoT device and the cloud, utilizing the HTTP protocol.

3. Materials and Methods Control Part
After measuring the current and voltage potentials, we need to control the impressed current biocides injection pump remotely in case of problems .
For this purpose, we have created another web interface to control the measuring points. The control process is shown in Figure 7.
• Database preparation In the same server we have created our database, username, password and SQL tables.
After the preparation of the database, we will create files responsible for the creation of the control interface. The following files: -Entering and accessing the database.
-Displaying the control buttons. -A CSS file to customize the appearance of the web page.
• Database insertion PHP scripts are used for storing and retrieving output states that are stored within a MySQL database. The store and retrieve output states are shown in Figure 8.
• Handling HTTP requests We will create a PHP script to receive incoming requests and interact with the MySQL database. PHP script to receive the requests is shown in Figure 9.    Figure 10. In the beginning, we will generate the output's name, its board ID, and the corresponding connection number.

TESTS AND RESULTS
To test the operation of our electronic board, we used the humidity and temperature sensor DHT11.

1. Supervision Part
We have connected the DHT11 to measure the temperature and humidity of the environment. Our graph in Figure 11 is available in the web site: https://pipimsi.000webhostapp.com/chart.php.

2. Control Part
A button has been created to control the relay which is a switch for controlling the injection pump. The relay control is shown in Figure 12.
The led on the relay lights up, which means that the relay is working and that the temperature has dropped. Figure 13 shows the relay correctly works by lighting the Led.
The proposed electronic board is ready to be installed in a classic cathodic protection station for corrosion protection. To be able to perform all measurements and control relays in real-time via IoT, the new system had to be connected to the pipeline and have access to WiFi. All this work allows us to design and evaluate our PCB. Depending on the number of sensors and actuators required, multiple cards can be connected. Further research in this field could consider the integration of advanced optimization algorithms into the proposed system to improve pipeline surveillance and decision-making. For instance, potential algorithms include machine learning [40], deep learning [41], Bayesian network (BN) [42,43], BN combined with genetic algorithm (GA) [44], GA, Particle Swarm Optimization (PSO) and Firefly Algorithm (FFA) metaheuristic optimization algorithms [45], multi-objective optimisation techniques [46], and adaptive intelligent systems [47].
Advanced optimization algorithms, including hybrid and metaheuristic heuristics, adaptive and self-adaptive algorithms, as well as island algorithms, have been widely employed to address complex decision-making issues. These algorithms have demonstrated their effectiveness in various domains such as online learning [48], planning [49], multi-objective optimization [50], transportation [51,52], medicine [53], data classification [54], and other relevant fields.

CONCLUSION
This paper has demonstrated the design and implementation of a stand-alone CP system for pipeline monitoring. The proposed system allows the acquisition of real-time data on voltage potential and current, which is crucial to protect pipelines from corrosion. The web interface provides realtime visualization of the measured data in the form of graphs, tables and also allows remote control of the relays for managing the biocide injection pump. However, there are improvements that can be made to this system such as using more reliable communication protocols and adding a memory card for data storage. Overall, this system has great potential for CP of pipelines and can be adapted for other similar applications.