RSSI-based Human Presence Detection System for Energy Saving Automation

WiFi facilitates computers and devices to connect with the Internet and each other using radio frequency signals that has Received Signal Strength Indicator or RSSI as its standard feature. With the use of RSSI value, a human presence detection technique to support energy saving by automating appliances is developed. It has attracted interest of researchers for its advantages like simplicity and low-cost. A system module that can detect the presence of human is achieved by designing and developing a device that utilizes off-the-shelves hardware, implementing a statistical analysis algorithm and by testing and evaluating the performance of the developed system in a real life environment. The result of the system module’s performance analysis in this research has shown 100% sensitivity, specificity and accuracy to the solution. The solution and approach can be used to support energy saving by automating appliances, resulting in a greener environment and a better financial efficiency.


Introduction
RSSI is an indication of the measurement for the strength of signal transmitted by an Access Point (AP) and is also the power level received by the receiver, therefore, it can be said that the stronger the signal, the higher the value of the RSSI [1].WiFi, which is also known professionally as Wireless Local Area Network (WLAN), is simply the term of trademark used by products belonging to a type of WLAN devices to brand it.This trademark belongs to WiFi Alliance.The technology of a wireless LAN in a computer network is known as WiFi or 802.11 networking.This technology allows electronic devices to communicate with a network by using 2.4 GHz or 5 GHz SHF ISM radio bands [2].These frequencies are considered to be greater than the frequencies used in cell phones, walkie-talkie or television.Essentially, 802.11 networking are based on radio wave signals that enable data transfers up to 70 meter (6Mbits/s of speed) in indoor environment [3].RSSI of the access point connected in a WiFi network can be harnessed and its pattern can be utilized for various purposes such as human presence detection.
Current solutions rely on the ICT protocols infrastructure itself instead of the radio frequency energy.For example, Bluetooth, ZigBee and WiFi solutions are readily available for use in presence detection and there are hundreds of manufacturers that make similar products.However, their solutions require specific costly hardware to operate and to interpret the commands coming on the protocol stream conveyed by the air interface.This requires operating expensive hardware dedicated solely for presence detection, hence, making the solution costly and prohibiting its widespread.The solution proposed in this research builds on the existing infrastructure available.It only harvests radio frequency energy available at the local setting and it can be implemented using simple and cheap electronic circuit and a microcontroller board.No protocol interpretation is needed, and hence it is not air interface-specific.It can target, for a start, university campus laboratories, staff offices and class rooms to control the automation process of lighting and air conditioning by sensing the presence and absence of humans.The result can reduce the amount to pay in monthly electricity bills and also security related damages.Therefore, the system is not limited to one industrial sector or application scenario which makes it highly competitive in the market.This research involves the development of a system module that integrates a WiFi module equipped with a built-in microcontroller with a relay that may be implemented for automation system.Even though there are various tools and techniques that can be used in human presence detection, this research focuses only based on  ISSN: 2089-3272 IJEEI Vol. 5, No. 4, December 2017 : 339 -350 340 RSSI readings of a WiFi access point without going into the other type of modules that may also produce radio frequency signals (i.e.Bluetooth).In addition, there are many factors that may affect and fluctuate RSSI readings, however, this research only focused on RSSI readings that is affected by human interferences.
Numerous researches have been conducted over the years in the area of RSSI-based human presence detection system.Several techniques are discussed and presented by other researchers which are reviewed in order to ensure a thorough understanding of work done in the similar area.Researches done on the available solutions and method to human presence detection system and the applications of it are focused and discussed.A novel method to detect the presence of human in a residential network that has a radio frequency energy is presented in [4].The researcher's method of detecting human presence is by utilizing radio irregularity phenomenon.Their hypothesis is confirmed that with the application of PCA analysis, to a set of RSSI samples read from same sensing scope and different smart outlets, human presence detection is made possible.To improve presence detection in a larger rooms, additional smart outlets are needed to ensure its propagation path's signal can be intersected by a human body.However, testing in another buildings made of different materials is yet to be done, since such testing would help to find patterns that can enable filter function defining which will result in the ability of distinguishing an occupied or unoccupied room especially when correlation occurs between the signal variations [4].
A project on the development of a physical intrusion detection system using WiFi ZigBee RF signals is conducted in [5].The approach presented by the researchers is by using RF signals from the RSSI of WiFi NIC and ZigBee motes as a base feed to their system testbed.This approach detects the presence of human in an indoor home or office environment.The approach is implemented as a controller that controls the switching of appliances or act as a reliable alarm for physical intrusion detection.However, the implementation of WiFi ZigBee RF signals in the system is in-situ where the physical detection is limited to the crossing of a distinct location or path [5].A new technique for proximity estimation called iBeacon is presented in [6].The technique is to establish an intelligent indoor presence detection system and is inspired by Apple Inc beacon device.At every certain interval, the beacon signal can be broadcasted.The researchers observe the path-loss readings from a collected data for line-of-sight situation and recognize the presence in the room.The accuracy is guaranteed from the data of other environments and situations such as the obstructed-line-of-sight and outdoor scenario.The system performance is deeply investigated in terms of error detection possibility based on empirical measurement results.The proposed applications of the system are such as security system, counting in and out and graduate seminar check-in.However, normalization of the hardware dependency to provide more robust location fingerprinting using RSS signatures is needed [6].

Research Method
The design and development of a WiFi RSSI based human presence detection system are achieved by developing and deploying a program for a WiFi module to harness and extract RSSI readings in an environment and process the values to determine switching ON/OFF of a circuit through a relay.WiFi RSSI feed information of an AP can be extracted by the WiFi Module.The proposed algorithm characterizes statistically the RF signal behavior in the office/home setting to determine if a human presence is detected.The RSSI feed is then used for the analysis with several statistical measures that can be combined to make an informed decision on the outcome of the human presence.The decision can be exploited in automation system that automates lighting, air conditioning, etc.
The entity relationship between the AP, System Module and the Electrical Appliances/Alarm System is illustrated in the block diagram as shown in figure 1. RSSI or received signal strength indication is the measurement for the strength of signal transmitted by the AP.RSSI of the AP is obtained by the WIFI Module.From the real-time characterization of the RSSI readings, WiFi module analyses the readings from the statistical profiling algorithm that has been programmed on it.The WiFi module then make appropriate decisions and trigger the activation signal of the relay circuit.The relay circuit then make the switching on or off depending on in which situation the system module is implemented on.

Hardware Requirement and Specification Analysis
There are four main hardware required for the system module: 1. USB to ESP8266-01 Adapter Module 2. WiFi Serial Transceiver Module ESP8266-01 3. 5VDC SPDT Relay 4. Voltage Regulators USB to ESP8266-01 adapter module is needed to flash the program codes from Arduino IDE to the ESP8266-01 WiFi module.There are many other ways an ESP8266-01 can be programmed.By using an adapter module and programming it using Arduino IDE, programming procedure can be simplified.ESP8266-01 WiFi module is proposed in the preliminary design of the system module prototype.ESP8266 is a low cost, high quality WiFi module with powerful on-board processing and storage capabilities.Although it comes in a very small size of 24.8mm by 14.3mm, this module offers a complete and self-contained WiFi networking solution all build in this single integrated chip.Its design allows it to either host an application or to offload all WiFi networking functions from another different application processor.Figure 2 shows the module its pins distribution and size measurement.This self-contained system on chip (SOC) is integrated with TCP/IP protocol stack that would allow access to WiFi network from any microcontroller used.Through its general-purpose input/output (GPIO) pins, the module were able to be integrated with sensors or any other application specific devices.Developed by Espressif Systems, ESP8266 is a low-cost, highly integrated chip with a complete and self-contained WiFi network solution that is integrated with TCP/IP protocol stack that allows any microcontroller to have access to the WiFi network.Among its capability are hosting an application or offloading all WiFi networking functions from another application processor.This WiFi module has an on-board processing and storage capability which enabling it to be integrated with sensors or many other application devices.It supports APSD for VoIP application and also Bluetooth co-existence interfaces.ESP8266 is also equipped with a self-calibrated RF.This feature allows it to work under all operating conditions and efficiently now requires no external RF parts [7].A relay is a device used in a circuit to open or close another circuit.It is electrically operated and activated by a current or signal.For the system module prototype, 5VDC SPDT relay module is used.SPDT stands for Single-Pole Double-Throw in which it has 5 terminals.There are several things that need consideration when selecting a relay.First, the power of what the circuit want to switch on and off and the second one is the power required to drive the relay.Therefore, for this research, the 240V Power relay are chosen for the switching of 240V mains powered appliances.Furthermore, 5.0V and 3.3V voltage regulators are needed for the system module.5.0V voltage regulator is used to supply a linear 5.0V voltage to the 5VDC SPDT relay and 3.3V voltage regulators to supply 3.3V to the ESP8266-01.The AMS1117 series of fixed and adjustable regulators are a good choice for its simplicity and protection against short circuit or thermal overloads.C3 is a 100µF capacitor (electrolytic capacitor) added to minimize reset inducing voltage fluctuations.7. D2 is a protection diode 1N4148 added parallel to the relay coil.8. Q1 is a general-purpose transistor BC548 in a common emitter configuration used as a switch to drive the relay.9. R1 is a 1.2kΩ transistor's base resistance as the switching signal from GPIO_0 is 3.3V.10.Whenever a human presence is detected by the WiFi Module ESP8266-01, the GPIO_0 output pin is set to High.The signal from GPIO_0 is fed to the base of transistor enabling it to conduct the current through its collector to emitter.When the transistor switch is closed, the relay coil is energized which then connects its Common (COM) terminal to its Normally Close (NC) terminal.The relay can then be used as a switch to any circuit connected to its COM and NC terminal.
The early prototype of the system module is shown in figure 4 (a).The system module that is equipped with AC-DC adapter module fits perfectly in a standard pattress box as shown in figure 4 (b).The pattress box is widely used in electrical appliances power wiring making it an ideal choice of enclosure for the system module.

The proposed algorithm of system module
The system module is controlled by an algorithm that is programmed into the ESP8266-01 WiFi Module through the USB to ESP8266-01 adapter module.The flowchart of the system module algorithm is as shown in figure 5 (a).The first step of the algorithm is determining the Access Point (AP).The system then continues to get the RSSI readings from the AP and continue to pre-processing step.The pre-processed RSSI readings then continue through the profiling technique to statistically distinguish whether there is human presence.If there is, then the system will set GPIO_0 pin of ESP8266_01 to high and trigger the relay to switch on, otherwise if there is no presence detected, the GPIO_0 pin is set to low and relay switches off the circuit.

Determining Access Point
The first flow of algorithm is on determining the Access Point as shown in figure 5 (b).The system starts by scanning the area for available networks.If there is no available networks, it will continue searching, if there is available network, it will extract the RSSI value of the scanned network and compare whether it is larger than the value of variable Max.Variable Max may be initially set to '-1000', this is because RSSI values are a negative integer.If RSSI value is larger than the variable Max, it will be the new Max value and if there is no other available network, the current scanned network will be the target SSID and chosen as the access point.From the test, the distance setting is at 1m but from the RSSI value, the distance is estimated at 3.98m.This proved that RSSI is noisy and fluctuative which is why pre-processing is needed.There are a lot of interferences and noises that may produce errors to RSSI values.In light of the research objective, such error is highly beneficial.The error is utilized in analysing human presence as the result of interference from human body and movements.To achieve the best solution, pre-processing plays an important role to smooth the high frequency sample of raw RSSI readings.There are many type of digital signal processing filters that can be used.However, the choice of digital signal processing filters has to be aligned with what the research want to achieve.In this research, the filter should not omit errors resulted from human interferences.Hence, two types of digital signal processing filters is discussed to show the consideration to be made when choosing a suitable filter.The first filter discussed is Kalman Filter and the second one is Moving Average Filter (MAF).
Kalman filter is an excellent pre-processing tool that significantly remove noises from raw RSSI readings.It is a recursive algorithm that takes the previous RSSI readings into account.RSSI reading is a static system, a regular Kalman filter that assumes linear models is sufficient.The equations for computing Kalman filter is defined as follows: Measurement update: Where The value of R in this research is determined from the standard deviation of a sample of RSSI values and Q is half of the value of R to reduce time lag.The value of Q and R are tweaked during an offline testing phase.The results of Kalman filter on RSSI readings is as shown in the graph in figure 7. It can be observed that although the noises have been exceptionally filtered, it is not satisfying for the objective of this research as the system is not responsive to errors caused by human interferences.Hence, it is not suitable to be implemented in this research.The implementation of the Moving Average Filter (MAF) as a pre-processing tool plays an important role to smooth the high frequency sample of raw RSSI readings.MAF is a simple low pass Finite Impulse Response (FIR) and is choosed in this research due to its simplicity and efficiency.MAF comes in handy to filter unwanted noise from the raw RSSI data.MAF works by taking n readings of RSSI and calculating its average to produce a single averaged reading of RSSI.The MAF equation is as follows: The larger the size of n, the smoother the graph can be where spikes are made blunt.The value of n is chosen by conducting an offline training phase for the system module to get the most suitable parameter.The result of MAF filtered RSSI readings is as shown in figure 8.The accuracy of filtered RSSI readings is indeed compromised, but error resulted from human interferences is still weighted on its value making it a suitable filter to be used in this research.

RSSI profiling technique
The RSSI profiling technique used in this research is the mean-variance deviation where the range of deviation for the mean and variance values is determined by taking two sets of n sample RSSI and calculating the difference between them.Algorithm of RSSI profiling technique is shown in figure 9.It starts with calibration phase done in a room without the presence of human.The calibration starts by obtaining n samples of RSSI readings.The raw RSSI is then smoothed using MAF.The mean and variance of the smoothed RSSI sample is calculated.The range of deviation for the mean and variance values is determined by taking two sets of n sample RSSI and calculating the difference between them.The system then continues to the main flow of presence detection by first getting the RSSI readings, smooth it, calculate mean and variance, and compare the mean and variance to the one obtain in calibration phase.From the statistically compared data, the system then distinguish whether there is human presence or not.If there is, then the system will set GPIO_0 pin of ESP8266_01 to high and trigger the relay to switch on depending on how the system module is implemented.

Results and Analysis
The system module prototype is tested for presence detection in an office room situated at crowded area surrounded by high number of WiFi APs.The performance analysis of the system module is determined by the following aspects: 1. Sensitivity (ability to detect presence): 2. Specificity (ability to detect only presence):  The performance analysis test has shown results of the statistical analysis done on the MAF filtered RSSI readings as shown in figure 10 and 11.The length of n for MAF chosen is 20.The value is chosen after conducting a training phase of the system module to get the most suitable parameters.During the system's calibration phase, the initial mean and variance of the sampled MAF filtered RSSI data is calculated.This is to initialized the value and range of mean and variance when the room is not occupied.So the next time a human enters the room, the mean will shift and variance will deviate from the initial calibrated value.The ranges of acceptable mean and variance deviations are determined during the calibration phase by taking two sample set of filtered RSSI data and calculating the difference between them.The differences are then multiplied to a factor that may tolerate the positive or negative deviations.The result of testing on 100 number of MAF filtered RSSI readings is as shown in table 2. The system module has a 100% sensitivity, 100% specificity and 100% accuracy.It can detect presence and only presence with a 100% precision.However, behind these very satisfying result lies a significant limitation.The system module can detect a presence only after obtaining 20 readings which take 2 seconds each, 40 seconds in total.Depending on the application and implementation of the system module, the time delay can be a big hindrance.For example, if the device is to be implemented to secure a perimeter and detect an intrusion, intruders may have 40 seconds before the intrusion can be detected.On the other hand, the device can be very useful to be implemented for energy saving in room or offices, where the appliances that

Conclusion
A system module prototype for human presence detection that relies on WiFi RSSI as its input parameters is developed in this research to support energy saving by automating appliances.The module consist of voltage supply, relay and most importantly the ESP8266-01 WiFi module.The ESP8266-01 has a built-in microcontroller which acts as the main brain of the system module.The system module works by harnessing readily available RSSI of WiFi Access Point as determined by the system.The best and ideal solution in terms of the hardware, software and statistical analysis used on the RSSI values to achieve the best outcomes while abiding the research requirements is a priority.In statistical analysis of the system module, the implementation of the Moving Average Filter as a pre-processing tool plays an important role to smooth the high frequency sample of raw RSSI readings.There are many other filters that can be used to smooth an array of sampled data or signal.However, MAF is chosen in this research due to its responsiveness to errors caused by human interferences.Furthermore, the Mean-Variance Deviation technique has resulted 100% in sensitivity, specificity and accuracy of human presence detection.In the future, an extensive research should be done to determine a method to reduce the time delay for human presence detection of the system module.

IJEEI 341 Figure 1 .
Figure 1.Block diagram of the system module's basic structure

Figure 3 .
Figure 3. Schematic diagram of system module The schematic diagram of the system module is shown in figure 3. The prototype consists of the hardware as stated in 2.1.The schematic diagram can be described as follows: 1. DC IN is the input DC voltage ideally ranged from 6.5V to 10V. 2. D1 is a 1N5400 general-purpose silicon rectifier diode.3. AMS1117 5.0 voltage regulator is used to supply a linear 5.0V voltage to the relay.4. AMS1117 3.3 voltage regulator is used to supply 3.3V to the ESP8266-01. 5. C1 and C2 are 22uF solid tantalum capacitors added to ensure stability for all operating conditions.AMS1117 voltage regulators require an output capacitor as part of the device frequency compensation.

Figure 4 .
(a) Early prototype of the system module (b) System module in pattress box enclosure

Figure 5 . 345 Figure 6 .
Figure 5. (a) Algorithm of system module (b) Algorithm on determining Access Point2.2.2 Pre-processing of RSSI readingsThe main challenge of this research is the analysis of RSSI values that gives the highest sensitivity, specificity and accuracy to human presence detection.RSSI is usually measured in dBm and it can be described in relation to distance from the Log-Distance pathloss model in equation 1[9]: = −10 log 10 (   0 ) +  0(1)Where,  ∶ Signal propagation exponent  ∶ Distance between transceiver and recipient  0 ∶ The referenced RSSI value at  0

Figure 7 .
Figure 7. Graph of raw RSSI and Kalman filtered RSSI over number of readings

IJEEI 347 Figure 8 .
Figure 8. Graph of raw RSSI and MAF filtered RSSI over number of readings 2.2.3 RSSI profiling techniqueThe RSSI profiling technique used in this research is the mean-variance deviation where the range of deviation for the mean and variance values is determined by taking two sets of n sample RSSI and calculating the difference between them.Algorithm of RSSI profiling technique is shown in figure9.It starts with calibration phase done in a room without the presence of human.The calibration starts by obtaining n samples of RSSI readings.The raw RSSI is then smoothed using MAF.The mean and variance of the smoothed RSSI sample is calculated.The range of deviation for the mean and variance values is determined by taking two sets of n sample RSSI and calculating the difference between them.The system then continues to the main flow of presence detection by first getting the RSSI readings, smooth it, calculate mean and variance, and compare the mean and variance to the one obtain in calibration phase.From the statistically compared data, the system then distinguish whether there is human presence or not.If there is, then the system will set GPIO_0 pin of ESP8266_01 to high and trigger the relay to switch on depending on how the system module is implemented.

4 .
Time taken per reading; 5. Time delay (time taken to detect changes).The performance parameters are described as follow:  True Positive (TP): human are present in room, and the system detects the presence;  False Positive (FP): human are absent in room, but the system detects a presence;  True Negative (TN): human are absent in room, and the system does not detects a presence;  False Negative (FN): human are present in room, but the system does not detects a presence. Number of sample taken, n = 20 RSSI readings.The readings of performance analysis' parameters are obtained and can be observed from Arduino serial monitor.The readings are taken during two condition, the first condition is during the absence of human as shown in figure 10 (a) and (b).The second condition is during the presence of human as shown in figure 11 (a) and (b).The result of performance analysis is as shown in table 2.
Human Presence Detection System for Energy… (Mohamed Habaebi) 349 (b) Figure 10.Test result in the absence of human (a) Initial readings (b) End readings (a) (b) Figure 11.Test result in the presence of human (a) Initial readings (b) End readingsTable 2. Performance of the system module


ISSN: 2089-3272 IJEEI Vol. 5, No. 4, December 2017 : 339 -350 350 are connected to the relay of the system module can be automatically turned off whenever humans are absence.

Table 1
shows the comparison analysis done on different WiFi Chips or modules specifications.