DIY indoor positioning (part 1)

Finding your position outdoors on a device is easy with GPS but indoors is another matter. I have some potential projects that might need indoor positioning so I have started researching and testing the subject. There are several ways to calculate indoor position and technologies including:

  • Visible Light Communication (VLC);
  • Bluetooth;
  • WiFi;
  • Ultra Wide Band (UWB); and
  • Near Field Communication (NFC) / RFID.

I do not want to spend a fortune so the DIY route it is. VLC largely requires line of sight and regardless of speed flashing lights always concern me for migraine and epilepsy sufferers. I also want a system that could potentially be used in any environment, inside or out, light or dark. As for UWB the Decawave DWM1000 module is something I would like to play with especially when reports say accuracy down to 12cm or so. This is on the cards but considering the cost not just yet. Ideally I want a solution that works with say an Android tablet without having to modify or add external hardware. This leaves Bluetooth and WiFi. I will try both of these, starting with WiFi. The only reason I am starting with WiFi is that I have a pile of ESP8266 modules already.


So the theory is you use multiple beacons, measure the signal strength to each beacon and this allows you to calculate your position. Think of it like this, you are on a boat, you can see three lighthouses and you measure the amount of light from each. The light level allows you to estimate your position. There are a few issues, you need to know the position of each beacon for starters and then there is the calculation for position. This method is called Trilateration and is what I will use.

Measuring distance

Rather than do it all in one go I will do this step by step. So first is to use two ESP8266's. One will be a beacon, the other will scan for that beacon and print the RSSI value. The beacon is simply the ESP8266 setup as an Access Point (AP). A simplified formula1RSSI = -10n  log d + A where n is the path loss factor, d is the distance and A is the measured power at 1m can be used.


Using a path loss coefficient of 2.9 and measured power at 1m of -49dBm along with the above formula and the RSSI a distance can be calculated. Results I have obtained shown below:

Measured RSSI (dBm) Actual distance (m) Calculated distance (m) Error (m)
-32.15 0.05 0.26 0.21
-35.52 0.10 0.34 0.24
-40.00 0.20 0.49 0.29
-47.85 0.40 0.91 0.51
-49.05 1.00 1.00 0.00
-45.72 1.50 0.77 0.73
-50.50 2.00 1.12 0.88
-54.43 2.40 1.53 0.87
-61.90 2.48 2.77 0.29
-60.43 2.50 2.47 0.03
-62.48 2.90 2.90 0.00

One admission, I have taken the RSSI at each distance as an average of 60 samples. The orientation of the ESP8266 module makes a difference and might account for some of the bumps in the data. This was done in an empty room with no obstructions. More testing is needed, for example with people and objects in the path, no averaging, etc.. I did notice a few blips where at say 0.4m the RSSI would suddenly indicate it was 5m away. In any case overall I was impressed with the results, they were far more accurate than I thought they would be.

Next step

This is going to be an ongoing project and there are several more steps:

  1. Repeat the above test but use two ESP-07's with an external antenna.
  2. Repeat the above with people, objects, walls, etc.
  3. Extend to three beacons to allow position to be determined
  4. Extend to four or more beacons to allow 3d position to be determined.
  5. Investigate existing open source solutions (i.e. FIND, Redpin)

1 Oguejiofor O.S., Okorogu V.N., Adewale Abe, Osuesu B.O, Outdoor Localization System Using RSSI  Measurement of Wireless Sensor Network, International Journal of Innovative Technology and Exploring Engineering (IJITEE) ISSN: 2278-3075, Volume - 2, Issue - 2, January 2013


As far as WiFi is concerned, there are several techniques for indoor localization.

1- WiFi Fingerprinting
So this technique involves generating WiFi RSSI map (getting RSSI from several APs nearby). Once you have mapped the whole place, you can then use any similarity measure to know your current position.

2- Trilateration - It involves knowing APs location, so if you don't know AP's location (in an unknown mobile environment), unfortunately, you cannot use it.

3- Measuring distance using RSSI and distance relationship is also a very popular method but I this case you are not sure of your position relative to the AP (could be anywhere in 360 degrees), also this method uses path loss coefficient n which is signal attenuation due to the environment. It depends upon on wall thickness and type of environment office, hall etc. but there are several textbooks values for n for the different type of spaces.

Indeed I am aware of all of them and mentioned some above. I already am testing all the methods out, have mentioned 1 and 2 above. Fingerprinting works well, especially if using a ESP8266 in each room just as an AP, really helps to get good results. Already in this article mentioned 3, which works but needs smothing and whilst only gives you distance and not position is good for a proximity based application.

Add new comment