Human body sensing method and system based on WiFi microcontroller
Technical Field
The invention relates to a human body sensing method and system based on a WiFi microcontroller.
Background
The detection of the number of people can be widely applied to safety monitoring and intrusion detection. The non-invasive person number detection does not need special equipment carried by the detected person, and the universality is stronger. In the current non-invasive people number detection, a scheme of estimating the number of people in a certain scene is widely applied by installing a camera and performing target detection on a camera picture by applying a computer vision method. The scheme can be integrated in the existing security monitoring system, but has the problem of privacy protection. The complex environment has blind areas under the influence of illumination conditions in the environment.
The use of radio for people detection is similar to radar, there is no privacy protection problem, and significant dedicated radio overhead can be avoided if people detection is performed using widely spread WiFi infrastructure. Traditional applications that make use of WiFi-aware environment features are mostly based on RSSI (Received Signal Strength Indicator, received signal strength indication). The intensity of the RSSI reflects the quality of the channel to a certain extent, and most wireless communication technologies can easily acquire the RSSI information. However, the factors affecting the RSSI are too many, and the numerical reaction is the superposition effect of the multipath propagation of the signal, and the multiple signal propagation paths cannot be distinguished one by one, so that it is difficult to extract the information capable of effectively detecting the number of people from the RSSI. While CSI (Channel State Information ) can obtain the amplitude and phase of multiple subcarriers of OFDM (Orthogonal Frequency Division Multiplex, orthogonal frequency division multiplexing) at the same time, characterizing multipath propagation to some extent. The presence and activity of a person will significantly alter the propagation path of the WiFi signal, affecting the amplitude and phase of each subcarrier. The CSI expands the single-value RSSI to the frequency domain, and adds phase information, so that richer and fine-grained multipath propagation information is provided for the detection of the number of people. In the IEEE 802.11n standard, CSI is listed in the content of MAC (Medium access control ) frames. This means that we can obtain CSI information for head count detection through 802.11n compatible WiFi facilities that have been widely deployed.
Disclosure of Invention
The invention provides a human body sensing method and a human body sensing system based on a WiFi microcontroller, which solve the technical problems, and specifically adopts the following technical scheme:
a human body sensing method based on a WiFi microcontroller, comprising the following steps:
collecting channel state information through a WiFi microcontroller;
carrying out data processing on the acquired channel state information;
and inputting the processed channel state information into a pre-trained people number detection model to obtain a people number detection result.
Further, the specific method for acquiring the channel state information through the WiFi microcontroller comprises the following steps:
disposing a device comprising a WiFi microcontroller at a corner of the space;
connecting a WiFi microcontroller to a WiFi device;
sending Ping packets to WiFi equipment at preset intervals through a WiFi microcontroller;
after receiving the Ping packet, the WiFi device returns a return data packet containing channel state information to the WiFi microcontroller;
and the WiFi microcontroller extracts the channel state information from the received return data packet and stores the channel state information into a queue.
Further, the specific method for carrying out data processing on the collected channel state information comprises the following steps:
selecting 20 groups of subcarriers with larger amplitude from 56 groups of subcarriers of channel state information acquired by a WiFi microcontroller;
this sampling of the amplitude and phase of the selected channel is differenced from the previous sampling to obtain differential data;
and identifying and removing outlier abnormal data by a local abnormal factor method to obtain the preprocessed channel state information.
Further, in the process of inputting the processed channel state information into a pre-trained people number detection model to obtain a people number detection result, the specific method of pre-training the people number detection model is as follows:
collecting channel state information under different people number states, and performing data processing and data labeling;
and inputting the labeled data into a first LSTM cyclic neural network to train the labeled data to obtain a people number detection model.
Further, after the processed channel state information is input into a pre-trained people number detection model to obtain a people number detection result, the human body perception method based on the WiFi microcontroller further comprises the following steps of:
and inputting the number of people detection results into a pre-trained number of people prediction model to obtain number of people prediction results.
Further, in the step of inputting the number of people detection result into a pre-trained number of people prediction model to obtain a number of people prediction result, the specific method of pre-training the number of people prediction model is as follows:
measuring the number of people detection results in different time periods;
and inputting the number of people detection results in different time periods into a second LSTM cyclic neural network to train the second LSTM cyclic neural network to obtain a number of people prediction model.
A WiFi microcontroller-based human perception system, comprising:
the WiFi microcontroller is used for acquiring channel state information;
the data processing module is used for receiving the channel state information acquired by the WiFi microcontroller module and carrying out data processing on the channel state information;
the people number detection module is used for receiving the channel state information processed by the data processing module and analyzing the channel state information through the pre-trained people number detection model to obtain a people number detection result.
Further, the WiFi microcontroller is connected to the WiFi device;
the WiFi microcontroller sends a Ping packet to the WiFi device at intervals of preset time;
after receiving the Ping packet, the WiFi device returns a return data packet containing channel state information to the WiFi microcontroller;
and the WiFi microcontroller extracts the channel state information from the received return data packet and stores the channel state information into a queue.
Further, the data processing module comprises:
the data selection unit is used for selecting 20 groups of subcarriers with larger amplitude from 56 groups of subcarriers of the channel state information acquired by the WiFi microcontroller;
the computing unit is used for obtaining data differential data by making difference between the current sampling and the previous sampling of the amplitude and the phase of the channel selected by the data selecting unit;
and the data analysis unit is used for identifying and removing outlier abnormal data through a local abnormal factor method to obtain the preprocessed channel state information.
Further, the human body sensing system based on the WiFi microcontroller further comprises:
the people number prediction module is used for receiving the people number detection result obtained by the analysis of the people number detection module and analyzing the people number detection result through the pre-trained people number prediction model to obtain a people number prediction result.
The human body sensing method and system based on the WiFi microcontroller have the advantages that a non-invasive human number detection scheme that detected personnel do not need to carry any electronic equipment is achieved, personnel matching is not needed, and privacy protection caused by visual human number detection is avoided.
The human body sensing method and system based on the WiFi microcontroller provided by the invention have the beneficial effect that the WiFi microcontroller equipment is adopted. Only need additionally install the device that has wiFi microcontroller can realize the function that the number detected at the current wiFi infrastructure of make full use of indoor. The implementation cost is very low.
Drawings
Fig. 1 is a schematic diagram of a human body sensing method based on a WiFi microcontroller according to the present invention.
Detailed Description
The invention is described in detail below with reference to the drawings and the specific embodiments.
Fig. 1 shows a human body sensing method based on a WiFi microcontroller, which can be used for detecting the number of people in an indoor environment. It will be appreciated that the indoor environment may be an indoor space, or a plurality of indoor spaces, such as a building. The human body sensing method based on the WiFi microcontroller specifically comprises the following steps of: s1: channel state information is collected by the WiFi microcontroller. S2: and carrying out data processing on the acquired channel state information. S3: and inputting the processed channel state information into a pre-trained people number detection model to obtain a people number detection result. Through the steps, the non-invasive people number detection scheme that detected personnel do not need to carry any electronic equipment can be realized, and privacy protection problems caused by visual people number detection do not exist without personnel cooperation. The WiFi microcontroller equipment is adopted, and the function of detecting the number of people can be realized by fully utilizing the indoor existing WiFi infrastructure only by additionally installing a device with the WiFi microcontroller. The implementation cost is very low. The above steps are specifically described below.
For step S1: channel state information is collected by the WiFi microcontroller.
In the application, the specific method for acquiring the channel state information through the WiFi microcontroller is as follows:
a device including a WiFi microcontroller was placed at the corners of the space. In this embodiment, the WiFi microcontroller is ESP32.
The WiFi microcontroller is connected to a WiFi device. Wherein, the WiFi device supports IEEE 802.11n standard.
And sending the Ping packet to the WiFi device at intervals of a preset time through the WiFi microcontroller. It will be appreciated that the predetermined time may be set according to actual needs. In this application, the WiFi microcontroller is set to send Ping packets to the WiFi device at intervals of 20 ms.
And the WiFi device returns a return data packet containing channel state information to the WiFi microcontroller after receiving the Ping packet.
And the WiFi microcontroller extracts the channel state information from the received return data packet and stores the channel state information into a queue.
For step S2: and carrying out data processing on the acquired channel state information.
Specifically, the specific method for carrying out data processing on the collected channel state information comprises the following steps:
and selecting 20 groups of subcarriers with larger amplitude from 56 groups of subcarriers of channel state information acquired by the WiFi microcontroller. Thereby avoiding quantization errors introduced by sub-carriers with smaller amplitudes.
This sample of the amplitude and phase of the selected channel is differenced from the previous sample to obtain differential data. The differential data reflects the variation of the channel state information.
And identifying and removing outlier abnormal data by a local abnormal factor method to obtain the preprocessed channel state information.
For step S3: and inputting the processed channel state information into a pre-trained people number detection model to obtain a people number detection result.
In a preferred embodiment, in inputting the processed channel state information into a pre-trained population detection model to obtain a population detection result, the specific method of the pre-training population detection model is as follows:
and collecting channel state information under different people number states, and performing data processing and data labeling.
And inputting the labeled data into an LSTM circulating neural network to train the data to obtain a people number detection model. During training, parameters for the LSTM recurrent neural network are set as follows: the network memory period was set to 32, the LSTM hidden layer number was set to 128, the learning rate was set to 0.001, and the batch size was set to 20.
Thus, after the processed channel state information is input into the trained LSTM cyclic neural network, the LSTM cyclic neural network outputs the detection result of the number of people.
Further, the number of people detection result is uploaded to the server through the MQTT protocol by WiFi. And the server receives the detection and prediction results of the number of the people in each device and stores the detection and prediction results into a database.
As a preferred embodiment, after the processed channel state information is input into the pre-trained people detection model to obtain the people detection result, the human body sensing method based on the WiFi microcontroller further comprises the following steps:
and inputting the number of people detection results into a pre-trained number of people prediction model to obtain number of people prediction results.
Specifically, in the process of inputting the number of people detection result into a pre-trained number of people prediction model to obtain a number of people prediction result, the specific method of pre-training the number of people prediction model is as follows:
the number of people under different time periods is measured.
And inputting the number of people detection results in different time periods into another LSTM cyclic neural network to train the number of people detection results to obtain a number of people prediction model. Wherein, the parameters for the LSTM recurrent neural network are set as follows: the network memory period was set to 64, the LSTM hidden layer number was set to 128, the learning rate was set to 0.001, and the batch size was set to 20.
Thus, after the number of people detection result is input into the trained LSTM circulating neural network, the LSTM circulating neural network outputs the number of people prediction result.
The application also discloses a human body sensing system based on the WiFi microcontroller, which is used for realizing the human body sensing method based on the WiFi microcontroller. It comprises: wiFi microcontroller, data processing module and number detection module.
The WiFi microcontroller is used for collecting channel state information. The data processing module is used for receiving the channel state information acquired by the WiFi microcontroller module and processing the data. The people number detection module is used for receiving the channel state information processed by the data processing module and analyzing the channel state information through the pre-trained people number detection model to obtain a people number detection result.
Specifically, the WiFi microcontroller is connected to a WiFi device. The WiFi microcontroller sends Ping packets to the WiFi device at predetermined intervals. And the WiFi device returns a return data packet containing channel state information to the WiFi microcontroller after receiving the Ping packet. And the WiFi microcontroller extracts the channel state information from the received return data packet and stores the channel state information into a queue.
As a preferred embodiment, the data processing module comprises: the device comprises a data selection unit, a calculation unit and a data analysis unit.
The data selection unit is used for selecting 20 groups of subcarriers with larger amplitude from 56 groups of subcarriers of channel state information acquired by the WiFi microcontroller. The computing unit is used for obtaining data differential data by performing difference between the current sampling and the previous sampling of the amplitude and the phase of the channel selected by the data selecting unit. The data analysis unit is used for identifying and removing outlier abnormal data through a local abnormal factor method to obtain preprocessed channel state information.
Further, the human body sensing system based on the WiFi microcontroller further comprises: and a people number prediction module.
The people number prediction module is used for receiving the people number detection result obtained by the analysis of the people number detection module and analyzing the result through a pre-trained people number prediction model to obtain a people number prediction result.
Specific technical parameters, namely details refer to the description in the human body sensing method section based on the WiFi microcontroller, and are not repeated here.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be appreciated by persons skilled in the art that the above embodiments are not intended to limit the invention in any way, and that all technical solutions obtained by means of equivalent substitutions or equivalent transformations fall within the scope of the invention.