2.4.1. Data Measurement Method
Figure 5 illustrates the indoor layout of the test environment, which covers an area of approximately 27.8 m
2. This prototype environment represents the researcher’s actual living space, where a DCU is installed on one of the walls. To establish a spatial coordinate system, the bottom-left corner of the room is defined as the origin (0, 0). The actual room dimensions are set to 532 cm × 527 cm based on real-world measurements. Three DCUs are installed on the left-side wall of the living room, positioned as follows:
DCU 1 (259, 250):
Mounted above the entrance connecting the living room to the bedroom.
DCU 2 (50, 250):
Installed above a tabletop, near the bottom-left corner.
DCU 3 (180, 95):
Serves as a vertical reference point for triangulation-based positioning.
Figure 5.
A prototype testing environment.
Figure 5.
A prototype testing environment.
These three DCUs continuously receive RSSI data from nearby BLE devices and transmit the collected data to the DCS for storage and analysis. Additionally, to simulate the subject’s location, a smart wristband is placed at the center of the test environment. Various behavioral scenarios are designed to collect environmental data for further analysis.
To ensure stability in BLE data collection, this study selected a wall with minimal environmental interference for the installation of three DCU devices. Two DCUs are mounted near the ceiling, responsible for horizontal positioning and detection. Another DCU is installed on the wall, serving as a vertical positioning reference point. Additionally, the ceiling-mounted DCUs can operate in coordination with other DCUs at the same height, further enhancing horizontal positioning accuracy. This setup enables more precise spatial analysis of the user’s position within the environment, as shown in
Figure 6.
After testing the installation positions of the DCU devices, it was found that placing them in corners tends to cause a dish antenna effect. This phenomenon occurs because signals reflect off surfaces such as walls and ceilings, increasing the number of reflections. As a result, the receiving end may detect multiple signal paths, leading to constructive or destructive interference. This interference affects signal interpretation, causing the receiver to misidentify the signal source direction, ultimately increasing distance estimation errors. Therefore, when installing DCU devices, they should not be placed in corners and must be kept at a distance of approximately 50 cm from walls or protruding interior structures to minimize signal interference caused by reflections. As shown in
Figure 7, the DCU installation method proposed in
Figure 6 was applied in the living room environment depicted in
Figure 5. The devices were installed on the wall marked with the “Well View” perspective for testing.
2.4.2. RSSI Data Collection Method
This study utilizes the ESP32 microcontroller as the DCU device for collecting BLE signals. The ESP32’s built-in antenna (PCB trace antenna), under its default output setting (typically 0 dBm), can achieve a maximum range of approximately 30 m in unobstructed conditions. However, in indoor environments, signal stability is often limited to a range of 5–10 m due to obstructions such as walls, furniture, and human bodies.
In Taiwan, the typical size of a household living room is generally under 30 m2, which falls within the ESP32’s allowable range for BLE signal measurement in indoor settings. To ensure the DCU device can effectively scan for the smartwatch, this study first conducted a signal attenuation test between the two devices. The test began at a distance of 100 cm and increased in 100 cm increments up to 1000 cm. At each measurement point, RSSI data was collected for 10 min.
Figure 8 illustrates the average RSSI performance of three devices (DCU 1, DCU 2, and DCU 3) at various distances, along with standard deviation error bars for each distance point to reflect signal stability. The x-axis represents the distance between the device and the signal source, while the y-axis shows the RSSI values (in dBm) after per-minute averaging and Kalman filtering. A lower RSSI value indicates a weaker signal.
The overall trend observed across the three DCUs aligns with the basic physical principle that “the greater the distance, the weaker the RSSI,” reflecting radio signal attenuation over distance. However, noticeable downward fluctuations in the RSSI curves appear at the 300 cm, 600 cm, and 900 cm points—significantly lower than neighboring points. These anomalies may be attributed to specific interferences such as multipath reflections, obstruction effects, or signal attenuation due to antenna orientation.
The error bars in the figure show the variability of RSSI at each distance. Longer bars indicate greater signal fluctuation and lower stability at that distance, whereas shorter bars suggest a more stable signal. Overall, while RSSI tends to decrease steadily over medium-to-long distances, the high variability and standard deviations at some points highlight the importance of accounting for environmental factors when performing wireless positioning or signal strength analysis.
Additionally, the results confirm that using ESP32 to scan BLE signals is reasonably stable within a 1000 cm range. Since distances beyond 1000 cm exceed the dimensions of the living room environment used in this study, such measurements are excluded from the analysis scope.
To analyze the user’s relative height, all three DCU devices must synchronously collect the RSSI signals transmitted by the smart wristband [
23]. In previous research settings, each DCU would immediately upload the received RSSI signal to the DCS upon detecting a BLE device. However, due to environmental interference and other factors, RSSI signal collection times could vary, leading to inconsistent time intervals between DCUs. This inconsistency results in a discrepancy in the amount of data collected across different devices. As shown in
Figure 9, even when data collection starts at the same initial time, the three DCUs exhibit significant differences in collected data volume, with some showing large discrepancies. If the data volume of a particular DCU device is significantly higher than that of other DCU devices, the decision tree tends to favor learning from this type of data during training. As a result, the model performs well in predicting data from the device with the largest data volume but performs poorly for DCU devices with lower data volumes. This phenomenon may affect subsequent filtering processes and reduce the accuracy of the machine learning model [
24].
The primary cause of this situation lies in the design of the BLE scanning functionality using the BLEScan class library compatible with ESP32. In this library, the default scan interval (setInterval) is set to 100 ms, and the scan window (setWindow) is set to 99 ms, which theoretically allows up to 10 scans per second. However, the actual number of scans can be reduced due to factors such as the broadcast interval of the smartwatch, the execution flow of the system design, and external environmental interference. In the current system workflow, once BLE scanning is initiated, the ESP32 performs up to approximately 20 scans within a 2 s period. During this process, it collects data only from devices with the specified BLE MAC address. If multiple data packets from the same device are detected within the 2 s window, only the most recent data is sent to the DCS (Data Collection Server), followed by a 1 s wait before the next scan cycle.
During the BLE signal reception process, environmental noise interference may cause the DCU device to enter an infinite loop, where the scanning process does not stop until the system crashes and restarts. This can lead to unexpected device failures and interruptions in data collection. To address the issue of potential software crashes in the DCU under certain conditions, this study incorporates an emergency stop command into the BLE signal detection process to prevent the device from entering an infinite loop. When the DCS receives a signal from the Microwave Motion Sensor Module, indicating that a person has entered a designated area, it sends an MQTT message to all DCU devices to initiate BLE signal detection. During the detection process, after each BLE scan activation, the system waits 5 s before sending the next detection command. Once all DCU devices successfully return RSSI data, the DCS sends another detection notification and resets the 5 s countdown timer for the next scanning cycle. This implementation ensures synchronized data collection, prevents system failures, and enhances the reliability of indoor positioning and behavior analysis.
If, after 5 s of detection activation, any of the three DCU devices fails to return data, the system will send a second detection notification. If, after the second detection notification, the system still does not receive responses from all DCU devices, the forced termination function will be activated, and the system will proceed to the next detection cycle.
To mitigate unexpected crashes of DCU devices, a search interruption command is integrated into the BLE detection workflow. Upon receiving an MQTT message instructing it to stop detection, the DCU device terminates all active processes, clears the temporary data storage array, and retransmits a detection notification. This mechanism ensures a proper system reset, restoring the device to a standby state where it awaits the next MQTT command to initiate BLE signal detection, as illustrated in
Figure 10. The firmware was developed using Arduino core (v1.8.19) for the ESP32 (v3.2.0, Espressif Systems, Shanghai, China) in combination with the ESP32 BLE Arduino library and PubSubClient MQTT library (v2.8).
2.4.3. Behavior Pattern Data Collection Method
To collect a large volume of stable data for specific postures and minimize anomalies caused by excessive environmental interference (such as human body obstruction or the difficulty of maintaining fixed actions while wearing a smartwatch), the measurement phase in this study avoids having users wear the smartwatch during data collection. Instead, alternative equipment is used to fix the smartwatch at designated reference points.
To simulate user postures in the measurement environment, smart wristbands are set up at different locations within the testing space. A telescopic selfie stick with standing functionality is used as a mounting stand to position the wristband, simulating the natural arm-hanging height when worn by a user.
The relative height thresholds for different postures are determined based on the average male height of 170 cm and are adjusted according to the typical hand positions when a user is lying on the floor, sitting on a sofa, or standing still. Considering that the accuracy of BLE signal positioning is generally around 1 to 5 m, achieving precision within 30 cm remains technically challenging with current devices and technology.
Therefore, the baseline is set at approximately 90 cm, representing the natural arm-hanging height when a user is standing and wearing a smart wristband. When sitting or reclining on a standard sofa, the hand position typically ranges from 50 to 60 cm, while lying flat on the floor places the hand height between 0 and 15 cm. Accordingly, the posture-related height thresholds are defined as 0 cm (lying down), 60 cm (sitting), and 90 cm (standing), as illustrated in
Figure 11.