#### 4.1. Location-System Hardware

As mentioned, the work in this paper is based on the reference-tag nearest-neighbors localization algorithm and the multiple-antenna time-division-multiplexing localization system. The hardware part consists mainly of the Intel R1000 RFID development platform, the Impinj far-field antenna, and the Invengo XCTF-8030A passive tag. The Intel R1000 RFID development platform mainly consisting of a microcontroller, integrated transceivers, power amplifiers, RF multiplexer, circulator and coupler and so on, which contains all the internal modules of an RFID reader designed to use RF tag for UHF ClassGen2 inquiry and data reception. This platform can be configured to use both receive antennas (RX) and transmit antennas (TX/RX) antennas and to use both transmit or receive the common mode of operation of the antenna. The Impinj far-field antenna is mainly used for 902∼928 MHz RFID systems, with a center frequency of 915 MHz, in line with the EPC global Gen2 ISO18000-6C standard. It has high sensitivity; the far-field read distance (above 6 m), selectable gain, strong anti-interference and noise reduction capabilities, circular polarization and linear polarization selectable features. The system uses three pairs of Impinj far-field antennas. The R1000 development platform is connected respectively to the TX/RX 0, RX0, TX/RX 1, RX1, TX/RX 3, RX3 ports, where 0, 1, 3 represent the transmitting and receiving antenna of each pair, the TX/RX port is transmitting, while RX is a receive port. Under the control of the platform Intel R1000, three pairs of antennas are used by rotation in a time-division-multiplexing manner.

#### 4.2. Localization Algorithm Implementation

In this paper, the localization algorithm based on the nearest-neighbor reference tag has been improved by using, a target-tags historical-trajectory algorithm, as well as a dynamic k value setting method and a nearest-neighbor-tags bias-correction algorithm. In the nearest-neighbor localization algorithm, suppose there are m reader and n reference tags, and u target tags. We assume the n reference tags are arranged according to a certain distribution on the plane. The m readers read the signal strength values for the n reference tags and the u target tags. These values can be written in the form of a field-strength vector. The field-strength vector of a target tag is denoted T⃗ = (T_{1}, T_{2}, ⋯, T_{m}), where T_{j} represents the field strength value of the respective target tag as perceived by the j-th reader; the reference tags field strength value vector is denoted
$\overrightarrow{R(l)}=({R}_{1}(i),{R}_{2}(i),\cdots {R}_{m}(i))$ where R_{j}(i) represents the read produced by the j-th reader to the field strength values of the i-th reference tag. To determine the neighboring extent of the reference tags and the target tag, for each target tag, with p ∈ [1, u], we define:

where E_{i} represents the Euclidian distance between the i-th reference tag and the target tag. The smaller E_{i}, for i ∈ [1, n], the closer the two tags. After comparing by size the E_{i} values, one chooses the k nearest distances to the target tag, corresponding to the nearest-neighbor tags, which compose a set κ. This definition of a weight of k nearest neighbor tags is introduced:
Thus, by using Equation (3) one can get the coordinates of the target tag:

Body position changes do not happen a lot in a short time. This justifies the use in this paper of the target tag historical trajectory algorithm, in which the RFID tags worn by the human body as a target tag are associated with historical weighted estimate of the current position. Assuming the current estimated position is (x_{0}, y_{0}), and the i-th estimated position is (x_{i}, y_{i}), where i = 1, 2, ⋯, s, the estimated value of (x, y) is obtained after considering the historical track. By investigating the residual weighting function:

when the Q value obtained has the minimum value, we can obtain the best estimated value. After derivation, the Equation (4) can be solved for (x, y):
where w_{i} represents the weight of each historical location value:
Equation (6) shows, that if the history of the position (x_{i}, y_{i}) is closer to the current position (x_{0}, y_{0}), then w_{i} has a larger value, to which it corresponds a larger weight. In actual measurement situations sometimes for several reference tags the field strength values of one or several components of the vector cannot be read, resulting in localization error. The dynamic k value method makes more nearest neighbor tags to participate in the RFID temperature sensing tag weighted positioning, in order to reduce the localization error. In the initialization process, the initial number of tag k-nearest neighbor is first set to k_{0}. In the hardware control program, if the value of the field strength component cannot be read, a value is artificially set. In the positioning program, if the number of the detected artificial field strength value tag is c, then the number of nearest neighbors tag k is corrected to k_{0} + c. The experiment found that the initial value of k_{0} can be 3, 4 or 5, with 4 being better.

The relationship between field strength and distance is not linear, but one similar to a negative exponential curve. When the RFID temperature sensing tag is closer to a reader, steep changes in the value of the field strength, the nearest neighbor tag select deviations and weights deviations, affect positioning results. Therefore, in order to solve the problem we used the nearest neighbor tag positioning error as a correction. Using the method described in the nearest-neighbor localization algorithm, select k nearest neighbor tags, and then were consider the k reference tags as the target tags, one at a time, the remaining n − 1 tags as reference tags, obtained by calculating the estimated position for each target of the tags, denoted (
${x}_{i}^{\prime}$,
${y}_{i}^{\prime}$), where i = 1, 2, …, k. Then by using the estimated position of the k tags and by comparing it to their actual location, get the correction value:

Finally, the correction value is used to obtain the RFID-temperature-sensing-tag location coordinates:

The localization algorithm flow is shown in Figure 5.

Following is a brief description of the localization algorithm flow: (1) Set various parameters, such as the number of readers m, the number of reference tags n, the number of nearest neighbor tags k, and historical value reads s; (2) Read the value of the field strength of each tag; (3) Correct k values in order to compensate for detected failures to read the value of the field strength in the second step; (4) Calculate E values for each reference tag; (5) Select k nearest neighbors tags according to the value of E; (6) Calculate the corrected values for each nearest neighbor tag; (7) Determine the weighted nearest neighbor tag position in order to get an estimate; (8) Repeat (4) to (7), for each nearest neighbor tag as target tag, and the other n − 1 as the reference tags, to obtain a location estimate value for each nearest neighbor tag, and the calculated deviation; (9) Get new estimates by making the correction with the deviation of the estimated value of the target tag; (10) Repeat (2) to (9) s + 1 times, the last value being the current estimated value, i.e., the historical value before s times; (11) Calculate the weights of each historical position; (12) Apply weighting in order to give the final target tag position estimate.