A Plug and Play IoT Wi-Fi Smart Home System for Human Monitoring

The trend toward technology ubiquity in human life is constantly increasing and the same tendency is clear in all technologies aimed at human monitoring. In this framework, several smart home system architectures have been presented in literature, realized by combining sensors, home servers, and online platforms. In this paper, a new system architecture suitable for human monitoring based on Wi-Fi connectivity is introduced. The proposed solution lowers costs and implementation burden by using the Internet connection that leans on standard home modem-routers, already present normally in the homes, and reducing the need for range extenders thanks to the long range of the Wi-Fi signal. Since the main drawback of the Wi-Fi implementation is the high energy drain, low power design strategies have been considered to provide each battery-powered sensor with a lifetime suitable for a consumer application. Moreover, in order to consider the higher consumption arising in the case of the Wi-Fi/Internet connectivity loss, dedicated operating cycles have been introduced obtaining an energy savings of up to 91%. Performance was evaluated: in order to validate the use of the system as a hardware platform for behavioral services, an activity profile of a user for two months in a real context has been extracted.


Introduction
The concept of a Smart Home has evolved remarkably over the past few decades.Initially, the Smart Home coincided with Home Automation intended as technological solutions applied to the home environment to automatically manage some situations (e.g., open doors/curtains, control thermostat) and detect dangerous events (e.g., fire, flood), freeing the user from manual control [1].Now, the evolution of ICT (Information and Communication Technologies) has allowed for the addition of many advanced features to smart homes over time, extending the possible applications.Among the advancements, the monitoring of human activity in the home environment has particular importance.Modern systems exploit human monitoring mainly to improve the energy management of the building [2][3][4][5][6][7].However, data related to the users and how they live in their own home environment can find straightforward applications in health management, allowing for early detection of behavioral trends and anomalies possibly relevant to one's wellbeing [8][9][10][11][12][13][14].
To accomplish this task, some new devices have to be developed [15] aimed at considering the interaction of the user with the home environment (e.g., armchair sensors to monitor inactivity periods, toilet sensors, etc.).These devices must be able to send data over the Internet so that, once processed, they can be accessed by the various professionals involved, for example, medical doctors, caregivers, relatives, and the users themselves.
Applications based on such a system have been presented in past works.For example, an infrastructure based on a Passive InfraRed (PIR), bed and temperature sensors was reported in [16].In this case, data transmission was based on the X10 wireless protocol, and a home server was exploited to process data and to send analyses and alerts to a third person (i.e., the clinician) through emails.Another monitoring system based on temperature, pressure, PIR sensors, and actuators was described in [17].Sensors communicated with a local computer by means of a wireless ZigBee protocol.Data were processed to monitor the activities of elders, and the results determined which actions were taken.The system proposed in [18] leans on a mix of ZigBee and Power Line Communication (PLC) transmission protocols.The architecture was conceived with distinct ZigBee Wireless Sensor Networks (WSNs) in each room, which communicate with a central management station through a PLC.An infrastructure exploiting a custom wireless protocol, the so called Wellness protocol, was presented in [19].The implementation was based on temperature, pressure sensors, PIR sensors, a manual alert button, and actuators.Another example of such a system was CARDEA (Computer-Aided, Rule-based Domestic Environment Assistant), developed at the University of Parma and specifically aimed at behavioral analysis.Originally based on the Ethernet protocol [20,21], the system's strength is flexibility.It is conceived to integrate different kinds of sensors and to support smart interfaces [22,23], in order to tailor the system's functions to the specific users' needs.By supporting a wireless protocol (i.e., IEEE 802.15.4/ZigBee) as well, further kinds of devices were introduced; the most remarkable is the wearable sensor MuSA (MUltiSensor Assistant) [24][25][26][27], designed for user motion analysis (e.g., fall monitoring) and for localization and identification purposes [28,29].
Most of the systems presented in the literature based their connectivity on wireless protocols, typically ZigBee [30][31][32], due to the low cost and power consumption.Coupling the low power required by a ZigBee transmission with recent developments in the field of energy harvesting, it is now possible to develop battery-less Internet of Things (IoT) nodes [33,34].However, powering the ZigBee protocol tasks for prolonged periods of time (i.e., >10 s) with energy harvesters is not recommended [35].Some advanced functions (e.g., localization or identification [36]), useful in smart home systems conceived for the continuous monitoring of the individual and for behavioral analysis, can be prevented.Moreover, the disadvantage of the ZigBee approach is mainly the necessity of a completely new and dedicated infrastructure in each home in which the system is going to be deployed, since, typically, a network compliant with these standards is not already present.Furthermore, a gateway device has to be considered as an interface between the home protocol and the Ethernet, in addition to a number of range extenders due to the low range featured by ZigBee [37].
In this paper, we present a new home monitoring system entirely based on Wi-Fi connectivity, in a fashion strictly compliant with the Internet of Thing (IoT) paradigm.Sensors connect to the Internet through a standard Wi-Fi home router, which is quite often already present in the homes.Some manufacturers are already producing chips for routers which are able to support Wi-Fi, Bluetooth, and ZigBee protocols in parallel (e.g., Qualcomm QCA4020 and QCA4024 [38]).These solutions could simplify the adoption of multiple protocols in the near future, but do not eliminate the need for building a complete infrastructure for the ZigBee sensors and in particular for deploying range extenders in the environment.On the contrary, Wi-Fi features a much wider range than ZigBee, so that no (or fewer) network extenders are needed, simplifying the overall approach, lowering the costs, and making the whole system more scalable.These characteristics open the market to the system making it particularly attractive to consumers.This, of course, comes at the expense of increasing power consumption, which may harm battery lifetime.Therefore, we carefully designed sensor platforms for low-power operation.An extensive account for the exploited design methodologies is given in [39], where it is shown that the obtained battery lifetimes are suitable for practical exploitation.
Based on such preliminary studies, we developed a complete set of specific sensor prototypes, providing expressive information relevant to behavioral inference.In [16,[40][41][42] some examples on how the sensor data can be processed and elaborated to extract patterns in the behaviors of home occupants are given.The present work is an extension of a published conference paper [43] where a brief description of the sensors is given.Here, more details about the developed hardware are given, and the proposed system hardware infrastructure is validated.The sensors have been tested both in a laboratory and in a real home environment.Some measurements about the power consumption are presented.
Moreover, during the tests, the sensors' data were logged to carry out a possible activity profile of the users in order to test the system performance.It is worth stressing that the aim of this work is not to develop and demonstrate a new behavioral analysis method, but to present a new hardware architecture conceived to collect data usable by behavioral analysis models developed elsewhere [16,[40][41][42].These tests show the usability and convenience of data collected and demonstrate that it is possible to take advantage of the flexibility of the Wi-Fi platform while eliminating costs given by the need of additional hardware (i.e., home servers and routers, adopted in [13][14][15][16]).
The paper is organized in four sections.After an introduction, a detailed description of the Wi-Fi architecture is presented in Section 2. In Section 3, experimental results are discussed, then in Section 4, conclusions are drawn.

System Architecture
The general system architecture is sketched in Figure 1.It includes a set of sensing devices, a Wi-Fi router, and services installed on a cloud environment.We currently exploit the IBM Bluemix Watson IoT platform (IBM, Armonk, NY, USA).The system is open to third-party and new device addition.We plan to integrate both custom-designed and commercial Wi-Fi devices in a seamless fashion.
Electronics 2018, 7, x FOR PEER REVIEW 3 of 13 a laboratory and in a real home environment.Some measurements about the power consumption are presented.Moreover, during the tests, the sensors' data were logged to carry out a possible activity profile of the users in order to test the system performance.It is worth stressing that the aim of this work is not to develop and demonstrate a new behavioral analysis method, but to present a new hardware architecture conceived to collect data usable by behavioral analysis models developed elsewhere [16,[40][41][42].These tests show the usability and convenience of data collected and demonstrate that it is possible to take advantage of the flexibility of the Wi-Fi platform while eliminating costs given by the need of additional hardware (i.e., home servers and routers, adopted in [13][14][15][16]).
The paper is organized in four sections.After an introduction, a detailed description of the Wi-Fi architecture is presented in Section 2. In Section 3, experimental results are discussed, then in Section 4, conclusions are drawn.

System Architecture
The general system architecture is sketched in Figure 1.It includes a set of sensing devices, a Wi-Fi router, and services installed on a cloud environment.We currently exploit the IBM Bluemix Watson IoT platform (IBM, Armonk, NY, USA).The system is open to third-party and new device addition.We plan to integrate both custom-designed and commercial Wi-Fi devices in a seamless fashion.Here, we discuss the custom design of a subset of sensors specifically aimed at behavioral analysis.Based on outcomes of previous European projects in which the ZigBee version was exploited [44], we defined the following device list:  Armchair (or Bed) occupancy sensor, to monitor inactivity periods or sleep disorders;  Passive InfraRed (PIR), to monitor the movements inside the house;  Toilet sensor, to monitor the toilet accesses;  Magnetic contact, to detect door and windows opening/closing.The same device can be used to monitor interaction with other meaningful objects (e.g., a cupboard door, to monitor feeding habits, or the medicine cabinet, for monitoring compliance with therapy prescriptions).All sensors are directly and individually connected to the Internet through the Wi-Fi home router.The commissioning procedure is very simple and relies on the Wi-Fi Protected Setup (WPS) standard.No technical skill is required, so that consumers themselves could manage the installation procedure.Data are sent to the Watson IoT platform, inside the IBM Bluemix cloud services, via MQTT (Message Queue Telemetry Transport) protocol with a Quality of Service (QoS) equal to 2. This ensures the necessary reliability of the transmission process, since the protocol itself ensures that Here, we discuss the custom design of a subset of sensors specifically aimed at behavioral analysis.Based on outcomes of previous European projects in which the ZigBee version was exploited [44], we defined the following device list:

•
Armchair (or Bed) occupancy sensor, to monitor inactivity periods or sleep disorders; • Passive InfraRed (PIR), to monitor the movements inside the house; • Toilet sensor, to monitor the toilet accesses; • Magnetic contact, to detect door and windows opening/closing.The same device can be used to monitor interaction with other meaningful objects (e.g., a cupboard door, to monitor feeding habits, or the medicine cabinet, for monitoring compliance with therapy prescriptions).
All sensors are directly and individually connected to the Internet through the Wi-Fi home router.The commissioning procedure is very simple and relies on the Wi-Fi Protected Setup (WPS) standard.No technical skill is required, so that consumers themselves could manage the installation procedure.Data are sent to the Watson IoT platform, inside the IBM Bluemix cloud services, via MQTT (Message Queue Telemetry Transport) protocol with a Quality of Service (QoS) equal to 2. This ensures the necessary reliability of the transmission process, since the protocol itself ensures that the message is received by the broker once and once only.The payload of the message is a string in a JSON (JavaScript Object Notation) format, reporting the sensor status.The device firmware, nevertheless, is suitable for connecting to other platforms as well (e.g., Amazon AWS (Amazon Web Services) (Amazon, Seattle, WA, USA), Microsoft Azure (Microsoft, Redmond, WA, USA), Thingspeak (MathWorks, Natick, MA, USA), etc.).

Sensors Prototypes
A Wi-Fi certified system-on-chip (SoC) (CC3200, Texas Instruments, Dallas, TX, USA [45]) was chosen as the core of all sensors.It integrates an 80 MHz clock MCU (MicroController Unit) with a 32-bit architecture and a network processor (compliant with the IEEE 802.11b/g/n network radio protocol).
For prototyping purposes, commercial development boards were exploited as the motherboard for all the devices.By connecting the same motherboard to different sensing devices, different sensors were built, sharing the architecture, thus reducing development costs.The sensors are shown in Figure 2.
Electronics 2018, 7, x FOR PEER REVIEW 4 of 13 the message is received by the broker once and once only.The payload of the message is a string in a JSON (JavaScript Object Notation) format, reporting the sensor status.The device firmware, nevertheless, is suitable for connecting to other platforms as well (e.g., Amazon AWS (Amazon Web Services) (Amazon, Seattle, WA, USA), Microsoft Azure (Microsoft, Redmond, WA, USA), Thingspeak (MathWorks, Natick, MA, USA), etc.).

Sensors Prototypes
A Wi-Fi certified system-on-chip (SoC) (CC3200, Texas Instruments, Dallas, TX, USA [45]) was chosen as the core of all sensors.It integrates an 80 MHz clock MCU (MicroController Unit) with a 32-bit architecture and a network processor (compliant with the IEEE 802.11b/g/n network radio protocol).
For prototyping purposes, commercial development boards were exploited as the motherboard for all the devices.By connecting the same motherboard to different sensing devices, different sensors were built, sharing the architecture, thus reducing development costs.The sensors are shown in Figure 2. All the devices can be powered from an AC (Alternating Current) outlet (through a standard USB port).This possibility eliminates the need to control and replace the batteries.However, the sensors' position is very important to efficiently monitor the users' activities.This position has to be independent of where the outlets have been set up in the house, but, at the same time, it is necessary to avoid wires in the room or to modify the existing home electrical system.For this reason, the devices are also conceived for battery-powered operation.In order to preserve battery lifetime, careful management of the energy budget was implemented.In particular, simple sensors do not need to fully exploit the Wi-Fi data transmission rate, since a limited quantity of data have to be exchanged over time.So, taking advantage of such an overabundant data rate, sleep phases are introduced in the operating cycle.The devices alternate active (data processing and transmission) and sleep intervals.Among available low power modes of the MCU, the Low-Power Deep Sleep (LPDS) and the HIBERNATE modes were exploited.In LPDS mode, the MCU stops its main clock while the radio module is active and maintains the connection with the network.The device is more reactive to external interrupts and features low wake up times.In HIBERNATE mode, the radio section is also turned off.Hence, HIBERNATE is the most effective in power saving, but, when awakening from hibernation, the device needs to re-connect to the network.Wake up times are in the order of tens of seconds, so hibernation is convenient when the sleep time is long enough.In our previous study [39], it was shown that the overall power performance of LPDS mode is better than HIBERNATE whenever a large enough frequency of messages (higher than 150 message/day) is to be managed.Considering the fact that all the sensors need to send a keep-alive message (every 15 minutes, in the application at hand), hibernation turns out to be practical whenever only a few tens of actual "events" per day are expected to occur.Among the sensors presented in this first All the devices can be powered from an AC (Alternating Current) outlet (through a standard USB port).This possibility eliminates the need to control and replace the batteries.However, the sensors' position is very important to efficiently monitor the users' activities.This position has to be independent of where the outlets have been set up in the house, but, at the same time, it is necessary to avoid wires in the room or to modify the existing home electrical system.For this reason, the devices are also conceived for battery-powered operation.In order to preserve battery lifetime, careful management of the energy budget was implemented.In particular, simple sensors do not need to fully exploit the Wi-Fi data transmission rate, since a limited quantity of data have to be exchanged over time.So, taking advantage of such an overabundant data rate, sleep phases are introduced in the operating cycle.The devices alternate active (data processing and transmission) and sleep intervals.Among available low power modes of the MCU, the Low-Power Deep Sleep (LPDS) and the HIBERNATE modes were exploited.In LPDS mode, the MCU stops its main clock while the radio module is active and maintains the connection with the network.The device is more reactive to external interrupts and features low wake up times.In HIBERNATE mode, the radio section is also turned off.Hence, HIBERNATE is the most effective in power saving, but, when awakening from hibernation, the device needs to re-connect to the network.Wake up times are in the order of tens of seconds, so hibernation is convenient when the sleep time is long enough.In our previous study [39], it was shown that the overall power performance of LPDS mode is better than HIBERNATE whenever a large enough frequency of messages (higher than 150 message/day) is to be managed.Considering the fact that all the sensors need to send a keep-alive message (every 15 minutes, in the application at hand), hibernation turns out to be practical whenever only a few tens of actual "events" per day are expected to occur.Among the sensors presented in this first implementation of the Wi-Fi system, this characteristic may fit with Armchair/Bed sensors, Toilet sensors and the several uses of the Magnetic contact.On the other hand, LPDS mode may be a better fit for higher frequency events, as happens for the PIR sensor.Based on such general assumptions, in the following specific implementation, details are given for each device.

•
Armchair/Bed sensor: In [46], a characterization of three different chair sensor elements is presented: a strain gauge, a mechanical switch, and a vibration sensor.Highest detection accuracy is reported for the mechanical switch, but this kind of sensor is more difficult to integrate in an ordinary home chair/bed since it is not straightforward to cover the whole sitting area.For our application, the strain gauge seems the most indicated choice.Indeed, resistive pressure pads are being commercialized which can be placed under the bed mattress or over the chair seat.These pads have been selected as sensing elements.Resistance change is assessed through a simple voltage divider, which drives a binary threshold comparator.This, in turn, generates an interrupt to wake up the MCU.As mentioned, given the relatively low expected number of events, the HIBERNATE sleep mode is exploited during idle phases.

•
Toilet sensor: The sensing element is a distance/proximity sensor.The sensor purpose is to allow for counting toilet visits (which may be relevant to many medical conditions), distinguishing them from generic bathroom presence (due to washing, for instance), which could be assessed though a PIR sensor.A short-enough, personalized reading range is therefore needed to cope with the actual placement of the sensor itself.The device has a reading range from 10 cm to 150 cm.The analog reading is fed to a comparator, which generates an interrupt signal to the system core.
In our experiments, we found that calibrating the sensor threshold at 65 cm distance was effective in discriminating toilet actual usage from generic bathroom presence.The nature of this sensor should make it suitable to exploit the benefits of the HIBERNATE mode.However, due to the high current consumption of the sensing element during its on state, the system core needs to power it on only when a distance reading is needed, keeping it in the off state otherwise.In our tests, we found that a period of 3 seconds for power off followed by 0.5 s of power on gives the optimal system reactivity.Since the sensing element duty cycle is driven by the MCU, LPDS mode had to be adopted.

•
PIR sensor: the sensing device is a standard passive-infrared motion sensor.It requires a supply voltage in the range of 3.3-5 V.In order to allow the system to be powered by AA batteries (as a common feature of all devices), a boost DC-DC regulator (direct current to direct current power converter that steps up voltage) has been added.The device already has embedded converters and provides a digital output signal, which is used to wake up the system core whenever a movement is detected.To avoid communication overload, PIR data are filtered on board; only status changes are transmitted, besides keep-alive messages.In the envisaged scenario, however, this results in a number of daily messages exceeding the above-mentioned threshold, which makes the adoption of hibernation not suitable and makes the adoption of LPDS mode preferable.

Results and Discussion
To evaluate the system, field tests were performed for two months.
For standby battery-lifetime evaluation, a full set of sensors was installed in a laboratory environment.The power consumption depended on the frequency of the occurring interactions with the sensor events.To determine a figure that allows for the comparison between sensors, only power consumption caused by the keep-alive events sent every 15 minutes were considered.
In order to estimate the battery lifetime in a working condition similar to the real one, another full set of sensors was installed in a real home environment inhabited by a family.
The sensors were deployed accordingly to their purpose: • Armchair sensor: Sensor pad placed on a lunchroom chair.

•
Magnetic contact: On the bedroom door.

•
Toilet sensor: Inside the bathroom to sense toilet interactions.

•
PIR sensor: Inside the bedroom.
The performance of the whole system was investigated, manually registering the user-sensor interactions and comparing them with the events reported by the sensors themselves.
Test details and results are given in the following subsections.

Power Consumption Analysis
In a previous work [39], preliminary laboratory tests about the sensors' power consumption were carried out.In this paper, we report an actual characterization of the system.
In the tests shown in [39], we assumed that the connection to the Wi-Fi network and to the Internet were reasonably stable.In real operation, this is not always true, and in order to consider possible disruptions that a consumer may experience, two main issues were evaluated:

•
Sensor unable to connect to the Wi-Fi network: The system, after power on, is configured to search for the previously known network (through the WPS procedure) until connection succeeds; if the network connection is broken (e.g., because of a blackout), the device performs a reboot.
The system always experiences an energy-expensive boot-loop until the network is restored;

•
Sensor connected to the Wi-Fi network but without an active Internet access (e.g., because of Internet provider issues): This situation arises only after the previous condition is met.After power on, the device searches and connects to the known network; it tries to establish a connection with the online cloud.If the procedure fails (e.g., because the Internet connection is lost), a reboot is performed.The result is the same, with the system always in an energy-expensive boot-loop until the internet connection is restored.
To better understand the consequences of this behavior on the actual current consumption, each scenario was reproduced and current measurements were carried out using a digital oscilloscope with a bandwidth of 350 MHz, an ADC (Analog to Digital Converter) resolution of 12 bit, and a maximum sample rate of 1.25 GS/s.To measure the sensors current, a probe with a bandwidth of 50 MHz and a minimum sensitivity of 10 mA/div was exploited.
Results are shown in Figure 3.In Figure 3a, the device settles at an almost constant current absorption of 14.2 mA while waiting for the network connection, with an averaged 71.4 mA current while searching for a Wi-Fi connection.In Figure 3b, phases in which the system is not using the radio module (during reboot) with a 101 mA peak current absorption can be identified, as well as a 74.3 mA peak current when the Wi-Fi connection succeeded and tried to establish connection to the cloud.By the analysis of those data, a total mean current of 17.3 mA can be extracted for the first scenario, and a total mean current of 34.5 mA for the second one.This behavior can significantly degrade sensors' energy performance.To overcome this problem, and hence to extend battery lifetime, the device is forced to follow a duty-cycled sequence of searching and sleeping phases, as shown in Figure 4.
Electronics 2018, 7, x FOR PEER REVIEW 7 of 13 lifetime, the device is forced to follow a duty-cycled sequence of searching and sleeping phases, as shown in Figure 4.The device is allowed to check for the presence of the Wi-Fi network or the Internet connectivity for a maximum period of 10 s.After this time, if the task fails, the system enters in a HIBERNATE sleep mode for 60 s to save energy and preserve battery charge.After the sleeping phase, a new search phase begins.This behavior has been tested and compared with the standard one for the same scenarios.The new current measurements are shown in Figure 5.After a larger initial current peak needed by the device to boot up, some current peaks are experienced during the Wi-Fi/Internet check phase and they reach the minimum in the sleep phase.In this case, the total mean currents over the period are 7.3 mA in the first scenario and 3.1 mA in the second one.Due to the unpredictability of these situations, the advantage in terms of battery lifetime is not quantifiable; however, with this method, the system is able to reduce the energy consumption by 42% in the case of Wi-Fi network absence and by 91% in the case of Internet connectivity absence.Hence, this behavior has been adopted for all sensors, and the actual battery lifetime during real operation has been evaluated.
As stated before, the sensors' energy performance was evaluated in both laboratory and home environments.All sensors were powered with parallel-series of four AA LR6 alkaline batteries.In the laboratory test, due to the different activity profile expected in a public environment, we tested only the stand-by power consumption.The only signals sent were periodic (15 min) keep-alive messages.In the real home environment, instead, the sensors were stressed during the day by three different members of a family.
After two months of testing, only the toilet sensor ran out of battery: For the other sensors, the laboratory set shows a residual charge of about 46%, while in the home environment this value is lower at 34%.It is worth considering that the battery lifetime in a real home environment strongly depends on the actual interaction with the sensors (e.g., the Magnetic contact can be stressed by more than one user, affecting the expected daily events and the sensor energetic performance).Moreover, as expected, the toilet sensor has a higher energy consumption because of the usage of LPDS mode and due to the higher power consumption of the sensible element.For this reason, the toilet battery lifetime was 30 days.The device is allowed to check for the presence of the Wi-Fi network or the Internet connectivity for a maximum period of 10 s.After this time, if the task fails, the system enters in a HIBERNATE sleep mode for 60 s to save energy and preserve battery charge.After the sleeping phase, a new search phase begins.This behavior has been tested and compared with the standard one for the same scenarios.The new current measurements are shown in Figure 5.

Behavioral Tests and Results
By the analysis of those data, a total mean current of 17.3 mA can be extracted for the first scenario, and a total mean current of 34.5 mA for the second one.This behavior can significantly degrade sensors' energy performance.To overcome this problem, and hence to extend battery lifetime, the device is forced to follow a duty-cycled sequence of searching and sleeping phases, as shown in Figure 4.The device is allowed to check for the presence of the Wi-Fi network or the Internet connectivity for a maximum period of 10 s.After this time, if the task fails, the system enters in a HIBERNATE sleep mode for 60 s to save energy and preserve battery charge.After the sleeping phase, a new search phase begins.This behavior has been tested and compared with the standard one for the same scenarios.The new current measurements are shown in Figure 5.After a larger initial current peak needed by the device to boot up, some current peaks are experienced during the Wi-Fi/Internet check phase and they reach the minimum in the sleep phase.In this case, the total mean currents over the period are 7.3 mA in the first scenario and 3.1 mA in the second one.Due to the unpredictability of these situations, the advantage in terms of battery lifetime is not quantifiable; however, with this method, the system is able to reduce the energy consumption by 42% in the case of Wi-Fi network absence and by 91% in the case of Internet connectivity absence.Hence, this behavior has been adopted for all sensors, and the actual battery lifetime during real operation has been evaluated.
As stated before, the sensors' energy performance was evaluated in both laboratory and home environments.All sensors were powered with parallel-series of four AA LR6 alkaline batteries.In the laboratory test, due to the different activity profile expected in a public environment, we tested only the stand-by power consumption.The only signals sent were periodic (15 min) keep-alive messages.In the real home environment, instead, the sensors were stressed during the day by three different members of a family.
After two months of testing, only the toilet sensor ran out of battery: For the other sensors, the laboratory set shows a residual charge of about 46%, while in the home environment this value is lower at 34%.It is worth considering that the battery lifetime in a real home environment strongly depends on the actual interaction with the sensors (e.g., the Magnetic contact can be stressed by more than one user, affecting the expected daily events and the sensor energetic performance).Moreover, as expected, the toilet sensor has a higher energy consumption because of the usage of LPDS mode and due to the higher power consumption of the sensible element.For this reason, the toilet battery lifetime was 30 days.After a larger initial current peak needed by the device to boot up, some current peaks are experienced during the Wi-Fi/Internet check phase and they reach the minimum in the sleep phase.In this case, the total mean currents over the period are 7.3 mA in the first scenario and 3.1 mA in the second one.Due to the unpredictability of these situations, the advantage in terms of battery lifetime is not quantifiable; however, with this method, the system is able to reduce the energy consumption by 42% in the case of Wi-Fi network absence and by 91% in the case of Internet connectivity absence.Hence, this behavior has been adopted for all sensors, and the actual battery lifetime during real operation has been evaluated.
As stated before, the sensors' energy performance was evaluated in both laboratory and home environments.All sensors were powered with parallel-series of four AA LR6 alkaline batteries.In the laboratory test, due to the different activity profile expected in a public environment, we tested only the stand-by power consumption.The only signals sent were periodic (15 min) keep-alive messages.In the real home environment, instead, the sensors were stressed during the day by three different members of a family.
After two months of testing, only the toilet sensor ran out of battery: For the other sensors, the laboratory set shows a residual charge of about 46%, while in the home environment this value is lower at 34%.It is worth considering that the battery lifetime in a real home environment strongly depends on the actual interaction with the sensors (e.g., the Magnetic contact can be stressed by more than one user, affecting the expected daily events and the sensor energetic performance).Moreover, as expected, the toilet sensor has a higher energy consumption because of the usage of LPDS mode and due to the higher power consumption of the sensible element.For this reason, the toilet battery lifetime was 30 days.

Behavioral Tests and Results
To evaluate the system accuracy, sensitivity, and specificity, one user manually took note of his interactions with the sensors for two months.These data were compared with the events generated by the sensors and automatically collected into the cloud platform.This analysis could effectively be done, in our scenario, only with the chair sensor, in fact, data for the Magnetic contact, Toilet and PIR sensors cannot be univocally assigned to a specific person, in an environment populated by more than one end-user.To resolve this situation a user identification mechanism should be considered [36,47].
In the case of the chair sensor, a total of 218 events were detected as follows: 99 True Positives (TP), 109 True Negatives (TN), 0 False Positives (FP), and 10 False Negatives (FN).Then, the accuracy, sensitivity, and specificity were carried out [48]: where TP, TN, FP, and FN are defined as reported in Table 1.The results presented show that our sensor is definitely capable of providing occupancy information in a real context.In [46], the reported averaged accuracy for a resistive strain gauge was 94%.This value is compatible with our results.We can conclude that the performance of our sensors are attributable to the resistive pressure pad.Nowadays, the pressure pad is the best choice due to its commercial availability and because it does not require specialized installation.Better performance could be obtained by replacing the sensing element, without affecting the system architecture.Some elaborations on the data acquired from all the sensors has been performed to demonstrate the possibility of identifying patterns in the user's activity.For each sensor, two different cases have been considered:

•
Daily activity: the distribution of the user-sensor interactions during a 24 h period was analyzed.
In Figures 6a, 7a, 8a and 9a the probability of an event in a certain hour of the day is plotted.
Values were obtained through the analysis of the activity per hour of every test day.The relative probability v i was calculated with the equation where c i is the number of events that occurred in the hour, \ and N is the total number of events observed during the test.

•
Weekly activity: the interaction was assessed during a week, counting the events registered in different three-hour intervals in the same day of the week (Figures 6b-9b).Although the aim of this paper was not to present a complete behavioral analysis module, simple trend information might be extracted from the results, demonstrating data convenience.For instance, a high lunchroom chair interaction can be seen during meals; the door openings are concentrated during the weekend, when the user is usually not at work.This fact can be confirmed by the PIR weekly graphs, in which the activity distribution shows a higher presence starting from Friday.Although the aim of this paper was not to present a complete behavioral analysis module, simple trend information might be extracted from the results, demonstrating data convenience.For instance, a high lunchroom chair interaction can be seen during meals; the door openings are concentrated during the weekend, when the user is usually not at work.This fact can be confirmed by the PIR weekly graphs, in which the activity distribution shows a higher presence starting from Friday.Although the aim of this paper was not to present a complete behavioral analysis module, simple trend information might be extracted from the results, demonstrating data convenience.For instance, a high lunchroom chair interaction can be seen during meals; the door openings are concentrated during the weekend, when the user is usually not at work.This fact can be confirmed by the PIR weekly graphs, in which the activity distribution shows a higher presence starting from Friday.Although the aim of this paper was not to present a complete behavioral analysis module, simple trend information might be extracted from the results, demonstrating data convenience.For instance, a high lunchroom chair interaction can be seen during meals; the door openings are concentrated during the weekend, when the user is usually not at work.This fact can be confirmed by the PIR weekly graphs, in which the activity distribution shows a higher presence starting from Friday.Although the aim of this paper was not to present a complete behavioral analysis module, simple trend information might be extracted from the results, demonstrating data convenience.For instance, a high lunchroom chair interaction can be seen during meals; the door openings are concentrated during the weekend, when the user is usually not at work.This fact can be confirmed by the PIR weekly graphs, in which the activity distribution shows a higher presence starting from Friday.Looking at the Toilet sensor activity, a periodic usage can be seen around meal times and in the early morning after waking up.Moreover, as expected, no sensors recorded activities during nighttime, when the user is supposed to be sleep.

Conclusions
In this paper, a new Smart Home system architecture conceived for behavioral analysis and based on Wi-Fi connectivity has been presented.The aim is to present an alternative architecture compared to the more traditional ones based on protocols such as ZigBee.The ZigBee solutions are not typically already present in the home environment, and this causes some problems in the practical deployment, mainly due to the necessity of the set-up fo a new and complete network infrastructure for every system installation.
In the proposed architecture, the sensors are connected to the Internet through a standard Wi-Fi router, in an IoT compliant fashion, without the need to add a dedicated home gateway to ensure connectivity or the range extenders often needed when using other standard protocols.A complete set of new devices conceived to acquire data related to users' behaviors has been designed and developed.
Since the principal drawback of the Wi-Fi connectivity is the higher power consumption, low power design strategies have been considered and applied to demonstrate the possibility of using this architecture in the context of smart homes for behavioral monitoring.The whole system has been tested in a real environment to evaluate the feasibility of adopting it in a real situation.
For this study, two sets of sensors.composed of an Armchair sensor, a Magnetic contact, a Toilet sensor, and a PIR sensor, were run for two months.The first set was used to evaluate stand-by battery lifetime while the second one was placed in a real home environment, inhabited by a family, to evaluate real battery lifetime.After the two months of testing, only the Toilet sensor ran out of battery.For the other sensors, the laboratory set shows a residual charge of about 46%, while in the home environment this value was 34%.Furthermore, in some cases, the network could undergo connectivity issues; in these situations, dedicated operating cycles introduced, instead of the standard ones, to reduce the impact on the battery lifetime.This lead to a reduction in the current absorption of 42% in the case of Wi-Fi network absence and of 91% in the case of a lack of Internet connectivity.
Moreover, in order to validate the possibility of using this system as a hardware platform for behavioral services, we have extracted, from the set of sensors installed in the home environment, a possible activity profile of an occupant.A user was assigned to take note of each interaction with the sensors for two months to test the system performance.The accuracy, sensitivity, and specificity were evaluated for the chair sensor (whose interaction, in our environment, can definitely be attributable to a single person) resulting in 95%, 91%, and 100%, respectively.These results show that our sensor is definitely capable of providing occupancy information in a real context.
In conclusion, exploiting Wi-Fi as an infrastructure for smart home systems conceived for human monitoring is a possible alternative to other systems based on protocols such as ZigBee, due to the low cost and ease of installation and use.The power consumption does not affect the usability, and the performance is not influenced by the system architecture.

Figure 3 .
Figure 3. Current absorption measurements: (a) scenario with missing Wi-Fi network connection; (b) scenario with sensor connected to Wi-Fi but without internet access.

Figure 4 .
Figure 4. Working phases for both Wi-Fi and Internet absence scenarios.

Figure 5 .
Figure 5. Current absorption measurements of sensors running with the introduced sleep periods: (a) scenario with missing Wi-Fi network connection; (b) scenario with sensor connected to Wi-Fi but without internet access.

Figure 4 .
Figure 4. Working phases for both Wi-Fi and Internet absence scenarios.

Figure 4 .
Figure 4. Working phases for both Wi-Fi and Internet absence scenarios.

Figure 5 .
Figure 5. Current absorption measurements of sensors running with the introduced sleep periods: (a) scenario with missing Wi-Fi network connection; (b) scenario with sensor connected to Wi-Fi but without internet access.

Figure 5 .
Figure 5. Current absorption measurements of sensors running with the introduced sleep periods: (a) scenario with missing Wi-Fi network connection; (b) scenario with sensor connected to Wi-Fi but without internet access.

Figure 6 .
Figure 6.Armchair sensor activity during the day (a) and during the week (b).

Figure 7 .
Figure 7. Magnetic contact (door sensor) activity during the day (a) and during the week (b).

Figure 8 .
Figure 8. PIR sensor activity during the day (a) and during the week (b).

Figure 9 .
Figure 9. Toilet sensor activity during the day (a) and during the week (b).

Figure 6 .
Figure 6.Armchair sensor activity during the day (a) and during the week (b).

Figure 6 .Figure 7 .
Figure 6.Armchair sensor activity during the day (a) and during the week (b).

Figure 8 .
Figure 8. PIR sensor activity during the day (a) and during the week (b).

Figure 9 .
Figure 9. Toilet sensor activity during the day (a) and during the week (b).

Figure 7 .
Figure 7. Magnetic contact (door sensor) activity during the day (a) and during the week (b).

Figure 6 .
Figure 6.Armchair sensor activity during the day (a) and during the week (b).

Figure 7 .
Figure 7. Magnetic contact (door sensor) activity during the day (a) and during the week (b).

Figure 8 .
Figure 8. PIR sensor activity during the day (a) and during the week (b).

Figure 9 .
Figure 9. Toilet sensor activity during the day (a) and during the week (b).

Figure 8 .
Figure 8. PIR sensor activity during the day (a) and during the week (b).

Figure 6 .Figure 7 .Figure 8 .
Figure 6.Armchair sensor activity during the day (a) and during the week (b).

Figure 9 .
Figure 9. Toilet sensor activity during the day (a) and during the week (b).

Figure 9 .
Figure 9. Toilet sensor activity during the day (a) and during the week (b).

•
Magnetic Contact: The sensing element is a reed switch, coupled to a magnet.When the two components are close to each other, the switch opens.This configuration is particularly convenient when drawers/doors are supposed to stay closed most of the time.Since the reed switch is open when they are closed, the sensor drains no current while in this state.Interrupts are generated to signal both transitions (close to open, open to close).In this case, selection of sleep mode depends on the actual device function.If, for instance, applied to the home main door, the HIBERNATE mode seems to be more effective again.