LoRa communication and geolocation system for sensors network

The Internet of Things (IoT) has developed tremendously over the past few years and has proven its worth in many areas of activity. With regard to environmental air quality monitoring, there are more and more products and applications that try to gather as much data as possible about all the pollution factors in a given area. This paper aims to present a new method of using devices capable of communicating with each other using the LoRa communication protocol to report to a real-time central server on environmental air quality. The innovation of this paper is the fact that it is implemented using a developed LoRa localization protocol, which connects an air quality sensor network, using only the low power of the LoRa technology by applying a multilayer algorithm to the gateway timestamps from received packages. The so created LoRaWAN tracking system is able to exploit transmitted packets to calculate the current position without using GPS or GSM that are high power consumers.


Introduction
The concepts of smart cities and intelligent communities have become a reality in this age of the Internet of Things (IoT). In the midst of this IoT revolution, low-power networking (LPWAN) technologies have become very popular as they greatly match IOT traffic generated and consumed by many intelligent cities' applications [1]. For example, if we think of urban-scale IoT applications such as intelligent metering, environmental monitoring, road traffic monitoring, facility management, smart parking, street lighting, vehicle tracking, waste management, precision farming, and house automation, a base of communication in these applications includes a long range of radio frequencies (i.e. several hundred meters of field), low power (i.e. extended battery life reaching to several months or years) and reduced bandwidth (i.e. a rate of a few kbps data) [2]. Thus, low-power WANs are considered to be urban decision makers of IoT. Among the various low-power WAN options, we study one of today's most popular technologies, called LoRa WAN [3]. LoRa has so far been adopted by European countries, although recently over 100 US cities have begun to implement LoRa networks at city level [3]. LoRa has a radio range of up to 14 km (in line), a transfer rate of up to 50kbps and a battery lifetime of about 10 years. Although LoRa is considered for outdoor applications, its properties can also be leveraged for indoor scenarios. Because LoRa operates in the sub-GHz band, it gains more penetration, making it more noise-resistant and multipath. This property makes LoRa a better choice for indoor use. Recently, for the use in large installations (e.g. multi-storey buildings, large warehouses), multiple access points must be installed due to the short range of the traditional RF signals, like WiFi, Bluetooth Low Energy (BLE). However, due to the long beam of the LoRa device, a smaller number of access points or nodes can perform similar operations. In this paper we study the performance and perspective of LoRa in the inner location. It has been noticed that LoRa is more stable than WiFi and BLE and is more resilient to environmental changes. By integrating technological advances into buildings, a significant amount of information can be given to those who live to improve their experience [4].

Matematical model of trilateration
It has been imperative for many centuries to locate our position on the surface of the earth. Many centuries ago, the navigators used the position of the stars and landmarks to find the right destination. Even in our days there are not enormous modifications among navigation procedures, only stars and landmarks were changed with satellites and cell towers. It is obvious therefore that it is very important to be able to give the exact location of certain devices. There are multiple reasons, such us commercial, scientific or military ones [5]. The development of navigation systems has provided several mathematical tasks, starting with celestial observation, spherical trigonometry and paper and pen calculation [6]. In the last eight decades electronic navigation has advanced from the using of fixed, land-based, radio transmitters to Long Range systems, which use sequenced chains of transmitters [7]. Nowadays, we can obtain the two-or three-dimensional position of one point in many different ways, such us triangulation, trilateration, multilateration. In order to locate a device, there is crucial to have some points of reference with identified locations known as anchor points [8].
Triangulation is based on the trigonometrical fact that if it is known one side (baseline) and two angles of a triangle are known (α and β in figure 1), the other two sides can be computed. In triangulation, the location of a device can be estimated using the geometry of the triangle that is formed with two anchor points (AP1, AP2) and the device [9]. The geometry of the triangle can be calculated using the Angle of Arrival (AoA) of a transmission from the anchors to the device, or vice versa (α and β in figure 1).
However, using AoA measurements is not suitable for LoRa's long range because more errors appear as the device is further away from the anchor points.
Another method for localization is Trilateration. Trilateration uses the gap between the device and the anchor points. Trilateration needs the distance between the device and the anchor points, which can be obtained from the time of arrival (ToA), the time of flight (ToF) or from the received signal strength indicator (RSSI). Consequently, a synchronization between the anchor points and the device, as well between the receiver and the transmitter is necessary. Figure 2 shows that the position of the device is the intersection of the three circles obtained from the different distances (R1, R2 and R3). In order to get these distances, we have to use the velocity formula: Ri=v ti , where v is the speed of light, sound or radio signals, and ti is the time of arrival.

Fig.2. Trilateration
The trilateration calculations could estimate the coordinates of the device using the coordinates (longitude, latitude) of nearby cell towers or satellites (AP1, AP2 and AP3), as well as the estimated distance of the device from the cell towers (e.g. either based on signal strength or by measuring the time delay that a signal takes to return back to the towers from the phone). The mathematical equations that are used in trilateration calculations are based on the equation of a circle [10]. The model described in figure 2 is a 2D model, based on (x,y) coordinates (or longitude/latitude coordinates). The coordinates of the anchor points are APi (xi, yi), i = 1, 2 or 3 and the device has the coordinates D (x, y). In figure 2, each circle represents all the possible locations of the device at a given distance (radius) of an anchor point. The aim of a trilateration algorithm is to calculate the (x,y) coordinates of the intersection point of the three circles. Each circle is defined by the coordinates of its center, APi and its radius Ri. From the three equations of the three circles (2) we obtain other three relations (3) after expanding out the squares in each of the equations [8]: x − 2xx + x + y − 2yy + y = R (3) For i=1 and i=2, we subtract the two equations and we get: (−2x + 2x )x + (−2y + 2y )y = R − R − x + x − y + y (4) Likewise, we subtract the third equation from the second (i=2 and i=3): (−2x + 2x )x + (−2y + 2y )y = R − R − x + x − y + y (5) The last two equations (4 and 5) represent a system of two linear equations, that can be written in a simplified form: ax + by = c and dx + ey = f (6) Or: There is a solution only if ae-bd≠0, and the solution of this system is: x = and y = (8) In the above relation (8), a = −2x + 2x ; b = −2y + 2y ; d = −2x + 2x ; e = −2y + 2y ; c = R − R − x + x − y + y ; f = R − R − x + x − y + y (9) In order to have exact values for Ri the time of transmission has to be known (ToA method), requiring the synchronization between the device and the network in order to use a specific clock. It is simply the problem of finding the intersection of three circles in the 2D case or the intersection of three spheres in the 3D case, where a system of quadratic, i.e. nonlinear, equations is involved. An exact solution is not easy to obtain. However, many algebraic and numerical solutions are available in the open literature for the 2D and 3D [10] cases respectively. These approaches involve complex geometric computations [5,7], which usually require a relatively long execution time and, thus, are not suitable for low-cost applications with constrained power and computational resources. In conclusion, finding the location of a device implies the problem of finding the coordinates of the intersection of three circles in the 2D case or the intersection of three spheres in the 3D case, where a system of quadratic equations is involved (2). An exact solution is not easy to obtain, sometimes a relatively long execution time is required and, therefore, is not suitable for low-cost applications with constrained power and computational resources [10]. This method demands precise instruments, not battery-powered gadgets. The multilateration principle is similar to trilateration, except that there are no longer circles or spheres. The main feature to compute the location is the time difference of arrival (TDoA). Using a device that receives signals from two synchronized transmitters, it is possible to measure the difference between the arrival times (TDoA) of the two signals at the receiver [6]. The device is located on a hyperbola (2D) or a hyperboloid (3D), more accurate is the intersection of at least two hyperbolas (three antennas required). The tracking system did not have synchronization with the end-node, only the gateways were synchronized with each other. Therefore, the only available information is the time when the packet is received by each gateway. Usually, there are necessary four transmitters to enable the receiver to calculate its position accurately. Hyperbolic multilateration (TDoA positioning) method is most commonly used for Automatic Source/ Object Location. Estimation of the hyperbolic place is done in two stages. The first phase includes estimating the time difference of arrival (TDoA) between recipients. The TDoAs are then changed into range difference estimations between base stations. This stage uses proficient calculations to create an unambiguous answer for these nonlinear hyperbolic conditions [7]. The solutions of these calculations show the targeted position area of the source. A noteworthy benefit of this strategy is that it does not require knowing the transmitting time from the source, as does the Time of Arrival (ToA) technique [11].
Therefore, an exact clock synchronization between the source and receiver is not compulsory. Accordingly, hyperbolic position location methods do not require extra equipment or programming execution. But clock synchronization is essential for all of the receivers. In order to be more specific, here is the mathematical background of this method [5]. The device transmits a LoRa signal which is received by n gateways (n≥2). These gateways are the anchor points, since their location is known. Each gateway is at a different distance from the device, so they will receive the transmission at a different time. For each pair of gateways there will be only one measurement. The total number of possible pairs for two gateways is one, for three gateways is 3. For each of these gateway pairs, the TDoA is tij = ti-tj, where ti and tj are the timestamps for gateways i and j. The distance that is calculated from the TDoA measurement will be referred to as the TDoA distance, which is calculated using the formula dij = c tij where c is the speed of light through air. Using this measurement, it is possible to draw the hyperbola consisting of all the possible points of where the device could be. To compute the hyperbola, we assume that the two gateways in a pair are situated on the xaxis, equidistant from the y-axis. The distance between the two gateways is d. Therefore, the coordinates of the gateways (anchor points) are (d/2, 0) and (-d/2, 0). The hyperbola is represented by all the possible points (x; y) calculated with the equation (10): where Δd is the difference in distance calculated from the TDoA measurement. The next formula is the asymptote of the hyperbola, for x >>Δd 2 /4 and y >> (d 2 -Δd 2 )/4: The (x,y) coordinates used for drawing the hyperbola are only local coordinates that are specific to this pair of gateways, AP1 and AP2.
The coordinates need to be mapped onto the 2D representation of the Earth, in order to get the global coordinates [5]. Only then can each hyperbola be linked to one another. Converting from local coordinates to global coordinates simply involves a rotation and then a translation of the two-dimensional plane. This is expressed as follows [5]: Where (x,y) are the local coordinates of the point, (X0, Y0) are the coordinates of the midpoint of the segment AP1AP2, and α represents the angle formed between the line determined by the two gateways and the global x-axis. Using (12), it is easy to represent the hyperbolic function of a TDoA measurement in global coordinates. An example is shown in figure 4. In LoRa the most suitable way to locate a position is using the Hyperbolic Multilateration method, since is not known the time t=0 s and the times of arrival (ToA) to each gateway are not known. The LoRa Network server offers the time difference of arrival (TDoA) between every pair of gateways [12]. Therefore, as a replacement for drawing circles to triangulate, we have to draw hyperbolic curves with the two focus points in each pair of gateways. The calculation is done in the LoRa Network server, not in the node [13]. Some advantages of Hyperbolic Multilateration method are the low user equipage cost taking into account, that for navigation, only one receiver is necessary with a simple clock; the method avoids the 'turn-around' error and the use of the large antennas which are needed for measuring angles; the number of users is unlimited in navigation; the method is viable over great distances [14]. The disadvantages of the method are the number of the stations and the fact that the method requires one extra station than a system based on true ranges and often two more than a system that measures range and azimuth. Moreover, the stations must almost surround the service area, be synchronized, and may require power and communications where not available [11].

Conclusion
LoRa is a long-range, low-power telecommunication system for the "Internet of Things". The physical layer uses the LoRa, a proprietary technology with a MAC protocol. LoRaWAN is an open standard with the specifications available for free. This paper presents the mathematical model of the principle of locating a LoRa device without using the GPS tracking system. Using the mathematical model of the localization method presented in the paper, LoRaWAN can be used for positioning inside the building as LoRa labels. Similar to specialized location nodes, LoRa tags work with a server-based approach and send and receive signals. Beacons are small transmitters that can only send simple signals to neighboring devices. Typically, beacons are placed inside the building and are detected by attached LoRa tags. Scanned data is then transmitted through LoRa to a special gateway. From there, the data is transferred to the backend. Using LoRa tags in combination with LoRaTag is suitable for all application scenarios where only a few objects are to be tracked over large areas, and the location inside may be an extra important feature.