Ido Azulay
Ido Azulay

Reputation: 47

Calculate approximated distance using RSSI

I working on a project that aims to measure approximated distance between single Raspberry PI and nearby smartphone.

The final target of the project is to check if there is a smartphone in the same room of the Raspberry.

I thought on two ways for implementation. The first is measure distance using RSSI value, second is to calibrate the setup in the first time from many places in the room and outside the room and get a threshold RSSI value. I read that smartphones sends wi-fi packets even when the wi-fi is disabled, I thought to use this feature the get the RSSI value from the transmitting smartphone (Using kismet passively) and check if its in the room. I can use Bluetooth RSSI also.

How can I calculate distance using RSSI?

Upvotes: 2

Views: 5035

Answers (1)

HamidReza
HamidReza

Reputation: 727

This is an open issue. Basically, Measuring distance according to the RSSI in the ideal state is easy, The main challenge is reducing noise that produced due to multipath and reflecting RF signals and its Interferences. Anyway, you can convert RSSI to distance by below code:

double rssiToDistance(int RSSI, int txPower) {
   /* 
    * RSSI in dBm
    * txPower is a transmitter parameter that calculated according to its physic layer and antenna in dBm
    * Return value in meter
    *
    * You should calculate "PL0" in calibration stage:
    * PL0 = txPower - RSSI; // When distance is distance0 (distance0 = 1m or more)
    * 
    * SO, RSSI will be calculated by below formula:
    * RSSI = txPower - PL0 - 10 * n * log(distance/distance0) - G(t)
    * G(t) ~= 0 //This parameter is the main challenge in achiving to more accuracy.
    * n = 2 (Path Loss Exponent, in the free space is 2)
    * distance0 = 1 (m)
    * distance = 10 ^ ((txPower - RSSI - PL0 ) / (10 * n))
    *
    * Read more details:
    *   https://en.wikipedia.org/wiki/Log-distance_path_loss_model
    */
   return pow(10, ((double) (txPower - RSSI - PL0)) / (10 * 2));
}

Upvotes: 5

Related Questions