## 2 System Architecture
### Home Monitoring System  
The system monitors the surrounding environment using sensors and displays data in real time. The mobile app offers easy access to information regarding the environmental conditions inside the house. The app also offers remote functionality. The sensors obtain temperature, humidity, carbon dioxide sensor concentration, gas concentration, infrared light, and air quality data. End devices that can be remotely controlled include alarms, fans, and lights. The home monitoring system continuously accesses data stored in the database using the MQTT communication protocol. The database transmits data to end devices by using the MQTT messaging mechanism. Sensor data is transmitted to the monitoring system every minute. Figure 7 presents a schematic of the connections between the sensors, server, MongoDB database ([[https://www.mongodb.com/?mosckid=1](https://www.mongodb.com/?mosckid=1) cc7 ffd448c63a430]([https://www.mongodb.com/?mosckid=1](https://www.mongodb.com/?mosckid=1) cc7 ffd448c63a430) 77 dac1408c6866), and mobile app. The parallel processing method of the simultaneous multithreading sequence was adopted for writing the application program. When the program runs, users can use other functions without interrupting data transmission. The user interface can also be displayed normally without causing a system malfunction.  
The end devices in the proposed home monitoring system can be automatically turned on or off by comparing the received environmental data with the assigned threshold value. For example, a warning light can be activated on the mobile app to remind users that the recorded environmental data has reached the warning threshold value. Simultaneously, the monitoring system asks the user whether a particular end device should be turned on or off. Figure 8 presents a schematic of the connections between the mobile app and end devices. To control the end devices, the mobile app sends an action command to the server through the MQTT communication protocol; the server uses the hypertext transfer protocol to issue commands and remotely control the end devices [15]. The server can also automatically control the end devices or transmit the sensor data stored in the database to the mobile app to be displayed.  
Figure 6: LSTM model used in this study.  
As shown in Figure 8, the Node-RED programming tool was used to develop the app [16] and control the end device. This tool integrates IoT devices, user development interfaces, and network services, facilitating the establishment of a serial operation for data processing, storage, and transmission, as well as end device control. The Node-RED tool adopts a serial design to write multiple functions into a node, serializing them using the design concept of a flowchart to create a workflow for processing data, controlling equipment, or sending alarms. The nodes can be written using Node.js Design. The designed nodes with different functions can be easily added or removed through the Node-RED library. Figure 9 illustrates the designed program and debug message of the Node-RED programming tool.  
Figure 8: Schematic of connections between the app and end devices.  
Figure 7: Schematic of the connections between the sensors, MQTT protocol, MongoDB database, and mobile app.