# Location by triangulation

**URL:** <https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435>\
**Category:** Application Development\
**Created:** [October 30, 2015, 9:20am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435 "2015-10-30T09:20:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjan/32/180_2.png) [@Arjan](https://www.thethingsnetwork.org/forum/u/Arjan)\
**Post date:** [October 30, 2015, 9:20am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/1 "2015-10-30T09:20:16Z")

</div>

Hi,

I’been trying to dig into how to obtain location information of a node. Left and right I’ve seen comments about gateways who are sending it’s own location information (obtained via build-in GPS) but it’s not yet clear to me how to get a location on the node.

For this it seems obvious you need at least 3 gateways and a node. In GPS the end-device would receive the location of the transmitters, an exact clock signal and thus would be able to calculate the difference from 3 sats based in the transmit delay it took to receive the signal from all 3 birds.

For IOT nodes this seems simply impossible, as it takes a fair amount of CPU power to calculate the location. So I suspect it’s the Application Server that needs to calculate the location of the node based on information the node sends back to the network. For this it seems that the node needs to tell the network what distance it ‘sees’ towards at least 3 gateways. For this the gateways and nodes must be exactly timed, so the node can tell how long it took for him to receive messages from different gateways, right? What would the maximum accuracy be of triangulation using LoRa?

Anyhow who can shed some light on this?

---

<div class="post-metadata">

**Author:** ![nestorayuso](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nestorayuso/32/35697_2.png) [@nestorayuso](https://www.thethingsnetwork.org/forum/u/nestorayuso)\
**Post date:** [October 30, 2015, 9:52am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/2 "2015-10-30T09:52:58Z")

</div>

in this slideshare, from page 21, LoRa location is explained using DTOA

> **[Location-Enabled LoRa IoT Network: “Geo-LoRa-ting” your assets | The French...](https://www.scoop.it/topic/the-french-wireless-connection/p/4053105090/2015/10/08/location-enabled-lora-iot-network-geo-lora-ting-your-assets)**
>
> Geolocation with LPWAN LoRa IoT Networks, a "Must have" Killer application. Benefits from Radio degree of Freedom brought by LoRaWAN Network, adaptive data rat…

---

<div class="post-metadata">

**Author:** ![mpfundstein](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mpfundstein/32/137_2.png) [@mpfundstein](https://www.thethingsnetwork.org/forum/u/mpfundstein)\
**Post date:** [October 30, 2015, 12:04pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/3 "2015-10-30T12:04:58Z")

</div>

One problem is of course the data rate. Because you can’t just spam the network full with packets in order to get a accurate location. So if you want to track a moving target, then you’d probably be better off to use a GPS module.

---

<div class="post-metadata">

**Author:** ![Arjan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjan/32/180_2.png) [@Arjan](https://www.thethingsnetwork.org/forum/u/Arjan)\
**Post date:** [October 30, 2015, 12:33pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/4 "2015-10-30T12:33:19Z")

</div>

A typical application would be geofencing. For this the node should be tracked at least every couple of minutes in order for the application to determine a breach of the fence.

GPS is out of the question, this requires too much CPU and battery power. This is why LoRa seems a nice alternative.

---

<div class="post-metadata">

**Author:** ![Fritek373](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@Fritek373](https://www.thethingsnetwork.org/forum/u/Fritek373)\
**Post date:** [October 30, 2015, 7:46pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/5 "2015-10-30T19:46:51Z")

</div>

> [@nestorayuso](#):
>
> LoRa location is explained using TDOA

If you have this situation for example: `(in a real situation you woudn't know the T = 0)`  
 ![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/02566f7a3cb9d5fe906787626c29ebc69b8fffa6.png)  
So the point of interest transmits a signal on `T = 0`, how can you calculate the origin of the signal? For that you’ll need a receiver with an extremely high sample rate in order to detect the time difference. How is that working?

And 2th, how can the different receivers know the exact time? Is it that so accurate?

---

<div class="post-metadata">

**Author:** ![Arjan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjan/32/180_2.png) [@Arjan](https://www.thethingsnetwork.org/forum/u/Arjan)\
**Post date:** [October 30, 2015, 8:36pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/6 "2015-10-30T20:36:17Z")

</div>

The time between TX and RX tells you how long a signal travelled and thus distance to all stations. Draw circles around each station for each measured distance and find a common place on each of these circles. This is how GPS works too.

The question is: how does a gateway know when the message was sent, as the node does not sent a synchronized time stamp?

---

<div class="post-metadata">

**Author:** ![nestorayuso](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nestorayuso/32/35697_2.png) [@nestorayuso](https://www.thethingsnetwork.org/forum/u/nestorayuso)\
**Post date:** [October 30, 2015, 9:10pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/7 "2015-10-30T21:10:53Z")

</div>

Every LoRa gateway have a GPS receiver to give precise timestamping to each LoRa frame received.  
GPS has a UART output with the time in seconds and a PPS (Pulse Per Second) 1Hz output that triggers a Timer inside SX1301 that gives microsecond or less precision (I supose 1/32MHz).

The advantage of LoRa modulation is that it is easy to determine the beginning and the end of a bit or a frame, because of the chirp modulation. In FSK it is not easy to determine the beginning or the end of a tone.

In GPS location you know the T=0s and the time of arrival of each satellite and you can triangulate (draw circles with the center in each satellite). The calculation is done in the GPS receiver.

In LoRa you don’t know the T=0s and you don’t know the time of arrival (TOA) to each gateway. The LoRa Network server knows the time difference of arrival (TDOA) between every pair of gateways. If you have 3 gateways you have 3 TDOAs. And if you have 4 gateways you have 6 TDOAs.

Instead of drawing circles to triangulate, you must 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.

In page 22 you can see an example with 4 gateways, so 6 TDOAs, so 6 hyperbolic curves colliding in a point that is the estimated location of the node.

---

<div class="post-metadata">

**Author:** ![Fritek373](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@Fritek373](https://www.thethingsnetwork.org/forum/u/Fritek373)\
**Post date:** [October 30, 2015, 9:32pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/8 "2015-10-30T21:32:37Z")

</div>

Radio signals travel with the speed of light `(299.792.458 m/s)`, that would be easy to calculate. And because you know the position of the gateway, you would be able to calculate the position. This is a _(probably not mathematical working)_ example of how it could work:  
 ![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/59c912c4052478fc652bd1da70a76010a5b5ed0d.png)  
May a physicist here could make a better _(mathematical)_ example? 😅

---

<div class="post-metadata">

**Author:** ![Arjan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjan/32/180_2.png) [@Arjan](https://www.thethingsnetwork.org/forum/u/Arjan)\
**Post date:** [October 30, 2015, 10:20pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/9 "2015-10-30T22:20:02Z")

</div>



---

<div class="post-metadata">

**Author:** ![Fritek373](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@Fritek373](https://www.thethingsnetwork.org/forum/u/Fritek373)\
**Post date:** [October 31, 2015, 8:59pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/10 "2015-10-31T20:59:01Z")

</div>

Thanks for the example, I now understand it 🕶.

So:

1. The node is sending a signal
2. Gateways will pick up the signal and send it to the cloud with a timestamp of arrival.
3. The cloud calculates the calculation with hyperbolic curves.

---

<div class="post-metadata">

**Author:** ![fred2](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fred2/32/10583_2.png) [@fred2](https://www.thethingsnetwork.org/forum/u/fred2)\
**Post date:** [November 4, 2015, 10:06am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/11 "2015-11-04T10:06:36Z")

</div>

![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/a97a5c9c7d8b3001dea3a15e806077b7d58fbbce.PNG)

This slide from the presentation also presents the importance of gateway coverage when using this method of geo-location.

And it will be a killer-feature if we can use this!

---

<div class="post-metadata">

**Author:** ![flavio](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/flavio/32/16500_2.png) [@flavio](https://www.thethingsnetwork.org/forum/u/flavio)\
**Post date:** [November 4, 2015, 10:59am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/12 "2015-11-04T10:59:30Z")

</div>

Hi @FredH do you have the entire presentation to share?

---

<div class="post-metadata">

**Author:** ![rudolf1](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/rudolf1/32/11094_2.png) [@rudolf1](https://www.thethingsnetwork.org/forum/u/rudolf1)\
**Post date:** [November 4, 2015, 11:05am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/13 "2015-11-04T11:05:55Z")

</div>

Hi All,

I intend to create a (Apache Spark) cluster application based on streaming (big) data to calculate the position. I am searching for a Python library which I can use to do the TDOA calculations. Does anybody know a good library?

Kind Regards,

Ruud

---

<div class="post-metadata">

**Author:** ![fred2](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fred2/32/10583_2.png) [@fred2](https://www.thethingsnetwork.org/forum/u/fred2)\
**Post date:** [November 4, 2015, 1:59pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/14 "2015-11-04T13:59:00Z")

</div>

I just ripped a few (interesting) slides from [http://www.slideshare.net/titidelparis/io-t-sagemcom-m2minnovationworldgeotrackv08](http://www.slideshare.net/titidelparis/io-t-sagemcom-m2minnovationworldgeotrackv08) that was shared earlier in this thread by @nestorayuso ! Earlier I urged Wienke to include a GPS in The Things Node on Kickstarter (and still think it would extend and upgrade many usecases for the node!) and then went after geo-localization / triangulation with/on the network. So happy it can be done, but think you at least need a GPS in all the gateways for exact synchronized timing, see this other slide from the presentation by SagemCOM:  
 ![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/80e20c43ac1fa644057d365253d849f39a03351d.PNG)

---

<div class="post-metadata">

**Author:** ![turiphro](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/turiphro/32/44103_2.png) [@turiphro](https://www.thethingsnetwork.org/forum/u/turiphro)\
**Post date:** [November 4, 2015, 3:29pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/15 "2015-11-04T15:29:05Z")

</div>

As you can see in the Kickstarter, there will be GPS inside the gateways:

![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/c54e989b9e304703de76045d6bc4b1a2c201bae5.png)

And yes, localisation would help a lot of killer apps come alive 😄 Hope to see an open source implementation ending up in our example handlers coming up some day (any takers?).

---

<div class="post-metadata">

**Author:** ![fred2](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fred2/32/10583_2.png) [@fred2](https://www.thethingsnetwork.org/forum/u/fred2)\
**Post date:** [November 4, 2015, 7:23pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/16 "2015-11-04T19:23:41Z")

</div>

[http://pylayers.github.io/pylayers/notebook/UserManual.html](http://pylayers.github.io/pylayers/notebook/UserManual.html)

This is what you are looking for @Ruud ?

---

<div class="post-metadata">

**Author:** ![rudolf1](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/rudolf1/32/11094_2.png) [@rudolf1](https://www.thethingsnetwork.org/forum/u/rudolf1)\
**Post date:** [November 4, 2015, 9:45pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/17 "2015-11-04T21:45:47Z")

</div>

Thanks @FredH,

It looks great!

I will update this forum when my application is finished.

---

<div class="post-metadata">

**Author:** ![Arjan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjan/32/180_2.png) [@Arjan](https://www.thethingsnetwork.org/forum/u/Arjan)\
**Post date:** [November 13, 2015, 6:20pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/18 "2015-11-13T18:20:24Z")

</div>

Btw: what class will the Kickstarter gateway support? It seems even the Kerlink (the carrier-grade gateway) only supports class A. I was surprised by this.

---

<div class="post-metadata">

**Author:** ![nestorayuso](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nestorayuso/32/35697_2.png) [@nestorayuso](https://www.thethingsnetwork.org/forum/u/nestorayuso)\
**Post date:** [November 18, 2015, 11:26am UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/19 "2015-11-18T11:26:59Z")

</div>

more about location  
[http://www.slideshare.net/zahidtg/lorawan-iot-synchronization](http://www.slideshare.net/zahidtg/lorawan-iot-synchronization)

---

<div class="post-metadata">

**Author:** ![fred2](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fred2/32/10583_2.png) [@fred2](https://www.thethingsnetwork.org/forum/u/fred2)\
**Post date:** [November 20, 2015, 11:22pm UTC](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435/20 "2015-11-20T23:22:37Z")

</div>

![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/d1fc841471f66a9117e47b988e488d8370a926dd.PNG) geo-localization by triangulation as part of the network functionality of TTN is mentioned by @johan in the recent network architecture update, great this is confirmed! It also will become important to use open standards in the higher OSI levels, like the [OGC framework for sensorwebs](http://www.opengeospatial.org/domain/swe).  
 ![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/369a056c9c15178c01736aa40128f04a0431e6a6.jpg)

[Next page](https://www.thethingsnetwork.org/forum/t/location-by-triangulation/435.md?page=2)
