{'fraction_non_alphanumeric': 0.026519787841697267, 'fraction_numerical': 0.0029919760641914863, 'mean_word_length': 4.973598700243704, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Millimeter-wave Respiratory Rate Detection System with WiFi and Android Platform

Sleep monitoring is widely used in health monitoring. Sleep respiratory rate is an important indicator of sleep quality. This paper designs a respiratory frequency monitoring system based on millimeter-wave radar, WiFi communication module and an Android-based mobile terminal APP. The respiratory data collected by the millimeter-wave radar is transmitted to the mobile phone through WiFi module. The phone can directly display the respiratory frequency data and the respiratory frequency in a curve manner. After testing, the system runs stably and reliably, has real-time performance and strong portability, and provides a new application method for millimeter-wave radar.


Introduction
Sleep is very important for a person's immune, nerve, and muscular systems. The duration and quality of sleep are important factors affecting the effect of sleep. Good sleep can improve people's quality of life and reduce the risk of disease. Respiratory rate and breathing patterns during person's sleep are important indicators of sleep quality. To monitor these parameters, the most common way is observing person's chest and counting the number of breaths per minute through physical assessment.
Erden F et al. [1] used pyroelectric infrared (PIR) sensor and accelerometer to non-contact measure the PIR sensor signal generated by chest motion so as to obtain respiratory frequency. This method has a high computational complexity. Meanwhile, in its experimental scheme, only 10 subjects were tested, so the conclusion may be due to accidental factors. O 'kelly D et al. [2] used multispectral optoacoustic tomography (MSOT) to capture chest motion data to determine respiratory frequency. This monitoring method is more convenient to implement, but it is easily disturbed by other external movements or the monitoring object's own unconscious movements, thus resulting in inaccurate testing. Piechocki [3] , based on passive doppler radar, monitored respiratory rate by capturing doppler changes in the chest caused by inhalation and exhalation movements. However, these products usually needed to keep the chest facing the radar, so they are difficult to be applied in actual sleep scenarios. Chen C et al. [4] , based on time-reversal (TR) technology, used TR resonance intensity to measure the changes of WiFi channel state information caused by human respiratory movement when WiFi signal passes through human body, so as to identify human respiratory movement. The accuracy of this method is better, but more WiFi devices are needed to obtain sufficient channel state information. Costanzo et al. [5] designed a software-defined radar with Doppler refinement, by placing the antenna on the human chest to monitor the chest oscillation and collect respiratory signals. This kind of biological radar technology can realize long-distance detection of human breathing and other information through clothes, bedding, etc. It is becoming a hot technology in monitoring respiration. It can be said that some current sleep monitoring technologies have limitations, such as inaccuracy, high maintenance and lack of comfort. These technologies such as passive infrared (PIR) and time-of-flight (TOF), will be limited by accuracy, thus resulting in false alarm.
On the basis of other kinds of bio-radars, millimeter-wave detection radar has the advantages of large bandwidth, easy to obtain target details and structure characteristics through narrow pulse or broadband FM signal. It also has the enhanced anti-jamming capability, and the potential for miniaturization and integration with smart phones [6]. In today's health marketplace, there is a shift from treatment to active monitoring, which requires a lot of self-tracking and monitoring equipment, these handy self-tracking products can help them monitor their health throughout the day.

Overall System Design
This paper designs a millimeter-wave respiratory frequency monitoring system based on WiFi and Android platform. The system includes a millimeter-wave respiratory frequency detection module, a WiFi module, and an Android phone, as shown in Fig.1. Figure 1. System Scheme. This scheme utilizes millimeter-wave detection radar which is based on ultra wideband (UWB) pulses to collect the breathing frequency of the monitored person. The millimeter-wave radar sends a 77 GHz linear frequency modulated continuous wave (LFMCW) signal. The signal reflects when it encounters a target. The radar receives the reflected signal and processes these signal in order to accurately measure the distance and relative speed of people and other objects.
The method is relatively unaffected by environmental conditions, such as darkness, brightness, and smoke, and can work in a completely dark environment or in bright daylight. The WiFi module constitutes wireless transmission and transmits the acquisition signal to the smart phone. The Android phone is responsible for data display, dynamic curve display, data storage, historical data review and analysis, and instant alarm.
The system collects the breathing frequency of the monitored person in a non-contact manner, and does not need any connection with the body of the monitored person. The millimeter-wave can pass through blankets, duvets and clothes to ensure that it does not affect monitor's comfortable sleep at night or day during the whole collection process.

Respiratory Monitoring based on Millimeter-wave Radar
James D. Taylor put forward the concept of UWB radar in 1995. The UWB pulse signal doesn't require a carrier. It can be made into the size of a palm, and can only be powered by a battery. Millimeter-wave Radar is also called a radar sensor. It has the characteristics of high resolution, and strong penetration. It can detect and image more accurately than traditional radars in a specific range.
The millimeter-wave radar can extract the target reflection signal from a variety of interference reflection signals, separate the breathing signal from the target signal, detect the tiny periodic relative movement between the chest and the chest cavity, and finally calculate the breathing rate. The data of comparable quality to polysomnography (the medical gold standard for sleep monitoring) can generally be provided in overall. Radar sensors for measuring sleep can be placed on the bedside table, on the wall or on the ceiling, and electromagnetic pulse waves are directed at the human chest.
First, the radar sensor periodically sends a linear frequency-modulated continuous wave through a transmitting antenna. The form of the transmitted signal is: (1) Where f is the center frequency of the modulation signal, B is the bandwidth of the FM signal. On the receiving end, the received signal is a delayed version of the transmitted signal: The general process of transmitting and receiving signals is shown in Fig. 2. This signal is subjected to FFT transformation, phase processing, spectrum estimation, etc., so as to calculate the time difference Δt between the transmitted signal and the received signal, and the distance of the target can be calculated to calculate the relative motion of the chest, as shown in Fig.3.

4.1WiFi Transparent Transmission Function
WIFi module uses the AP mode as the server, and Android mobile phone serves as the client to access the wireless site, so that the data of the radar sensor can be transmitted to the Android mobile phone through WiFi module.
The server uses ServerSocket class, and the client uses Socket class. Wifi module in server-side maintains ServerSocket itself. As a client, Android phone's Wifi module needs to programmatically implement the client's Socket to establish a connection, send data, receive data, and close the connection. The TCP-based socket communication process is as follows: The server declares a Server Socket object and specifies the port number, calls the Server Socket's accept () method to monitor whether there is a connection request for the port, and waits to accept data from the Android client. The accept () method is in a blocking state when without data to accept. Once the data is received, it will read the data through input stream.
Android client creates a Socket object and sends a connection request to the server through OutputStream according to the IP address and port number set by the server. The server will enter the blocking accept method and read the data requested by the client through InputStream. After the server finishes processing, it wraps the request result into OutputStream and returns it to the client. The client then accepts the results returned by the server through InputStream object.
For blocking time operations, Android framework does not allow this processing in the main thread. Therefore, it is necessary to create a new sub-thread to process the accepted request, which starts this sub-thread and listens to whether the server returns a result. If data is returned, the data can be gotten in InputStream. After the data transfer is completed, the connection must be released and resources are recovered. Fig. 4 shows the process of server and client socket communication.

4.2Android-based Mobile Terminal APP Design
Using RelativeLayout and Linearlayout designs UI interface for the user to select various function. The data processing module receives the breathing data from the communication module, analyzes the data, and displays and draws the parsed data. The SQLite database is used to store the data for historical queries when needed.

4.2.1Respiration Data and Curve Display
The data processing module is responsible for converting the radar sensor data packet passed by WiFi module into a Bean object that Android can process. The data processing module is mainly implemented by ReceiveMessageBean class. The field isActive is used to receive the returned result that is RPM curve or real-time RPM data. The field dataLength is the length of the data result. Finally, the data returned through getRealDataAfterExchanger() program is for display and saving.
The curve can display the current and previous data, and is continuously updated automatically. The respiratory data to be displayed are first converted into a set of points and stored in a defined Point array, which can be directly called and drawn into the graph when drawing. First, the View attribute can be initialized through the initConfig() function. Because the graph system uses the selfdefined attributes, the custom attribute values in stylrable are obtained through observeStyles Attributes() under this function, including the highest and lowest values that the curve can display. This method will return a TypedArray object. After using it, TypedArray object is recovered through recycle() method. Before drawing the curve, the brush has to be adjusted first, and then draw the curve to the canvas. In Android, the brush is the Paint class. A new brush is started through new Paint () and the style of the brush is set. Function onDraw () is overridden to draw graphics to the canvas.

4.2.2Data Storage and Query
SQLite database is an embedded relational database integrated in the Android system that supports SQL and can easily add, modify, delete, and query data. The stored data is that the mobile phone receives from the radar sensor. The data is inserted into the corresponding column in the table.
To implement a database needs to use the Android.database.sqlite.SQLiteOpenHelper class for database creation and update operations. If the database does not yet exist, calling getWritableDatabase() and get ReadableDatabase() methods of DBOpen Helper class, can create automatically a new database. onCreate() creates the tables and initialization data required by the system. In order to operate the database more conveniently, a DBOpenHelper class is designed to further encapsulate the database operation. This class provides a database operation interface for other modules to call After the mobile phone receives the breathing data, it converts the data into a float type, and the time is obtained by using SinpleDataFormat object. The format of the stored time is first formatted: "year-month-day hour-minute-second", and then a new Data object is used to get the current time. Finally the breathing data and time are be inserted into the corresponding columns through SQL statements.

5.1WiFi Connection and Data Transmission
To click the software app icon "RPM Sensor" on the phone desktop enters the system main interface as shown in Fig. 5. Click the relevant button continuously, then the phone executes the following procedures to start the connection with WiFi module. showToastMessage("Connection Failed"); pd.dismiss(); If successful, the page displays a green tag "Connection", if no connection is established, it displays a red tag "Connection Fail".

5.2Data Display
To click "RPM Curve" button, the homepage interface jumps to the respiratory data curve display interface, and 200 most recent consecutive data are be displayed in the form of a curve, and when a new data is collected, the first collected data is automatically updated, so that the curve display is always the latest 200 data. This curve can be used to observe the change in breathing rate over the entire time period, so as to judge a person's sleep quality or physical health, as shown in Fig. 6 Figure 6. Respiratory data Curve. It can also to click "Historical Data" button, and the interface jumps to the display of historical data with the form of a table. The latest data is at the bottom of the table. As new data is continuously received, the table is continuously updated as shown in Fig. 7. At this point, the system test is complete and the system is working normally.

Conclusion
This paper designs a respiratory frequency monitoring system based on millimeter wave radar, developes a WiFi communication module and an Android-based mobile terminal APP. The Android development environment is set up, including installing JDK, Android Studio and Genymotion. The overall architecture and UI interface of the designed client can be analyzed in detail. For the design and implementation of the software on the mobile phone side, the communication between the mobile phone and WiFi module, the curve display of breathing data, the mobile phone alarm, data storage and query, and historical data review are designed. After testing, the system can well achieve wireless communication and data transmission between the mobile phone and WiFi module, and greatly improve the effectiveness and real-time nature of breathing information collection, which provides a new application method.