32

First of all, I am trying to do all this disaster in c# (.net 4) so if you come up with some code to help me that would be appreciated but really anything would help at this point.

I have a situation where I have a device that can only get GSM Cell information (incidentally via the AT+KCELL command) so I have a collection of values about cell towers (each has LAC, MCC, MNC, Cell ID, Signal Strength and the first Timing Advance). I think, therefore, I am in a good place to be able to come up with some sort of longitude and latitude coordinate (albeit inaccurate, but, well meh). This is where I am reaching out for help because now my little brain is confused...

I can see various services that provide cell code resolution (Google, Open Cell ID, etc) and they take LAC,MCC etc as arguments and return a coordinate. I figure that what they return would, therefore, be the coordinate of the given tower I pass in. So in my case I could send off all the LACs etc that I have and get back a collection of longitude and latitudes. Brilliant, but that is not where my device is. Now I think I need to do some kind of triangulation and this is where my lack of knowledge is hurting me.

So am I right so far? Assuming I am, how do I perform this calculation (is there something out there that will tell me what to do with all these numbers or, even better, some open source library I can reference and feed all this stuff into to get something sensible)?

I'm assuming that I would need to use the timing advance to work out some approximate distance from a cell tower (maybe using the signal strength somehow) but what do I have to do? As you can tell - I am way out of my depth here!

For example, this is something I might get back from the aforementioned AT command:

5,74,33,32f210,157e,8101,50,0,79,3,32f210,157e,80f7,37,64,5,32f210,157e,810b,37,55,32,32f210,157e,9d3,27,41,33,32f210,157e,edf8,15

breaking it up and parsing it I would get (I hope I parse this right - there is a chance there is a bug in my parsing routine of course but it looks reasonable):

Number of cells: 5

Cell 1

LAC: 5502
MNC: 1
MCC: 232
Cell ID: 33025
Signal: 80
ARFCN: 74
BSIC: 33
Timing advance: 0
Longitude: 14.2565389
Latitude: 48.2248439

Cell 2

LAC: 5502
MNC: 1
MCC: 232
Cell ID: 33015
Signal: 55
ARFCN: 79
BSIC: 3
Longitude: 14.2637736
Latitude: 48.2331576

Cell 3

LAC: 5502
MNC: 1
MCC: 232
Cell ID: 33035
Signal: 55
ARFCN: 64
BSIC: 5
Longitude: 14.2488966
Latitude: 48.232513

Cell 4

LAC: 5502
MNC: 1
MCC: 232
Cell ID: 2515
Signal: 39
ARFCN: 55
BSIC: 32
Longitude: 14.2488163
Latitude: 48.2277972

Cell 5

LAC: 5502
MNC: 1
MCC: 232
Cell ID: 60920
Signal: 21
ARFCN: 41
BSIC: 33
Longitude: 14.2647612
Latitude: 48.2299558

So with all that information how do I find, in the most accurate way, where I actually am?

kmp
  • 10,535
  • 11
  • 75
  • 125
  • any chance of posting the data you get.. at least 50% because i am curious ;-) –  Apr 26 '12 at 08:40
  • I think that there may be different techniques for doing this dependent on exactly what data you have. I could put an answer up but it might be best to gather up all the data you can get and post a question on:http://math.stackexchange.com/ unless there is someone who has done this before and is up for sharing the specific info –  Apr 26 '12 at 08:59
  • @gordatron I have added an example - thanks for looking at my question – kmp Apr 26 '12 at 10:03
  • 1
    does anyone know of an umts usb-device that supports this functionality? I've got one from huwei and one from alcatel but none supports AT+KCELL – Folkert van Heusden Feb 07 '13 at 19:37
  • I have the same situation and would like to clarify whether you're adding any changes to the formula provided below or not? – Kin Sep 25 '13 at 08:23
  • @Kirix - The formula below works fine for me. – kmp Sep 25 '13 at 09:11
  • For me it looks a bit simple... May be somehow possible to have a small conversation with you via skype or email? – Kin Sep 25 '13 at 11:52
  • May I ask what device you used which support KCELL? I know its two years now but I am looking at the sim900 chipset which is cheap.. but cant find if it supports KCELL. I want to build my own. fairly accurate trackers to put into equipment I use for contracting. I just need to know more or less where it is and when it leaves a GEO fence, without using GPS – Piotr Kula Oct 22 '14 at 10:32
  • 1
    @ppumkin, Well it has been a while but I think it was a Sagemcom HiLo V2 module - info here: http://support.sagemcom.com/site/livret/URD1_OTL_5635_2_013_72398_ed_02_-_HiLo_V2_technical_specification_14_March_2011.pdf – kmp Oct 22 '14 at 10:40
  • 2
    Never mind. I was looking at a 2010 doc, the 2014 doc has a vendor specific command 'AT+CNETSCAN' that gives you all cells with no sim card or connected cells with the connected network. Pretty awesome for 9GBP :) – Piotr Kula Oct 22 '14 at 11:25
  • The provided solution of Jared Kells seems not to provide an exact location of the intersection point. If you calculate the distances between the intersection point and three centers (for example, based on the path loss model), you can find the exact solution by using the trilateration method. The detail of the formulae to find the coordinate (not longitude, latitude -- Geolocation, but x, y of Cartesian coordinate) is as follows: https://math.stackexchange.com/questions/1948835/how-can-i-calculate-a-points-coordinates-given-distances-from-three-other-known – ngovanmao Mar 26 '19 at 03:26

2 Answers2

42

I can help you with a bit of the theory.

Triangulation is basically finding the intersection point of 3 circles.

Each mobile tower is the center of a circle. The size of the circle is relative to the signal strength of that tower.

The place where the 3 circles overlap is where the user is.

You can do some very basic triangulation as follows:

3 Towers at 
 tx1,ty1 
 tx2,ty2 
 tx3,ty3

With signal strengths s1, s2, s3

We calculate the weight of each signal. Essentially a number from 0 to 1 for each tower where the sum of the weights adds up to 1.

Weighted signal w1, w2, w3 where:
 w1 = s1/(s1+s2+s3)
 w2 = s2/(s1+s2+s3)
 w3 = s3/(s1+s2+s3)


User will be at
x: (w1 * tx1 + w2 * tx2+ w3 * tx3)
y: (w1 * ty1 + w2 * ty2+ w3 * ty3)

Here is a working example using the values from your question:


s1 = 80
s2 = 55
s3 = 55
s4 = 55
s5 = 21

w1 = 80 / ( 80 + 55 + 55 + 55 + 21 ) 
w2 = 55 / ( 80 + 55 + 55 + 55 + 21 ) 
w3 = 55 / ( 80 + 55 + 55 + 55 + 21 ) 
w4 = 55 / ( 80 + 55 + 55 + 55 + 21 ) 
w5 = 21 / ( 80 + 55 + 55 + 55 + 21 ) 

w1 = 0.3007519
w2 = 0.2067669
w3 = 0.2067669
w4 = 0.2067669
w5 = 0.0789474

1. Longitude: 14.2565389
1. Latitude: 48.2248439

2. Longitude: 14.2637736
2. Latitude: 48.2331576

3. Longitude: 14.2488966
3. Latitude: 48.232513

4. Longitude: 14.2488163
4. Latitude: 48.2277972


5. Longitude: 14.2647612
5. Latitude: 48.2299558


Location Longitude = 
 14.2565389 * 0.3007519 + 
 14.2637736 * 0.2067669 + 
 14.2488966 * 0.2067669 +
 14.2488163 * 0.2067669 +
 14.2647612 * 0.0789474

Location Latitude: = 
 48.2248439 * 0.3007519 + 
 48.2331576 * 0.2067669 + 
 48.232513 * 0.2067669 +
 48.2277972 * 0.2067669 +
 48.2299558 * 0.0789474

Result Longitude: 14.255507
Result Latitude: 48.2291628

Jared Kells
  • 6,771
  • 4
  • 38
  • 43
  • 1
    Thanks for answering - I have since included above the longitude and latitude values (according to the Google cellcode resolution service) for each of the cells so I plugged the three with the largest signal strength into the calculations you give. It comes up with a location in Africa (x: 16.0764901666667 y: 4.75214030350877) but all of the cells are located in Austria so that doesn't seem quite right - any chance there is a typo in there? – kmp Apr 26 '12 at 11:36
  • Yeah i shouldn't have been dividing by 3. See if that is any better. I updated the question with an example using your values. It's in Austria now :-) – Jared Kells Apr 26 '12 at 12:11
  • Great, thank you, that definitely looks like a sensible coordinate based on the input! – kmp Apr 26 '12 at 12:14
  • How can you calculate an "Error radius" for a location like this? Or as Google puts it, 'Accuracy'? – kouton Oct 16 '13 at 13:19
  • You can't really. This method isn't very sophisticated, I imagine accuracy is based on the number and quality of the sources. i.e. a location based on 8 GPS satellites is more accurate than one based on an access point and a cell tower. – Jared Kells Oct 17 '13 at 01:40
  • 2
    ...And its assuming all towers have the same strength, height, interference etc. Just had an idea on how to get an error radius, you could use alternating selections of towers and look for similarities/differences in the triangulated point. Also over a period of time (repeat the above several times over a few seconds to alleviate erroneous spikes/drops in strength) – Dave Engineer Dec 11 '14 at 15:34
  • 3
    Signal is usually a negative value in dBm. So, the lower absolute value the better is signal and cell tower is closer. In this answer it means that weight of the signal with lower absolute value must be greater. – Denis The Menace Aug 23 '16 at 20:29
  • 1
    This formula is wrong. Let's simplify to round numbers. We have 3 cells: a(1,2), b(2,3) and c(2,1). And our phone is at (2,2). Signal is therefore 1 for all 3 cells. So factors w1,w2,w3 are all 1/3 X=(1/3 + 2/3 + 2/3) = 5/3 (should be 6/2=2) Y=(2/3 + 3/3 + 1/3) = 6/3 = 2 (this is ok) Also note that circle around tower is for omni antenas, but in practice this antenas are rarely used, they are rather sectored (like a pie). Within the sector the power is not the same in every direction, it is in the middle where on the ends it may drop to 3 or more dB. – Marvin Aug 31 '17 at 09:46
  • triangulation is based of angles . trilateration is based on distances – ofskyMohsen Nov 29 '17 at 12:20
5

This is not an answer really but its a starter and I might add more to it:

The cell ids are published it seems:

http://openbmap.org/

I found this link from this wiki page that has links to other cell id data sources: http://en.wikipedia.org/wiki/Cell_ID )

see the bottom of the page the is a link to the cell id data:

http://openbmap.org/latest/cellular/raw/input_raw.zip

also i found this youtube video where a guys is playing around with some apps that have cell tower locations it seems:

http://www.youtube.com/watch?v=CYvVN5dJD7A

possibly between the cell ids and signal strength you can make a guess..

but AFAIK for general triangulation you need to know the exact location of at least three towers and your exact distance from them (this could be a rough distance with signal strength but it may just be too in accurate).

it seems like wikipedia is saying its done in this way.. use a combination of which cell you are in, the closest tower and signal strengths to get your location:

http://en.wikipedia.org/wiki/Mobile_phone_tracking