Calculating Position From Wifi
WiFi positioning is a method of determining a device's location by analyzing the signal strength from nearby WiFi access points. This technique is commonly used in indoor environments where GPS signals are weak or unavailable. In this guide, we'll explore how WiFi positioning works, how to calculate a position from WiFi signals, and how to interpret the results.
How WiFi Positioning Works
WiFi positioning relies on the fact that WiFi signals degrade as they travel through space. By measuring the signal strength from multiple access points, a device can estimate its distance from each access point and use trilateration to calculate its position.
Key Components
- Access Points (APs): Devices that broadcast WiFi signals. Each AP has a known location.
- Received Signal Strength Indicator (RSSI): A measurement of how strong the WiFi signal is at the receiving device.
- Trilateration: A method of determining a position by measuring distances from multiple known points.
How It Works
- The device scans for nearby WiFi access points and records their MAC addresses and signal strengths.
- The device sends this information to a server or local database that knows the locations of the access points.
- The server uses the RSSI values to estimate the distance from each access point.
- The server applies trilateration to calculate the device's position based on the estimated distances.
- The calculated position is returned to the device.
WiFi positioning is most accurate when there are multiple access points with known locations and when the environment has minimal interference that could affect signal strength.
The Formula Explained
The core of WiFi positioning is estimating the distance from each access point based on signal strength. The most common formula used for this is the log-distance path loss model:
Distance (d) = 10((P0 - Pr) / (10 × n)) × d0
- P0: Reference signal strength at distance d0 (in dBm)
- Pr: Received signal strength (in dBm)
- n: Path loss exponent (typically between 2 and 4)
- d0: Reference distance (typically 1 meter)
Once distances from multiple access points are calculated, trilateration is used to find the intersection point of the circles centered at each access point with radii equal to the estimated distances.
Worked Example
Let's walk through an example calculation to see how WiFi positioning works in practice.
Scenario
We have three access points with known locations and signal strengths:
- AP1: Location (0,0), P0 = -30 dBm, n = 2.5
- AP2: Location (5,0), P0 = -30 dBm, n = 2.5
- AP3: Location (2.5,4.33), P0 = -30 dBm, n = 2.5
Calculating Distances
Suppose the device receives the following signal strengths:
- From AP1: Pr = -50 dBm
- From AP2: Pr = -55 dBm
- From AP3: Pr = -52 dBm
Using the formula:
- Distance to AP1: 10((-30 - (-50)) / (10 × 2.5)) × 1 = 102 = 100 meters
- Distance to AP2: 10((-30 - (-55)) / (10 × 2.5)) × 1 = 100.8 ≈ 6.3 meters
- Distance to AP3: 10((-30 - (-52)) / (10 × 2.5)) × 1 = 100.4 ≈ 2.5 meters
Trilateration
Using the calculated distances, we can find the intersection point of the three circles centered at each access point. This gives us the estimated position of the device.
In practice, the actual calculation involves solving a system of equations to find the intersection point. This is often done using numerical methods or optimization techniques.