## 3 Materials and Methods
### System of Sensors Network
For example, recommendations for fluid consumption if the person gets up many times to go to the bathroom, decrease the amount of light in the sleeping area, close or open doors or windows according to the amount of noise, etc. Each day, the person receives recommendation messages based on the night immediately before via email or SMS. This can lead to a gradual improvement in sleeping habits. The sensor system is not invasive, and the person does not have to configure it constantly. The system has an intelligent energy algorithm incorporated according to the adaptation of the sensors and its continuous use in the different areas of the house. Figure 1: Real implementation of the sensor network. The algorithm described in Algorithm 1 is based on the operation of the sensor network in conjunction with the coordinator node. When the network is turned on, the coordinator sends packets to know the whole topology. Each node has a hierarchy, the measurement of its sensing parameter, RSSI value and LQI value (these last two related to the quality of the link). Each node takes the measurement of its parameter depending on the programmed _request-time_. The node differentiates its measurement based on the subtraction of the initial default value and the current value. If this difference value is greater than 50% of the default value of the steady-state measurement, the node increases its hierarchy. This means that the measurement is very changeable, and it is important to monitor the area constantly. So, if the node hierarchy is greater than 3, the LQI value is 50% greater than its typical value (in stable state), and the RSSI value is 50% greater than its typical value (in stable state), the node is activated in proactive mode. This means that it is essential to monitor the parameter every _request-time_ because its value is highly variable. Otherwise, the node goes into reactive mode, which reduces its energy consumption and only requests the sensed value when necessary, that is, on demand. In this way, the network has an adaptive behavior according to the home of each person. The node is the device that has or can have multiple sensors. Indeed, the RSSI and LQI values should not change in static nodes. However, this can be altered by other devices that the person activates one day or by environmental conditions. Furthermore, when these factors change, there are anomalous environmental conditions, precisely what we want to analyze to establish the recommendations. Therefore, the sensor system is the same for anyone, but the sensors' operation, energy consumption, and recommendations will be personalized to each home. Table 6 provides recommendations for sleeping better at home, grouped into three different categories: Group 1, Group 2, and Group 3. Each group contains a list of seven different recommendations aimed at helping individuals improve their sleep quality. Group 1 recommendations focus on creating a comfortable and relaxing sleep environment. This includes closing the window to block out noise, using a comfortable mattress and pillows, using a noise machine or earplugs to block out background noise, keeping the room at a cool temperature, using a humidifier to improve air quality, keeping the room dark and using black-out curtains, and avoiding caffeine and heavy meals before bedtime. All these recommendations are aimed at creating a sleep-conducive environment that is comfortable and free from distractions. Group 2 recommendations focus on relaxation and preparation for sleep. These recommendations include practicing relaxation techniques before bedtime, keeping a consistent sleep schedule, using a weighted blanket, trying aromatherapy with essential oils, keeping electronics out of the bedroom, using a white noise machine, and trying a sleep mask. All these recommendations are aimed at relaxing the body and mind and preparing them for sleep. Group 3 recommendations focus on developing good sleep habits, and include establishing a bedtime routine, exercising regularly but not close to bedtime, avoiding blue