## 2 Materials and Methods
### Compatibility Considerations in the Manufacturing Process  
The proposed IoT configuration supports distributed manufacturing with a custom-made sorting algorithm between cast defect-free and cast with defects categories. It also contributes to the global connectivity aims of Industry 4.0. Figure 3 shows the main stages of quality control in a cast manufacturing process, highlighting the specific roles of IoT devices at each stage. The process flow moves sequentially from Stage 1 to Stage 3, showcasing the progression of quality assurance from initial assessment to final verification and data logging. Figure 3 presents an exemplification device scenario, but a cast quality control process does not need to involve these devices specifically. The proposed study configuration for the cast manufacturing process in the Industry 4.0 context is outlined below:  
_Stage 1: Initial Quality Assessment--ESP32-CAM._ The process begins with an ESP32-CAM module at the initial quality assessment stage. This device captures images of casts immediately after the initial production step and sends these images to the ML model for analysis. Using AI-powered object detection, the ML service processes the images, identifies the cast quality criteria, and returns the identified category. The system determines if the cast meets initial quality standards based on these scores. If the NIA detects any issues, the  
Figure 3: Stages of IoT-enabled quality control in cast manufacturing. Figure 2: Global IoT-enabled cast manufacturing connectivity via Azure IoT Hub. ESP32-CAM sends an alert to Azure IoT Hub. In this scenario, once a defect is detected, the ESP32-CAM triggers an alert through the Azure IoT Hub, which notifies subsequent process stages. The communication between the ESP32-CAM and the IoT Hub is established using the MQTT protocol. _Stage 2: In-Process Monitoring and Adjustment--M5 Stack or Custom CastDevice._ An M5 Stack device is integrated for in-process monitoring and adjustment at a later production line stage only for the IoT infrastructure demonstration. The M5 Stack is a modular, IoT-compatible device beneficial for real-time data collection and feedback. In this stage, the M5 Stack continuously monitors specific parameters, such as the temperature or vibration of the machines involved in machining and finishing the casts. Connected to Azure IoT Hub, the M5 Stack device collects and transmits this operational data to the cloud in real-time. If the ESP32-CAM detected any issues earlier in the process, Azure IoT Hub can use the M5 Stack data to investigate further and identify root causes. For example, if a defect is detected that might be linked to overheating, Azure IoT Hub can instruct the M5 Stack to modify machine settings, like adjusting the temperature. A Custom CastDevice tracks more specialized metrics. In the process, additional data are provided to increase the precision of adjustments. This behavior is specific to Industry 5.0 principles. Adjusting parameters resulting from a behavior in a real-time context is specific to Industry 5.0. The M5 Stack and any cast CastDevices create a responsive monitoring system within optimal ranges. The ensemble actively reduces the likelihood of defects and increases the quality of the cast product. In conceptualizing this stage, the M5 Stack or the Custom CastDevice is responsible for monitoring the in-process parameters of the machines involved in finishing the cast. The M5 Stack device collects these data through its sensors and transmits them to Azure IoT Hub. The software behind the M5 Stack includes real-time data collection routines, processing algorithms for parameter validation (e.g., threshold checks), and data transmission protocols like MQTT for continuous feedback to the cloud. Suppose a defect is detected in Stage 1 (e.g., a temperature-related issue that could affect the casting quality).