## 3 PLC Production Line Signal and IoT Connection  
A smart factory is required to establish an internal ecosystem in which devices and applications are connected through standard protocols. Key applications, such as the manufacturing execution system (MES), enterprise resource planning (ERP), and product lifecycle management tools, should be integrated with each other. The PLC equipment core is integrated into the MES to adjust each step, as shown in Figure 2. Devices, such as handheld scanners, mobile phones, and tablets, should communicate with the applications in the workshop. This ensured a closed-loop information collection and control system.  
The PLC is an industrial-grade device. Therefore, it does not allow direct connection to the Internet, as it can only communicate with other devices through a special protocol developed by the PLC manufacturer. Furthermore, these protocols have limited functionality, and require specific additional knowledge and different software to be fully functional. The main purpose of this study is to recommend a simple, efficient, and low-cost technique to connect any type of PLC to the Internet, thereby moving data to high-performance servers where it can be processed quickly and easily. This adds a new dimension to data storage, processing, and interpretation as data moves from limited-resource devices such as PLCs to unlimited-capacity devices such as cloud servers. The device that plays a major role in the entire framework is the Raspberry PI, which helps to transfer data from the PLC to the cloud server by facilitating the conversion between the PLC and the server. The Raspberry PI establishes a connection with the PLC through the Modbus TCP. The main function of the Raspberry PI is to map data from the PLC and encapsulate it in a hypertext transfer protocol (HTTP) request that the server can handle. After the connection is established, the following steps are repeated for signal processing at specific time intervals.  
* Step 1: The PLC performs electromechanical integration through drivers and sensors to form the basic edge computing controller (edge layer) of the smart factory and stores parameters for electrical devices such as motor speed, current, operating temperature, machine operating status, and alarms in temporary storage in the memory.
* Step 2: Machine image recognition uses convolutional neural network (CNN) technology to detect the status of the unmanned factory, sends its information through the Raspberry PI fog computing controller (fog layer) conversion and uploads it to the cloud.
* Step 3: The Raspberry PI connects to the PLC through an analogue and digital signal converter, reads data from the I/O port of the PLC, and sends it to the server through an HTTP request.
* Step 4: Raspberry PI reads these values and wraps them into HTTP requests with a machine ID and timestamp before sending them to the cloud server. To obtain real-time information, the interval of the Raspberry PI loop is adjusted to 100 ms.
* Step 5: When the server receives a request from the Raspberry PI, it stores the received data, machine ID, and timestamp in a database. Authorised users can view the information collected in a secure network environment using an Internet-connected device.
* Step 6: The cloud controller was a dual-core MT7697 (using Cortex-M4 with a FPU Max frequency @192 MHz, with a UART/I2C/SPI/I2S/PWM/ADC/IrDA function. CNN technology passes a video signal, and a PLC intercept signal is used for terminal monitoring. A general view of the proposed system architecture is shown in Figure 2.