# Anomaly Detection in Elderly Health Monitoring via IoT for Timely Interventions
## 2 Materials and Methods
### Proposed Embedded System  
The hardware prototype features the M5 Stack module as its central element. This represents a modular embedded solution that integrates processing, wireless communication, and energy management functionalities. This energy management method, which utilizes deep sleep and wake-up mechanisms triggered by events, is superior to all other  
Figure 1: Features for anomaly detection were examined through a custom-made analyzer. solutions proposed in the literature to date. This embedded solution enables the connection of multiple sensors, whose values are read at predetermined time intervals or when an event occurs, with minimal energy consumption. Furthermore, the real-time handling of data transmitted to the cloud infrastructure for detailed analysis and alert generation makes the M5 Stack a top choice for elderly monitoring solutions. Additionally, when the battery level drops below the 5% threshold, the person responsible for monitoring the elderly individual is notified to intervene and resolve the issue. This situation must be addressed when the elderly person neglects to recharge the bracelet. A heart rate bit sensor, MAX30100, is used for heart rate monitoring. This sensor emits light pulses, while the photodetector measures the variations in the intensity of light reflected by blood flow. For step counting (S), the prototype integrates an MPU-6050 module, which combines an accelerometer and a gyroscope. The accelerometer detects the characteristic movements of walking, and data processing algorithms convert this information into the number of steps. By correlating this data with heart rate data, the algorithms estimate energy consumption. Sleep quality is assessed based on the DST and SS. The values of these two parameters are determined through actigraphic analysis of the accelerometer data. Detecting periods of minimal movement enables differentiation between deep sleep phases and superficial sleep phases. Figure 2 presents the simplified logical schema of the embedded device. Each device has a unique identification code (ID). This code establishes the correlation between the monitored patient, the device, and the evolution of the six monitored parameters over time for that specific patient. The embedded device's algorithm initializes serial communication and Wi-Fi connection to transmit data to the central server. Subsequently, the two sensors are initialized and read the battery level. Heart rate measurements are collected over a defined interval in a continuous loop to determine the maximum, minimum, and average values. Afterward, the six monitored parameters are calculated. The M5 Stack receives and preprocesses data from all sensors. It forms a JSON payload with all necessary values, including the battery level information. Using the integrated Wi-Fi module, the M5 Stack sends the data via an HTTP POST to the ASP.NET API server, which collects the information for anomaly analysis. The system disables data reading until the condition is met again. During the entire period of system deactivation, it remains in power-saving mode. Exiting this mode occurs when a new reading is required or the battery is fully depleted. Figure 2 presents a simplified schema, as each parameter has different time conditions in reality. For example, heart rate monitoring is performed more frequently than sleep monitoring. The prototype proposed in this paper uses a Wi-Fi connection in this configuration to transmit data to the Azure infrastructure. For situations where the system is in a scenario where the Wi-Fi network is unavailable, the M5 Stack module has the option to use the cellular communication module with a Subscriber Identity Module (SIM) card. This technology is compatible with Long-Term Evolution (LTE) for Machines (LTE-M) or Narrowband IoT (NB-IoT). In this way, the collected data is transmitted to the cloud platform via the mobile network, eliminating the need for a local network.