1. Introduction
In traditional manufacturing environments, machine anomalies or production line status notifications often rely on manual inspections or a single monitoring system for recordkeeping. However, these methods suffer from delayed responses and insufficient information transmission, which results in untimely maintenance, thereby affecting production efficiency and line stability. With the advancement of Industry 4.0 [
1] and smart manufacturing, the demand for real-time monitoring, automated alerts, and comprehensive data preservation has increased, and traditional approaches can no longer meet the requirements of modern production lines for efficiency, transparency, and decision support.
To address this issue, we developed a real-time alert and data management system, using a filling machine production line as a case study. The system integrates programmable logic controllers (PLCs), RS-485 industrial communication, Structured Query Language (SQL) server, Message Queuing Telemetry Transport (MQTT), and the nodemation (n8n) automation platform, enabling real-time collection and storage of equipment status and production line data, ensuring all information is fully preserved for subsequent analysis and tracking. The system transmits data to n8n via MQTT to execute automated workflows and logic operations. When the PLC detects anomalies or sensor malfunctions, the data is immediately uploaded to the database via RS-485 and triggers communication software APIs through n8n’s rule-based operations, automatically sending alerts so that maintenance personnel can receive information and respond promptly.
The system architecture offers advantages such as low cost, rapid deployment, cross-platform integration, and high flexibility. It improves anomaly handling efficiency and information transparency, preserving complete historical records. The system assists the filling production line in achieving long-term stable monitoring, optimized scheduling, and intelligent management, further advancing enterprises toward the vision of smart manufacturing.
2. Materials and Methods
The real-time anomaly alert and data management system developed in this study uses a PLC as the core hardware control unit, capturing data via RS-485 and transmitting equipment status and production line parameters to the host computer. On the software side, SQL Server, the n8n automation platform, and communication software application programming interfaces are integrated to complete the full workflow from data storage and logical judgment to alert notification, as illustrated in
Figure 1.
2.1. Hardware
2.1.1. MITSUBISHI FX3U-64MR
The MITSUBISHI FX3U-64MR is a mid-range PLC, as shown in
Figure 2. It features 64 input and output (I/O) points, a program capacity of up to 64,000 steps, fast instruction processing, a built-in real-time clock, and support for various expansion modules. Consequently, it combines high-speed processing, modular expandability, and high reliability, making it particularly suitable for industrial automation applications that require medium-scale I/O, fast real-time control, and multifunctional expansion [
2,
3].
2.1.2. RS-485 to USB
The RS-485 to USB is an interface conversion device, as shown in
Figure 3, which converts differential signals from the RS-485 bus into USB signals, allowing a computer to communicate with RS-485 devices via a virtual COM port. It supports plug-and-play functionality and multiple baud rates, and is widely used in industrial automation, instrumentation, and PLC systems, facilitating easy installation and rapid integration [
3].
2.2. Software
2.2.1. SQL Server Management Studio
SQL Server Management Studio (version 20.2) is a database management tool provided by Microsoft, primarily used for managing and operating SQL Server. It offers a graphical interface and a query editor, allowing users to create, modify, and manage databases, tables, stored procedures, and user permissions. In this system, the database serves as a real-time data hub and historical record management platform, supporting automated alerts while also providing a basis for long-term analysis and decision-making.
2.2.2. n8n
n8n (version 1.30.0) is an open-source workflow automation platform that allows users to design, execute, and manage cross-system automated workflows visually. It supports integration with hundreds of services and applications, enabling tasks such as periodic data retrieval, conditional triggers, sending notifications, or updating databases. n8n also offers high scalability and customization, allowing enterprises to quickly build automated workflows at low cost, improving efficiency and the timeliness of data flow. In this architecture, n8n provides both real-time and historical data to support automated workflows and decision analysis [
4].
2.2.3. MQTT
MQTT (mosquitto 2.1.2) is a lightweight publish/subscribe communication protocol, characterized by low bandwidth consumption and real-time transmission, commonly used in IoT and industrial data exchange. In this study’s architecture, MQTT serves as an intermediary for data transmission, sending production line monitoring data in real time to the n8n platform for automated workflow control and anomaly alert notifications [
5].
During the data acquisition phase, communication programs were developed on the host computer using Python (version 3.11) and the open-source project fxplc, exchanging data with Mitsubishi FX series PLCs via the RS-485 interface. The system adopts an asynchronous communication architecture (asyncio) to ensure high performance and non-blocking operation. To ensure reliable data transmission, a complete frame structure was designed, including start and end markers and a checksum mechanism to automatically detect and correct transmission errors. The system supports reading and writing to PLC bit registers (e.g., S, X, Y, T, M) and data registers (e.g., D, C, T), and can force specific input/output bits on or off.
Additionally, an integrated data type conversion mechanism ensures correct reading and writing of various numeric formats, including integers and floating-point numbers. Through this architecture, PLC data is converted into structured byte streams in real time and transmitted to a database to support subsequent data analysis and decision-making. This approach provides high scalability and reusability, enabling automated process monitoring and data management, and offering a practical solution for smart manufacturing and Industry 4.0 applications.
3. Results
3.1. Production and Inspection Data of Filling Process
Figure 4 and
Table 1 show the operational status of the equipment during a single production cycle, including anomaly events, output quantities, and key process parameters (such as temperature and pressure), providing valuable support for subsequent production performance analysis and process quality studies.
3.2. Status Monitoring Record Table of the Filling Equipment
Figure 5 and
Table 2 show the operational status of each equipment during the production process, including power and mode information, fault conditions, and historical time-point changes. It provides accurate data for equipment utilization and fault tracking, serving as a reliable basis for subsequent production efficiency evaluation, anomaly analysis, and maintenance strategy planning.
3.3. Real-Time Monitoring Alerts
In the real-time monitoring and alert workflow, the system subscribes to status and production data published by the production line equipment via the MQTT protocol (
Figure 6). Once the data enters n8n, the system performs logic checks based on predefined conditions: if an anomaly is detected, the error record is immediately written to SQL Server and, after formatting, pushed to LINE to notify maintenance personnel for prompt action; if the data is normal, it is directly stored in the database for subsequent analysis.
As illustrated in
Figure 7, when the machine TEST17 experiences filling anomalies, shutdowns, or temperature irregularities, the system instantly pushes notifications to LINE with time stamps. This real-time alert mechanism significantly reduces response time, allowing maintenance personnel to quickly understand the situation and take appropriate measures, ensuring production line stability. Through this architecture combining MQTT, SQL Server, and n8n, not only is data collection and alert notification automated, but complete records of anomalies are also preserved.
3.4. User Interactive Query
In the user query process, the system uses the LINE Webhook as a human–machine interaction interface to receive query requests from maintenance personnel or managers (
Figure 8). The system accesses the SQL Server database to retrieve the production line table structure and relevant data, converting them into JSON format for subsequent processing. Next, the AI analyzes the user’s input and determines whether an actual database query needs to be executed. If a query request is detected, the system executes the corresponding SQL command to extract the required data, which is then formatted and semantically processed by the AI before being returned to the user via the LINE API, as illustrated in
Figure 9. If the input is a general question, the AI responds directly. This process reduces the complexity of data queries while enhancing the accessibility and timeliness of production line information.
In summary, the two processes complement each other: the former provides data querying and intelligent decision-support capabilities, while the latter enables real-time monitoring and anomaly alerting. Through the integration of MQTT, AI, and n8n, the framework proposed in this study achieves automation, flexibility, and scalability, effectively enhancing the management efficiency and stability of smart manufacturing environments.
4. Conclusions
We developed a real-time alerting and data management framework for traditional PLCs, integrating RS-485 data acquisition, Python-based host communication, MQTT middleware, SQL Server historical database, and n8n workflow automation. The system reliably collects production and sensor data, performs anomaly detection through threshold and historical comparisons, and automatically records events while sending real-time LINE alerts, significantly reducing maintenance response time and improving production line transparency. The implementation results verify that the system offers low cost, rapid deployment, and high flexibility, while preserving complete historical records to support trend analysis and report generation. Through the integration of MQTT and n8n, the system successfully achieves real-time monitoring, anomaly notification, and user-interactive querying in the filling line case study, thereby enhancing maintenance efficiency and reinforcing production stability.
The system developed in this study applies to a wide range of existing equipment environments, serving as a stepping stone toward the intelligent transformation of traditional production lines. Future work will focus on incorporating advanced AI models for predictive maintenance, root cause analysis, and automated task dispatching, as well as evaluating scalability and cybersecurity in large-scale multi-machine environments to further improve long-term operational efficiency and system reliability.
Author Contributions
Conceptualization, N.-Z.H. and P.-H.L.; methodology, P.-H.L.; software, H.-L.H.; validation, Y.-X.L. and C.-C.L.; formal analysis, Y.-T.H.; investigation, S.-C.J.; resources, P.-Y.C.; data curation, Q.-R.L.; writing—original draft preparation, P.-H.L.; writing—review and editing, N.-Z.H.; visualization, H.-L.H.; supervision, N.-Z.H.; project administration, N.-Z.H. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Informed consent was obtained from all subjects involved in the study.
Data Availability Statement
The original data are unavailable due to privacy or ethical restrictions.
Conflicts of Interest
The authors declare no conflict of interest.
References
- Lasi, H.; Fettke, P.; Kemper, H.G.; Feld, T.; Hoffmann, M. Industry 4.0. Bus. Inf. Syst. Eng. 2014, 6, 239–242. [Google Scholar] [CrossRef]
- Mitsubishi Electric Corporation. FX3U Series Programmable Controller User’s Manual; Mitsubishi Electric Corporation: Tokyo, Japan, 2015. [Google Scholar]
- Krystian, D. fxplc: Python Connector for Low-Level Mitsubishi PLC MELSEC FX Series (FX-232AW) Serial Protocol with Built-In HTTP Server. Available online: https://github.com/KrystianD/fxplc (accessed on 20 September 2025).
- n8n GmbH. n8n Documentation—Official Instructions and Tutorials. Available online: https://docs.n8n.io/ (accessed on 10 September 2025).
- Banks, A.; Briggs, E.; Borgendale, K.; Gupta, R. (Eds.) MQTT Version 5.0; OASIS Standard; OASIS Open: Woburn, MA, USA, 2019. [Google Scholar]
| Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |