Smart factory is quickly becoming the new reality in the market, and every innovative manufacturer must embrace it to stay competitive. To achieve manufacturing innovation in smart factory, manufacturers will have to invest in improving and or utilizing Internet of Things (IoT) to enable real-time data on their processes and their condition – for example, machine state condition or quality problems. One of real-time data that we could gather from the factory is environmental data. Thus, in this study, we develop real-time prediction system based on random forest algorithm to detect the quality problem based on real-time environmental data. Lab data was used to evaluate the performance of the algorithm. In addition, other machine learning algorithms are also applied, and the comparison results are provided.