使用 RSSI 计算近似距离

Ido*_*lay 2 bluetooth rssi wifi raspberry-pi

我正在从事一个项目,旨在测量单个 Raspberry PI 与附近智能手机之间的近似距离。

该项目的最终目标是检查 Raspberry 的同一房间内是否有智能手机。

我想了两种实现方式。第一个是使用 RSSI 值测量距离,第二个是从房间内和房间外的多个位置首次校准设置并获得阈值 RSSI 值。我读到即使 Wi-Fi 被禁用,智能手机也会发送 Wi-Fi 数据包,我想使用此功能从传输智能手机获取 RSSI 值(被动使用 kismet)并检查它是否在房间中。我也可以使用蓝牙 RSSI。

如何使用 RSSI 计算距离?

Ham*_*eza 5

这是一个悬而未决的问题。基本上,在理想状态下根据 RSSI 测量距离是很容易的,主要的挑战是减少由于多径和反射 RF 信号及其干扰而产生的噪声。无论如何,您可以通过以下代码将 RSSI 转换为距离:

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));
}
Run Code Online (Sandbox Code Playgroud)

  • @DADi590 根据无线电传播模型,有多种模型可以通过 RSSI 值计算距离。最常见的模型称为“对数距离路径损耗模型”,上面的代码中也使用了该模型。在此模型中,“n”比室内位置的固定数字更复杂。由于路径中存在物体和障碍物,我们不能期望接收器和发射器存在于视线范围内。环境物体会对信号产生干扰、衰落等影响。 (2认同)
  • @DADi590确实根据周围的物体,每个位置的“n”值可能是可变的。室内位置是传播无线电信号的不均匀环境。但是,如果不需要高精度,可以考虑“n”为 2。尽管如此,最终的精度可能只对接近检测有用。 (2认同)