Implementing a Distance Estimator for a Wildlife Tracking System Based on 802.15.4

: In this work, a novel distance estimation mechanism using received signal strength indication (RSSI) signals with ZigBee modules is designed, implemented and tested in several scenarios. This estimator was used for a research project focused on a wildlife behavioral classiﬁcation system deployed in Doñana’s National Park. As a supporting feature for that project, this work was implemented for locating animal’s collars acting as wireless nodes in order to ﬁnd those who went outside of the coverage area of the network or that were accidentally detached from animals. This work describes the system architecture and the implementation of a mobile assistant capable of recovering devices located beyond the coverage of the network. The analytical model needed for distance estimation and the signal ﬁltering are described, as well as the difﬁculties that the researchers must deal when building robust location estimators. This theoretical model was applied to three different scenarios and tested with two validation experiments.


Introduction
Although the theoretical model of radio wave propagation and its relation with the received signal strength has been well defined for long time [1], studies about the use of this theory in location systems show that serious difficulties exist in its application [2,3].This can be due to the presence of several kinds of noises in the measurements of the signal strength, which makes it difficult to use the signal strength as the only variable to evaluate the distance to a target.Examples can be found in [4], in which the authors employed variance and its relation with RSSI (received signal strength indication) to improve accuracy in distance assessment (at large distances, with a large set of measurements), and in [5], which uses the modulation phase to improve the accuracy at small distances (in very controlled ambient conditions).
Other ways to solve the signal variability problem have been the use of filtering stages, such as adaptive window filtering [4], particle filtering [6][7][8] or adding measurement stations (triangulation) (e.g., Reference [9,10]), where some environmental conditions are established (e.g., the position of the antenna and its orientation, voltage references, and others) to avoid the variability of received signal strength measurements.These works and authors have achieved improvements on distance assessment, but at the expense of computation cost and system complexity.
There are several theoretical propagation models, but not all of them can be used in every system and conditions.In the case of wireless sensor networks (WSN) operating at 2. 5 GHz in open fields at 2 m height at most, models must be capable of operating with a small quantity of measurements and be lightweight to allow fast computing with small resources.Proposed models such as Ray-Tracing [11], Finite-difference time-domain [12], or Artificial Networks [13] are much better when estimating position in terms of accuracy than other models, but, as mentioned above, at the expense of a high computation cost [14].Other models (e.g., Reference [15]) are well accepted for network deployment of cellular devices (≤1.5 GHz) but not suitable for higher frequencies.
The log-normal model, together with the free-space model [16] are some of the most used models operating at 2.5 GHz for being the calculation procedure simple [4] (at distances greater than the length of the antenna and the wavelength) but at the expense of a lower accuracy.One alternative is 2RM (2-Ray Model) [4], which includes this length as one of the parameters to calculate two possible signal paths.An improved version of this model can be found at [17] but the improvements over the log-normal model are only present at d ≥ 4πH rx H tx , which in our case is more than 250 m (when setting the maximum height of the antennas that were used in this work at 160 cm).Further details about the position of the antenna can be found in Section 2.5.
This work presents a relative distance estimator for Wireless Sensor Network devices operating at 2.5 GHz using the 802.15.4 standard [18], on which the target device is a wildlife tracking and behavior classifying device that is attached to an animal by means of a collar.The distance estimator is used to locate collars belonging to animals that are not moving, or collars that have been abandoned by the animals to which they belonged, or even collars that have gone outside of the coverage area of the WSN.On the other hand, the locating device (that uses the distance estimator algorithm) is used by an operator that moves overland with a WSN node that acts as a 802.15.4 wireless packet sniffer.To justify this development, the propagation model and filters used are shown together with two ways to deal with signal measurement variability and uncertainty.In Section 3, we present the data obtained from three scenarios that were designed to fit our propagation model, and also two additional experiments designed to validate the propagation model.In the discussion section, the solution to the problem of uncertainty in distance estimation is justified and the problems aroused when trying to implement the proposed solutions are presented.

Distance Estimation Model
Signal strength is a technique used for distance estimation.Signal strength decays with distance between radio stations at a well known rate.Given that transmitted and received power can be known in some cases (transmitting device is clearly known or transmission features are sent by radio to the receiver), we can compute the loss of power in the receiver due to the travelled distance (also called pathloss).If pathloss is related with distance, then it is possible to know the distance between transmitter and receiver knowing some transmission parameters (such as the transmitting power and the gains of the antennas) and the received power (also called RSSI).
As mentioned in Section 1, one of the most used models for RSSI estimation is the log-normal model [16].This model is used for indoor and outdoor environments, depending on two fitting parameters: d 0 , a reference distance (therefore, being PL d 0 the experimentally measured average pathloss at distance d 0 ), and η, called pathloss index.X σ is a random Gaussian distributed variable with zero mean and standard deviation σ that models the attenuation effects of flat or slow fading (that can be considered as noise).Equation (1) presents the pathloss value perceived by a receiving station, expressed in dbm, as a function of the distance between stations (d).
Fitting parameters change depending on the season and the scenery [19].To fit both parameters, a linear approximation of both parameters can be done, converting Equation (1) into a strike line equation such as y = ax + b with the changes [20] expressed in Equation (2).
where PL(d) can be obtained from the receiving station if the following transmission features are known: transmitting (G TX ) and receiving antenna gain (G RX , in dbi), transmission power (P TX in db), and received power (P RX or RSSI, in dbm).Then, the pathloss perceived by a receiving station is calculated in Equation (3).Therefore, distance d can be obtained from Equation (1), ignoring noise effects, as expressed in Equation (4).

Filtering
Noise effects can be taken into account and partially removed in Equation ( 4) if some filtering is done to the received signal strength.Given the highly noisy nature of signal strength, several types of filters can be applied, e.g., the Kalman filter [21], simple moving average filters, or exponential moving average filters.This way, most of the noise can be removed from signal strength measurements, giving some stability and robustness to the distance estimation.
Kalman filters can be successfully applied to filter RSSI: the robustness and simplicity of the calculations can be attractive.However, it must be taken into account that this kind of filter is designed for static conditions between radio stations (stations do not move, thus the signal must be a fixed value, and the rest of variations can be considered as noise).For this reason, the filtered signal has a low responsiveness to changes and might not be suitable for moving stations [21].The main problem in this filter appears when trying to make a proper parameter fitting.In this case, adjusting the variance of the noise is critical.However, once fitting is done, this filter is very appropriate for removing white Gaussian noise from the signal.
In Figure 1, a Kalman filter is used over RSSI measurements from a slightly moving station in a period of 220 s.The variance of the noise (10.66) was calculated by taking the maximum value from a shifting window of 20 samples.
Simple moving average (SMA) can be an option when responsiveness is needed, but can be heavier to compute (in the case of computing a high number of measurements) than Kalman filters (for RSSI).In this case, the window size determines the filtering smoothness and responsiveness, but is a critical parameter for the filter performance.In Figure 2, a simple shifting-window average filter with a 20 samples window can be seen filtering the same signal as in Figure 1.
The greater the window is, the smoother the filter becomes, as well as the heavier it is to compute.This filter fits the signal better than Kalman.However, it needs many samples to fit properly.In WSNs, this can be a drawback because this kind of networks commonly has a low bandwidth and large periods of time between packets and, therefore, much time could be required to compute the signal.To smooth more quickly with fewer samples, a double exponential shifting-window average filter can be used.
In Figure 3, a double exponential moving average filter (EMA2 filter) is applied.As can be seen, the curve is smoother, and the filter only needs four samples instead of more than 20 (which are needed in the simple moving average).In this work, we choose EMA2 filtering due to the low computation time, the reduced number of samples required, and the good smoothing capability.

Considering Uncertainty
Until now, the existence of noise (denoted as X σ in Equation ( 1)) is reduced by the use of filters that smooth the RSSI signal.However, we must keep in mind that noise is not the only source of uncertainty in the RSSI.Issues such as the orientation of the antenna, obstacles, thermal noise, and others can produce unexpected variations over the RSSI that could make modeling the system harder.
Given that the environment conditions (humidity, temperature, type of soil, and vegetation) is a key factor [22], some authors opted for featuring terrain depending on some of variables described above (e.g., Reference [19]).Other authors opted for building auto-corrective models in order to adapt distance calculation to environmental conditions (for example, in [4], variance is used for auto-adjusting), and others states that it is difficult to model a distance estimator using RSSI due to the intrinsic lack of distance information contained in it [13].Our options to consider the uncertainty of RSSI are: to create a model that outputs a distance range instead of a precise distance to the target and/or a model that outputs relative distance information regarding the target (approaching, receding, or staying in the tame position).

Ranges of Distances
The first option could be modeled by considering the standard deviation observed in the signal and the application of the 68-95-99.7 rule that states that, given a random variable X that follows a normal distribution with mean µ and standard deviation σ, Equation ( 5) is obeyed.
Thus, if we obtain a filtered RSSI X with standard deviation Y, we have a probability of 68% for finding our target in the range [ f (X + Y), f (X − Y)] being f (x) the modeling function, and so on.Therefore, standard deviation is a parameter that must be considered to build distance intervals in several ways.Distance intervals can be built adding the observed standard deviation at each average measurement obtained from the characterization experiments, obtaining the curve shown in Figure 3 (and subtracting it to obtain the lower distance).Another way to consider standard deviation to build intervals is to make two models: one for modeling maximum distance (considering average measurements from the characterization experiments and adding its proper standard deviation) and another for modeling minimum distance (this time, subtracting standard deviation).
In Figure 4, a set of standard deviation measurements for three scenarios can be seen.The horizontal axis represents distance and the vertical axis represents the standard deviation of the RSSI taken from more than 3000 measurements for each point on the x-axis.For Scenario 2, an average scenario has been considered as the whole set of measurements regardless of the polarization of the antenna (SD_Scn2), and partial scenarios taking this into account are shown as SD_Scn_2_0 and SD_Scn_2_90.
As can be seen, there is no common relationship in absolute values between scenarios or a common trend between values and distance: Scenario 1 shows a decreasing trend, while Scenario 2 (regardless antenna polarization) shows the opposite, and Scenario 3 shows a slightly increasing trend.Given that the variability of RSSI can be affected by many physical factors, it could be better to obtain the value of the standard deviation in real time instead of obtaining a static value for each environmental condition.

Relative Distance Information
This kind of estimation is based in a continuous estimation function such as Equation ( 6): The implementation of this function is simple: first, given a filtered RSSI, we can assess the distance to the target and, comparing it with the last distance measurement, the relative distance to our target could be known as in Equation ( 7): However, the implementation shown in Equation ( 7) is very abrupt and must be smoothed to behave as a continuous function in order to express something such as a receding rate, in which a value closer to one means a moving-away rate greater than a value near to zero, and vice-versa.This functionality can be achieved by smoothing the output of this function with a double exponential moving average filter, as presented below.Therefore, the first approach to the architecture of the relative distance estimation is Equation (8): This architecture can be simplified if we keep in mind that the use of distance is not precise because the fitting of the distance model is different in every scenario and, therefore, the output does not fit to the true distance to the target.The only known fact is: low values of pathloss mean a nearer distance than higher ones.Therefore, using Equation (3) in our architecture, we obtain Equation ( 9): Then, no fitting is needed for distance estimation and the only parameters to consider are the ones used for the filters in this architecture.

Hardware Infrastructure
The main components of the WSN scenario used are: the base station, collars, 802.15.4 motes, the mobile node, and the 802.15.4 sniffer device, which can be seen in Figure 5.
The base station is a solar-powered computer that is the central and main node of the network and its main goal is to collect all the packets sent from collars and upload them to a database through WiFi.On the other hand, 802.15.4 motes are small solar-powered devices whose purpose is to extend the coverage of the network, being able to receive packets from collars and send them to another mote or directly to the base station if it is close enough.More information about these two systems and the others that have been mentioned can be found in previous publications [23][24][25].In this work, we focus on the main relevant components for the distance estimation task that we present, which are: collars, the 802.15.4 sniffer devices and the mobile node.

Collars
Collars (see Figure 6) are smart devices that are placed on target animals and are able to monitor them and collect behavioral information that is then sent to a base station using an 802.15.4 ZigBee 2.4 GHz radio module.
Collars consist of a set of sensors such as a GPS, for obtaining the location where the animal is, and also the time at which this information is collected; and an inertial measurement unit (IMU) that contains an accelerometer, a gyroscope and a magnetometer.The data obtained from the IMU are processed to extract the relevant information from the sensors, and then sent to a neural network (NN) that is embedded on the collar's micro-controller, which was trained to classify between three different gaits: walking, trotting, and running.More information about the network, the training process, and the accuracy that the system is able to achieve can be found in [23].
Processing the information on the embedded NN (Neural Network) and then sending the results to the base station instead of sending the sensor data to the base station and then classifying them drastically reduces the number of packets sent through the network, reducing the power consumption of the system and thus improving battery life, which is crucial for this project [24].

802.15.4 Sniffer Device
The sniffer is a CM5000 TelosB based device that is able to capture all the data packets that are sent by the different nodes of the network and also obtain information about signal strength (or RSSI).
The sniffer is connected to a portable device (also called mobile node) through a USB port.The information of every ZigBee packet detected on the network is received in the mobile node.This way, the RSSI and the collar ID can be used in the software application that runs on the mobile node in order to determine the relative position of the animal from the sniffer device.This can be used to track animals that are outside of the coverage area of the network based on the request for connection data packets sent from the collar to the base station.

Mobile Node Software Application
As mentioned in previous sections, the mobile node is a portable device that is used to track orphan nodes corresponding to animals that are outside of the coverage area of the network, among other functionalities.
Figure 7 shows the software application that was developed for the mobile node.This application also has a map in which the base station, collars, and other nodes are shown.

Data Acquisition
As mentioned above, we studied how the signal strength decays with the distance in rural areas for 2.4 GHz networks.To this end, different experiments were performed applying the distance estimator based on RSSI.In this system, first, the mobile node Xbee coordinator establishes the communication between the collar and the sniffer.After setting the WSN, the collar device sends data packets with a period of 123 ms, which the sniffer captures using a directional antenna.This way, the mobile node is able to track the collar using the RSSI information obtained by the sniffer.
To acquire data to fit and evaluate the distance estimator, different experiments were performed, three of them under static conditions (called characterization experiments) in which the mobile node and the collar were located at fixed locations to collect data and characterize the distance estimator model and two under dynamic conditions (called validation experiments) so that the collar was moving away from the mobile node while collecting the data to evaluate the estimator.
The experiments were performed in open areas with no objects or high vegetation between the mobile node and the collar, in order to obtain an as clean as possible signal and with the minimum amount of noise.The choice of these areas was made according to the study in [22], where three different scenarios were taken in consideration: areas with dunes (no vegetation at all), wetlands (only low-height vegetation), and mixed areas.Although the path between the mobile node and the collar was clear, it is important to mention that some bushes and trees were present at both sides (except for the area with dunes), which could have reflected the signal sent by the collar, adding some noise to the measurements that were taken for these experiments.
For the characterization experiments, the signal emitted by the collar was registered at different distances.To ensure the communication between the collar and the sniffer, the Xbee coordinator was located next to the collar device.Figure 8 shows the system that we build to perform these experiments.For each of the distances studied, it was established that the sniffer had to receive at least 10,000 packets from the collar during a period of around 10 min (which is only considered for these static experiments whose purpose was to collect data).In the first experiment, the signal was measured at 10, 50, 100, 250 and 400 m under warm weather conditions (39.6 ± 2.43 • C and 21 ± 1.73% relative humidity).In the 250 and the 400 m scenarios, the sniffer was not able to gather the 10,000 packets goal that was set during the 10 min test, which could have been caused by the long distance to the collar device or by many other causes including weather conditions or other artifacts.
Then, in the second experiment, the signal was measured at the same distances as the first one, as well as for 200, 300 and 350 m under similar weather conditions (32.86 ± 4.34 • C and 34 ± 10.86% relative humidity).Besides, for each of these distances, a test with a different polarity on the sniffer's antenna was also performed, rotating it 90 • with respect to the collar's antenna.With this, we studied if the signal drop is influenced by the antenna's polarity.
Finally, in the last experiment under static conditions, the signal was measured at different random distances between 0 and 50 m, including distances multiples of 10 m.The weather condition was different compared to the other experiments with a temperature of 16.48 ± 2.45 • C and 64 ± 9.58% relative humidity.
For the validation experiments, the mobile device was located in a fixed position while the collar was moving away from it while registering the signal.The data were collected from the collar packet's RSSI starting from the position where the sniffer was, and then continued while moving away from it until reaching a distance of 50 m.Apart from changing the scenario, in these two validation experiments, the speed at which the collar was moving was also different, being faster in the second experiment than in the first one.In these experiments, the Xbee coordinator was situated next to the mobile device and the sniffer (Figure 9).

Results
After collecting the data from the characterization experiments that were carried out in three different scenarios where the antennas' gain was the same, the results are presented in Tables 1-3.
Table 1 presents the results obtained from the first experiment, and the average value for the pathloss measurements are presented for each of the distances studied, along with their corresponding standard deviation values.Then, in Table 2, the same results are presented for the second scenario, including more distances distances that were taken into account when collecting the data, and also considering the antenna's polarization (0 • and 90 • ).On the other hand, Table 3 presents the same results for the third scenario, which considers shorter distances than the previous experiments, for more precise estimations.

Discussion
The system presented in this work is focused on locating collars belonging to wild animals in two different situations: the animal is dead or the animal lost its collar in the open field (the collar is in a static location in both cases).From this point of view, we supposed that signal conditions such as the orientation of the antenna and transmission power do not change and only environmental conditions constitute a challenge for distance estimation.In fact, we also assumed that we could reduce the possible variations to fewer than four for each type of field (cold/warm and wet/dry, similar to proposed in [19]), and for this purpose the first three experiments were carried out for static distances, along with two experiments on a moving target through a known path.
Once we obtained the result from the three static scenarios and the two validation experiments, we reconsidered our point of view, given that there were poor similarities between scenarios and the distance estimation from the validation experiments in the third scenario showed severe lack of precision.In Table 4, the results of fitting these scenarios are shown.With these parameters, we tried to calculate the distance to a moving target located in the third scenario, already fitted.First of all ,we considered the use of double exponential moving average filters to reduce white noise in RSSI but we realized that the behavior of Kalman filter (knowing variance, obtained as the maximum from all the characterization experiments) was better, and more approximated to reality, as can be seen in Figure 10.This figure illustrates an experiment on which one person is moving away from the receiver's station at a low speed, nearly constant rate, from 0 to 50 m, so the trend of pathloss must be increasing.This effect is better reflected by the Kalman filter than the EMA2 filter.With pathloss already filtered, we proceeded to calculate distances using parameters obtained from characterization experiments (shown in Table 4).Given that the validation experiments were done in Scenario 3, we computed distance and obtained a series of distances that differed from the characterization experiments, as can be seen in Figure 11.As can be seen, the maximum distance is slightly higher than 35 m and there are some moments when the target is getting closer.Things do not improve if we use range estimations: despite variability, it was not enough to justify a maximum distance of 50 m, as can be seen in Figure 12.
Maximum distance is 35 m but the experiment was done little time after the characterization experiments, used to fit the model.We believe that, even so, variations in the position of antenna, or even the antenna's length and other effects severely distort RSSI when obtaining precise measurements.In our opinion, this makes any absolute distance estimator model unsuitable to fulfill our purposes.
Taking this into account, we built the first relative distance estimation model (Equation ( 8): for this implementation, we used the same Kalman filter as before, and for the smoothing purposes we used a EMA2 filter with a smoothing parameter of 0.005.The curve presented in Figure 13 means that the target was moving away from the receiving station during almost the entire time.Only during a small period of time the target was getting closer at a very slow rate.For this reason, the estimated value for the receding rate for this experiment must be a positive value, but it cannot be determined by any specific value because it depends on the smoothing capacity of the filters employed after the relative distance calculation.Therefore, we used the average value of the relative distance calculation proposed in Equation ( 7) as the ideal value for this experiment.First, we used the log-normal model that was already fitted to Scenario 3 to supply data to the relative distance function, but we could check that the results were exactly the same.This implies that this estimation model is more robust against environmental conditions than the log-normal model.
This fact was checked analyzing a second validation experiment, which was carried out in a different scenario (Figures 14 and 15).This time, the target collar was moving away at a slightly faster speed than before, going from 0 to 50 m in 3.5 min instead of more than 5 min (first validation experiment).The estimated value for this experiment was calculated following the same considerations as before.As expected, it supplies less information than an absolute distance estimation model but it could be used successfully for locating stations in a static position with a receiver that uses a non-directional antenna.
A last consideration could be done when watching the right part of Figures 13 and 15, where the receding rate decays despite a nearly constant target's receding speed: it should be taken into consideration that, due to the logarithmic nature of the relation between pathloss and distance, the larger the distance is, the larger the target's receding speed must be to sustain the ratio calculated in Equation ( 7).This can be seen if we compute the difference between two consecutive RSSI values applying Equation (4) to calculate distances.Using the same fitting parameters as those applied in the first validation experiment, 1 dbm of difference applied to −19 dbm (from −19 to −20) is equivalent to 0.12 m.However, the same difference applied to −52 dbm is equivalent to 6.54 m.For this reason, Equation ( 7) could be less sensitive at larger distances than nearer distances.

Conclusions
In this paper, a relative distance estimator for 802.145.4 nodes in open field is proposed, based on the log-normal propagation model and RSSI.Log-normal model was chosen for its simplicity and easiness to fit parameters.To reduce the white noise in signal strength measurements, a Kalman filter was applied successfully.To test the estimator, a computer application was implemented based on this propagation model that draws the location of the target within a map.In addition, three data gathering campaigns were carried out to fit the propagation model against several scenarios.As presented in Section 3, the log-normal model is quite inaccurate and very dependent on the environmental conditions to provide reliable distance measurements.Given the high variability of environmental and antenna conditions, two solutions are proposed to achieve better results.
The first solution is to implement an estimator providing a range of distances, based on standard deviation of RSSI measurements.This solution was tested against with two validation experiments without improving prior results due to the high dependency of the log-normal model on environmental conditions.The second one is to implement a relative distance estimator on which the estimator only provides information about the target if getting closer or moving away.For this solution, the log-normal model is ignored and an abrupt proximity function is developed to evaluate the approaching of the target.After this function, a double exponential filtering stage is implemented to smooth the function's output and give a more stable and consistent result to the software application.The relative distance estimator was tested against both validation experiments and it showed better and much more robust results than the absolute distance estimator using the log-normal propagation model.Funding: This research was funded by the excellence project from Andalusia Council MINERVA (P12-TIC-1300).

Figure 4 .
Figure 4. Standard deviations (dbm) for three similar scenarios at different distances (m).

Figure 6 .
Figure 6.Front (a) and back (b) view of the Antenova Asper 2.4G/GNSS Antenna and the collar PCB, showing the SD card slot and the XBee.

Figure 8 .
Figure 8. Scheme of the system that was used to perform the characterization experiments.MN, mobile node; S, sniffer; C, collar; X, XBee coordinator.MN-S and C-X were placed on top of tripods (160 cm height).Both tripods were distance meters away from each other, depending on the experiment.

Figure 9 .
Figure 9. Scheme of the system that was used to perform the validation experiments.MN, mobile nod; S, sniffer; C, collar; X, XBee coordinator.MN-S-X were placed on top of a tripod (160 cm height).The collar was moving away from MN-S-X during the experiments.

Figure 11 .
Figure 11.Distance calculation using the log-normal model.Dashed: expected distance.

Figure 12 .
Figure 12.Distance calculation using log-normal model with range of distance estimations.

Figure 13 .
Figure 13.Relative distance calculation obtained from the first validation experiment.

Figure 14 .
Figure 14.Filtering pathloss from the data collected from the second validation experiment.

Figure 15 .
Figure 15.Relative distance calculation obtained from the second validation experiment.

Table 4 .
Log-normal model's parameters for three different scenarios.