# Data-Driven Knowledge-Based System for Self-Measuring Activities of Daily Living in IoT-Based Test
## 4 Knowledge-Based Implementation
### IoT Sensor Devices and User Activity Recognition  
In this study, we developed the smart band and sensor boards for the terminal devices, including a faucet, toilet, pillbox, sphygmomanometer, coffee machine, microwave, gas oven, and an in/out detector. The sensor boards were attached to the terminal device. The smart band and some of the terminal devices are shown in Figure 11.  
Figure 11: Smart band and proximity-based neighbor identification protocol (PNIP) box. Figure 10: Timer service request in “C” Language Integrated Production System (CLIPS): (**a**) transition from Ready to Bath_Idle and (**b**) transition from Bath_Idle to Bath_Idle. All of the smart band and sensor boards run on Ubinos [37], which is an operating system designed and implemented to fit the ultra-small and ultra-low-power devices of ubiquitous computing networks. The wearable smart band communicates with the terminal devices via Bluetooth and a low frequency (LF), to announce its presence [38]. The proximity-based neighbor identification protocol (PNIP) box also has the Bluetooth Low Energy (BLE) and LF communication function. First of all, the PNIP box broadcasts a BLE advertising packet. The sensor gateway recognizes the PNIP box close to itself through the received signal strength indicator of the BLE advertising packet and registers it through the BLE connection. The Sensor Gateway delivers the current time information to the registered PNIP box. After that, the PNIP box stores the time information and delivers it, along with the user event results. Through this, the PNIP box stores user activity results with time information even if a network problem occurs. The PNIP box retransmits the stored result information when performing the reconnection procedure. Next, to recognize user activity events, the PNIP box and smart band use low-frequency communication. The low-frequency communication has high-transmittance and low-power characteristics. For this reason, it is possible to accurately recognize the communication distance by using the received signal strength indicator (RSSI) of the LF signal. When a user activity event is recognized through the PNIP box, the LF signal is transmitted to the surrounding area through the LF transmitter of the PNIP box. The smart band receiving the LF signal converts the RSSI value of the LF signal into a distance value, and the smart band transmits the converted distance value to the surrounding PNIP box through the Bluetooth advertising packet. The PNIP box recognizes the distance value of the smart band through the received BLE advertising packet. Through this, the PNIP box collects the user ID of the nearest smart band and estimates it as the user of the activity event. Finally, the PNIP box sends the user ID and activity event result to the Sensor Gateway to which it is registered. The PNIP box detects user activity events through various methods. The PNIP box basically has an external interface that can receive digital and analog signals. Equipment such as a coffee machine is connected to the external interface of the PNIP box through the button input of the coffee machine. Through this, the PNIP box receives the user button input of the coffee machine directly as an activity event. Like the in/out detector, user events can be recognized by the communication function of the PNIP box without additional connection. The in/out detector for detecting a user's movement event is installed on all doors, to detect the user's access [39]. The in/out detector was developed by a PNIP box with two LF transmitters. Each LF transmitter is installed inside and outside of a door and transmits the LF signal at a fixed interval. The smart band compares the RSSI of the two LF signals and recognizes the high side signal as its location. The smart band transmits this access information through BLE advertising packet. The PNIP box collects BLE advertising packets of this smart band. Through this, the PNIP box recognizes a change in the user's location information and sends an activity event to the sensor gateway.