1 Introduction

The advent of the concept of smart dust has ushered in a new era in wireless sensor network research [1]. For example, the application fields have expanded beyond defense and military elements to current environmental monitoring, medical rescue, forest fire control, and other disciplines. The sensor nodes may establish an organization network within a specific range by human propagation, and the surrounding information is sensed and monitored. It is crucial to find the node before gathering the data around it, as positioning without the accompanying nodes will be useless [2]. Range-based positioning algorithms and range-free positioning algorithms are the two broad groups of sensor node positioning methods [3]. The time of arrival (TOA) algorithm [4], time difference of arrival (TDOA) algorithm [5], angle of arrival (AOA) algorithm [6], and received signal strength indication (RSSI) algorithm [7] are the four algorithms that make up the range-based positioning algorithm. The centroid algorithm [8], distance vector-hop (DV-Hop) algorithm [9], the amorphous algorithm [10], and approximation point-in-triangulation test (APIT) algorithm [11] are the most used range-free positioning techniques.

Since the range-free positioning algorithm does not need to calculate the relative distance or angle as precisely as the range-based positioning algorithm, it requires less hardware and has lower communication costs, making it more feasible for practical applications. The improved triangle centroid localization algorithm based on RSSI is investigated in this paper, which covers two aspects of positioning accuracy and response speed. Because noise, multipath effect, diffraction, temperature, and other factors in surrounding environment can readily impact the wireless signal, the data error acquired by RSSI is high.

The approaches employed at home and abroad to lessen the error generated by the positioning process are mostly based on two aspects. The first approach is to improve the wireless signal's transmission loss model and create a more realistic model; the second way is to improve the positioning algorithm to eliminate mistakes. The current study focuses mostly on refining the positioning algorithm.

The domestic and international literature have investigated traditional RSSI positioning algorithm in order to address the limitations of this method, such as adding the existence probability function [12], measuring error observer [13] or data mapping [14], and using Wi-Fi signal instead of the original anti-interference ability weak signal [15], etc. The improved RSSI positioning algorithm's positioning accuracy has been substantially improved thanks to the approaches described above. In addition, the RSSI positioning algorithm can be integrated with other algorithms to reduce positioning errors, such as iterative calculation [16], weighted centroid algorithms [17, 18].

From the perspective of research algorithm optimization, Ding et al. [19] present the maximum and minimum method and the maximum likelihood estimation method to solve the low RSSI positioning accuracy based on the actual distance between the beacon node and the unknown node being within 10 m, and the final positioning error being within 3 m. It can be seen that the above suggested algorithm still has a significant flaw. Shi et al. [20] provide a tri-partition RSSI classification and RSSI filter based on its tracing technique, this method is suitable for improving the RSSI algorithm’s stability and decreasing the effect on the surrounding environment.

From the application point of view, it can be applied to the RSSI measurement of smartphones [21]. Furthermore, Bae et al. [22] provide a robust ranging approach based on RSSI which can be applied in robotics and IoT, with the goal of determining the position of mobile nodes. The RSSI algorithm is inextricably linked to indoor environment as well. A sensor fusion framework for indoor positioning by using the smartphone inertial measurement unit (IMU) sensor data is proposed [23], and the suggested framework is more suitable to inside setting. One of the most often utilized algorithms for indoor positioning is fingerprint matching. Poulose et al. [24] compare four fingerprint matching algorithms for Wi-Fi RSSI signals: closest neighbor, k-nearest neighbors, weight k-nearest neighbor, and Bayesian fingerprint matching technique. What’s more, Sun et al. [25] provide a novel distance metric to investigate the assiciation between the RSSI distance and the indoor distance. The recurrent neural network is proposed by Hoang et al. [26], and the positioning technique paired with deep learning can locate a succession of positions. This strategy, however, necessitates gathering the RSSI data of a large number of different beacons in various places in preparation. It's possible that the RSSI values for some places aren't in the database.

From the perspective of information theory, Zhou et al. [27] investigate the Cramer-Rao Lower Bound (CRLB). These papers only provide a qualitative analysis of accuracy and do not take response time into account. Futhermore, such an approach as the fingerprint positioning algorithm has a number of prerequisites. More crucially, this work not only examines the method from the Matlab simulation, but also conducts a hardware platform verification experiment. As a result, the response speed must be considered in real systems.

From the perspective of improving accuracy and response time, the improved triangular centroid localization algorithm based on RSSI (ITCL-PIT) is studied in paper. The ITCL-PIT method interprets the calculated intersection coordinates and builds new beacon node to gradually reduce the triangle area in the intersecting region. Then, the PIT criteria is utilized to determine whether the unknown node is located inside triangle area. Finally, the centroid technique is used to determine the coordinates of an unknown node. Compared with the traditional triangle centroid localization algorithm, the ITCL-PIT algorithm delivers a higher level of positioning accuracy based on the guaranteed response time. What’s more, the positioning accuracy is also improved compared to the centroid iterative estimation positioning algorithm. The complete abbreviations of important terms are given in Table 1. The contributions in this paper can be summarized as follows.

  1. 1.

    We present an improved triangle centroid localization algorithm based on PIT criterion(ITCL-PIT) in this paper. It was discovered that the ITCL-PIT method, when compared to the triangle centroid localization technique, can improve localization accuracy by up to five times, depending on the promised response time.Futhermore, the ITCL-PIT algorithm outperforms the centroid iterative estimation algorithm in term of positioning accuracy and response speed. As a result, the ITCL-PIT algorithm has a higher overall performance.

  2. 2.

    We also use the ESP07 module to build the hardware experimental platform to test the traditional triangle centroid localization algorithm, centroid iterative estimation algorithm and the suggested algorithm. According to the test result, the positioning errors of the proposed ITCL-PIT algorithm is fewer than the errors of the other two positioning algorithms, with a positioning error of 1.42 cm.

Table 1 Summary of important acronyms

The reminders of the paper are organized as follows: Sect. 2 describes the calculation method of the calculation method and communication model. Section 3 describes the triangular centroid localization algorithm. Section 4 describes the core idea of the ITCL-PIT algorithm. Section 5 evaluates the performance of ITCL-PIT algorithm compared with the existing positioning algorithm. Finally, the conclusion and future directions are drawn in Sect. 6.

2 Communication model and calculation method

The RSSI is mainly dependent on the signal loss strength to quantify the distance between transmission and reception. Based on RSSI measurements, the empirical and theoretical signal propagation nodels are widely utilized. The empirical model is based on the establishment of an offline database that compares received signal intensity to real time location to obtain the corresponding coordinates. Since the acquired data may not match the corresponding location in the database, the database requires sufficient data to reduce mistakes. The theoretical models commonly include the following: the free space propagation model, the two-ray ground model and the shadowing model. The free space propagation model is susceptible to obstructions and has an excessively high fading rate. The two-ray ground model is more complicated and unsuitable for short-range signal transmission. Compared with the above two models, the shadowing model has less restricted conditions, is easy to implement and is more realistic. More significantly, this model is adopted in most algorithms. Hence, the shadowing model [5, 10, 20] is employed in this experiment, which can be expressed as the following formula.

$$P_{L} (d) = P_{L} (d_{0} ) - 10\eta \log \left( {\frac{d}{{d_{0} }}} \right) + X_{\sigma }$$
(1)

where \(P_{L} (d)\) represents received signal strength; \(P_{L} (d_{{0}} )\) represents the signal strength when the transmitting end and the receiving end are separated by 1 m, its value range is generally 45–49; \(\eta\) represents environmental attenuation factor; \(d\) represents the calculated distance between the transmitting end and the receiving end; \(X_{\sigma }\) represents zero mean Gaussian random variable. The loss RSSI value can be converted to the distance by the above path loss formula (1).

3 Triangular centroid localization algorithm

Based on the communication model, it is considered that the calculated received signal strength and the actual situation are vastly different. The coordinates of unknown node \(D\) can be correctly obtained by calculating the distance \(d_{a}^{*} ,d_{b}^{*} ,d_{c}^{*}\) between the beacon node \(A,B,C\) and the unknown nodes \(D\) in an ideal case, which can also be used as the radius of the circle \(A,B,C\), and the resulting three circles have only one point of intersection.

The ideal model is shown in Fig. 1a, the RSSI-based triangle centroid localization algorithm can be represented as follows. Set the coordinates of beacon nodes \(A,B,C\) are \((x_{a} ,y_{a} )\)\((x_{b} ,y_{b} )\)\((x_{c} ,y_{c} )\), the coordinate of unknown node \(D\) is \((x_{d} ,y_{d} )\). The following equation may be obtained using the distance calculation formula, as illustrated in Eq. (2).

$$\left\{ {\begin{array}{*{20}l} {\sqrt {(x_{a} - x_{d} )^{2} + (y_{a} - y_{d} )^{2} } = d_{a}^{*} } \hfill \\ {\sqrt {(x_{b} - x_{d} )^{2} + (y_{b} - y_{d} )^{2} } = d_{b}^{*} } \hfill \\ {\sqrt {(x{}_{c} - x_{d} )^{2} + (y_{c} - y_{d} )^{2} } = d_{c}^{*} } \hfill \\ \end{array} } \right.$$
(2)
Fig. 1
figure 1

Ideal model (a) and actual model (b). Thess figures depict how to determine the distance between the beacon node and the unknown node under ideal model and actual model

According to Eq. (2), Eq. (3) can be simplified as follow.

$$\left[ {\begin{array}{*{20}l} {x_{d} } \hfill \\ {y_{d} } \hfill \\ \end{array} } \right] = \left[ {\begin{array}{*{20}l} {2(x_{a} - x_{c} )} \hfill & {2(y_{a} - y_{c} )} \hfill \\ {2(x_{b} - x_{c} )} \hfill & {2(y_{b} - y_{c} )} \hfill \\ \end{array} } \right]\left[ {\begin{array}{*{20}l} {x_{a}^{2} - x_{c}^{2} + y_{a}^{2} - y_{c}^{2} + d_{c}^{*2} - d_{a}^{*2} } \hfill \\ {x_{b}^{2} - x_{c}^{2} + y_{b}^{2} - y_{c}^{2} + d_{c}^{*2} - d_{b}^{*2} } \hfill \\ \end{array} } \right]$$
(3)

The coordinates of unknown node D can be calculated by the Eq. (3).

The actual situation is depicted in Fig. 1b, where the RSSI is susceptible to multi-path attenuation and non-line of sight, resulting in a theoretical distance \(d\) between the converted beacon node and the unknown node, which is larger than actual distance \(d^{*}\) [28], so that three intersection \(E,F,G\) of three circles, which constitute the triangle in the overlapping area \(\Delta EFG\). The unknown node D’s coordinate is determined using the triangle’s centroid. Set that the coordinate of intersection point \(E\) is \((x_{e} ,y_{e} )\), the following inequation can be obtained with the coordinates of the known beacon nodes \(A,B,C\).

$$\left\{ {\begin{array}{*{20}l} {\sqrt {(x_{a} - x_{e} )^{2} + (y_{a} - y_{e} )^{2} } \le d_{a} } \hfill \\ {\sqrt {(x_{b} - x_{e} )^{2} + (y_{b} - y_{e} )^{2} } = d_{b} } \hfill \\ {\sqrt {(x{}_{c} - x_{e} )^{2} + (y_{c} - y_{e} )^{2} } = d_{c} } \hfill \\ \end{array} } \right.$$
(4)

According to inequation (4), the coordinate of intersection point \(E\) \((x_{{\text{e}}} ,y_{{\text{e}}} )\) can be computed. Similarly, the coordinates of the other two intersecting points \(F,G\) can be determined, and according to centroid formula, the coordinate of the unknown node \(D\) can be represented by \((\frac{{x_{e} + x_{f} + x_{g} }}{3},\frac{{y_{e} + y_{f} + y_{g} }}{3})\).

4 Methodology

4.1 The establishment of New Beacon node

According to the above traditional RSSI-based triangle centroid localization algorithm, the ITCL-PIT algorithm is proposed in this paper. As can be seen from Fig. 1b, \(E,F,G\) are the intersection coordinates of three circles obtained by taking the beacon node \(A,B,C\) as the center and \(d_{a} ,d_{b} ,d_{c}\) as the radius into account. As shown in Fig. 2, the intersection coordinates \(E,F,G\) (denoted by red dots) are regraded as the new beacon node whose radius is the distance between the intersection coordinates \(E,F,G\) and the unknown node \(D\)(calculated using the path loss formula (1)), allowing the intersection coordinates \(E,F,G\) (represented by blue dots) to be retrieved using the formula (5).

$$\left\{ {\begin{array}{*{20}l} {\sqrt {(x_{e} - x_{e1} )^{2} + (y_{e} - y_{e1} )^{2} } \le d_{e} } \hfill \\ {\sqrt {(x_{f} - x_{e1} )^{2} + (y_{f} - y_{e1} )^{2} } = d_{f} } \hfill \\ {\sqrt {(x{}_{g} - x_{e1} )^{2} + (y_{g} - y_{e1} )^{2} } = d_{g} } \hfill \\ \end{array} } \right.$$
(5)
Fig. 2
figure 2

The improved triangle centroid localization algorithm (ITCL-PIT) model. This figure shows how to calculate the coordinate of the unknown node under the improved triangle centroid localization algorithm

Set the coordinate of intersection point \(E^{{\prime }}\) is \((x_{{{\text{e1}}}} ,y_{{{\text{e1}}}} )\),which can be calculated by formula (5). Similarly, the coordinates of the intersection point \(F^{{\prime }} ,G^{{\prime }}\) can also be derived. According to above repeated computation procedure, the coordinates of three intersection points \(E^{(n)} ,F^{(n)} ,G^{(n)}\) generated by the nth iteration can be obtained.

4.2 Centroid calculation iteration criterion

According to the improved triangle centroid localization algorithm, it can be known that the size of the intersecting region triangle shrinks as new beacon nodes are established. The basis for establishing the new beacon node is that unknown node \(D\) needs be located within the triangle. Most of the current centroid algorithm termination criterion set the threshold until the condition is fullfilled to tackle this problem, although applying this type of criterion will result in less precise optimization. In this paper, based on the complexity and positioning error, the PIT criterion in the APIT algorithm can be used as the iterative exit criterion [11]. Compared with other criteria, the PIT criterion is simple, and the positioning accuracy is relatively high, with a low test error rate. Moreover, the movement of unknown nodes in the PIT criteria can be mimicked by exchanging information with adjacent nodes. As a result, when a new triangle is generated, the judgment is based on the fact that a new beacon node is no longer established when the unknown node \(D\) is not within the triangle.

The detailed description of the PIT criterion is shown in Fig. 3. It is assumed that there are beacon nodes A, B, C and unknown node \(D\). When the unknown node \(D\) has no neighbor nodes close to or far away from the beacon nodes A, B, C at the same time, it can be found that the unknown node \(D\) locates within the triangle. Futher, if a neighbor node is close to or away from beacon node A, B, C simultaneously, it is judged that the unknown node is outside the triangle. Hence, it can be combined with the improved positioning model in Fig. 2 to determine whether the unknown node \(D\) is within the triangle. Moreover, due to the irregular placement of neighbor nodes, it may lead to judgment errors. The probability of arising of this situation is extremely low which is verified through experiments, and thus is ignored in this experiment.

Fig. 3
figure 3

The schematic diagram of the PIT criterion. This figure shows how to judge whether the node is located within the triangle

5 Results and discussion

5.1 Theoretical analysis of positioning error

In the experiment, the positioning error is defined as Localization_error. If the coordinates of the unknown node is \((x_{{e{\text{st}}}} ,y_{{e{\text{st}}}} )\), and the true coordinate is \((x_{{{\text{true}}}} ,y_{{{\text{true}}}} )\), the distance is represented as follow.

$${\text{Localization\_}}error = \sqrt {(x_{est} - x_{true} )^{2} + (y_{est} - y{}_{true})^{2} }$$
(6)

Since all nodes are randomly distributed in simulation when other factors such as the communication radius are the same, the following two situations may generally be considered: there is no positioning error in the beacon node itself and a slight error in the beacon node itself. Figure 4a shows the case where an unknown node is located when there is no positioning error in the beacon node. When the inaccuracy of the specified beacon node is 2 m, Fig. 4b displays the position of an unknown node. Additionally, as the error increases, the positioning error becomes more obvious, and this mistake is usually only reflected when the node is deployed in a hilly terrain or where the signal is poor. All in all, the positioning error of the beacon node itself is not considered in this simulation.

Fig. 4
figure 4

No error in the beacon noded (a) and 2 m error in the beacon nodes (b). These figures describe the situation when there are errors and no errors in the beacon node

Considering that the communication radius of the beacon node is 20 m, Fig. 5a indicates that the unknown nodes which have been located are regarded as the beacon node of other unknown nodes. Figure 5b shows beacon nodes are employed for positioning when beacon nodes exist around the unknown node. If no beacon node is present, the previously located unknown node is utilized to assist positioning. As the unknown nodes calculated may include errors, the existing beacon nodes around can be used to mitigate the inaccuracies as much as feasible. Overall, when the unknown node contains the neighbor beacon nodes, the neighbor beacon nodes are considered in this experiment. Otherwise, the located unknown node is used to assist the positioning.

Fig. 5
figure 5

Use unknown nodes positioning when neighbor nodes exist (a) and don’t use unknown nodes positioning when neighbor nodes exist (b). The figures depict how to find the neighbor nodes

5.2 Algorithm steps

  1. 1.

    The nodes are randomly distributed in a certain region. After receiving the information (ID of beacon nodes), the unknown node averages the RSSI of the same beacon node;

  2. 2.

    After the unknown node collects the information, the beacon nodes are filtered according to the strength of their RSSI, and the three beacon nodes with the largest RSSI value are selected as the calculation foundation;

  3. 3.

    For the set of beacon nodes, the coordinates of three intersection points are calculated in turn;

  4. 4.

    The PIT algorithm is used to determine whether the unknown node is within the triangle of the intersecting region. If the unknown node is within the triangle, the three intersection coordinates are taken as the new beacon nodes. The area of the triangle is decreased, and then it is judged whether the unknown node is within the smaller triangle’s region. The calculation is paused until the unknown node is not within the triangle of the intersecting region;

  5. 5.

    When the unknown node repeatedly judges that it is not in the intersecting region, the coordinates of the three intersection points are forced to halt computation, and the coordinate of the unknown node is obtained by the centroid algorithm.

5.3 Software simulation

The ITCL-PIT algorithm is optimized using MATLAB simulation software in experiment. During the simulation process, the distance estimation to each beacon (PL(d)) was derived from the regular model. The simulation parameters are listed in Table 2. The simulation results are depicted in Fig. 6. Due to the random distribution of all nodes, there may be no neighbor beacon nodes surrounding a few unknown nodes. Therefore, a small number of unknown nodes cannot be located through the beacon node or assisted by the already-discovered unknown node.

Table 2 Simulation parameters
Fig. 6
figure 6

Distribution of beacon nodes and unknown nodes. This figure shows the distribution of all nodes

From the aspects of positioning error and response speed, traditional triangle centroid localization algorithm, centroid iterative estimation localization algorithm [14] and ITCL-PIT algorithm are compared and analyzed in Fig. 7.

Fig. 7
figure 7

The comparison of the localization error (a) and response time (b). a Describes the relationship between communication range and localization error; b reveals the relationship between response time and communication range

Figure 7a demonstrates that as the communication distance grows, so do the positioning errors of the three positioning algorithms. The positioning errors of the ITCL-PIT technique and centroid iterative estimate localization algorithm, however, are much lower when compared to the standard triangular centroid localization algorithm. When the communication distance is 0–15 m, the positioning accuracy of the centroid iterative estimation localization algorithm is slightly higher than the ITCL-PIT algorithm, and the accuracy of its improvement is basically unchanged. When the communication distance is 15–30 m, the ITCL-PIT algorithm has higher positioning accuracy than the centroid iterative estimation localization algorithm, and the accuracy is increased by about 50%. It is indicated that the centroid iterative estimation localization algorithm will reduce the positioning accuracy when there are more beacon nodes, and the ITCL-PIT algorithm maintains a relatively gentle error growth rate.

As shown in Fig. 7b, the response time differences between the conventional triangular centroid localization algorithm, the centroid iterative estimation localization algorithm and the ITCL-PIT algorithm are also considered. The response time of the three algorithms increases with the increase of communication distance, and the conventional triangular centroid localization algorithm has the fastest response speed, because this algorithm only applys a few iterations. In addition, considering the response time of the centroid iterative estimation localization algorithm and the ITCL-PIT algorithm, since the number of beacon nodes is large, the centroid iterative estimation algorithm requires more time to select an appropriate beacon node. Therefore, the response time is substantially longer than the ITCL-PIT algorithm in larger communication range, and the response time of the ITCL-PIT algorithm is roughly reduced by 17%.

Based on Fig. 7a, b, it can be known that the positioning accuracy of the ITCL-PIT algorithm is greatly improved by increasing the response time, and the algorithm has certain feasibility and practicability.

5.4 Complexity analysis

Figure 7b further demonstrates that the conventional triangle centroid localization algorithm has the fastest response time due to the few iterations. As a result, it can roughly obtain the tradtional triangle centroid localization algorithm has the lowest complexity compared with the other two algorithms.

First, the three different positioning algorithms need to calculate the position of the new beacon node at the first stage, and the computational complexity is O(n^3). In the second stage, the traditional triangle centroid localization algorithm needs to use the PIT criteria to obtain the location of the unknown node, and the corresponding computational complexity is O(mlogn). On the other hand, the centroid iterative estimate localization algorithm and the ITCL-PIT algorithm both need to experience multiple iteration to compute the position of the unknown node using the PIT criteria, with the corresponding computational complexity is O(mlogn) + O(n^3), O(mlogn) + O(n^2logn), respectively.

Additionaly, it is should be noted that the convergence speed of the centroid iterative estimation algorithm will slow down when the communication range between node grow, resulting in a bigger variance at centroid prediction point. Because it is connected to the shrinking area, the convergence speed of the PIT criteria has been growing slowly with the rise in communication range. All in all, the analysis results of the complexity are roughly consistent with the simulation results obtained in Fig. 7b.

5.5 Hardware simulation

The above simulation results of the positioning accuracy and response time are analyzed in detail. In addition, an experimental platform was built to verify the advantages of the ITCL-PIT algorithm in actual scenario when compared with other algorithms. The schematic diagram of the test location is shown in Fig. 8. In this experimental platform, four ESP07 modules are selected as sensor nodes, three of which were utilized as beacon nodes, and the remaining one was employed as an unknown node. The ESP07 modules are used to evaluate three different algorithms with five distinct pieces of data. The origin of the measuring area is (0,0), and the results are depicted in Table 3.

Fig. 8
figure 8

The schematic diagram of the test scenario. This figure shows the test area and the location of the experimental nodes

Table 3 Experimental result in test scenario

The positioning errors are measured in the experimental platform under the three algorithms: the triangle centroid algorithm, the centroid iterative estimation algorithm and the ITCL-PIT algorithm respectively. According to results in Table 3, the traditional triangle centroid positioning algorithm has the biggest positioning error when compared to the other two algorithms, with an inaccuracy of 3.86 cm. Futhermore, the tested statistics indicates that the ITCL-PIT algorithm has the smallest positioning error, which is only 1.5 cm. Due to the lack of condition and equipment, only positioning error was tested in the experimental platform, and the response time of various algorithms was not tested on the paper.

6 Conclusion and future work

Considering the two aspects of positioning accuracy and response speed, an improved triangle centroid localization algorithm based on PIT criterion (ITCL-PIT) is proposed in paper. The ITCL-PIT algorithm reduces the area of overlap region by generating new beacon nodes and applies the PIT criterion of the APIT algorithm as the foundation for the judging unknown nodes. At last, the coordinate of the unknown node is calculated by the centroid algorithm. The simulation results demonstrate that the ITCL-PIT algorithm improves the positioning accuracy by 6 times on the basis of double response time compared with the traditional triangular centroid localization algorithm. Additionally, the ITCL-PIT algorithm outperforms the centroid iterative estimation algorithm in terms of localization accuracy and response speed. Moreover, the model is closer to the actual positioning situation by analyzing the error of the beacon node itself and the judgment of the neighbor beacon node.

Since the ESP07 module is used in the experimental test platform which its price is low, and the positioning function can be accomplished, and the difference in response time between algorithms may be negligible, but it still needs to be verified in kind. However, when the algorithm selects the new beacon nodes, the error of the new beacon nodes are ignored. The following stage is to think about how to lessen the error. Furthermore, the time complexity and the space complexity can also be used as the research object of the following topic. At the same time, in addition to the research of algorithms on a two-dimensional plane, it can be considered whether the algorithm also has an efficient positioning function in the three-dimensional space [29]. In the future, the visble light positioning is a promising the research direction [30].