我正在研究一个旨在测量单个Raspberry PI与附近智能手机之间的近似距离的项目。
该项目的最终目标是检查Raspberry的同一房间中是否有智能手机。
我考虑了两种实施方式。首先是使用RSSI值测量距离,其次是第一次在房间内和房间外的许多地方校准设置,并获得RSSI阈值。我读到即使禁用了wi-fi,智能手机也会发送wi-fi数据包,我想使用此功能从发送智能手机(被动使用kismet)获取RSSI值,并检查其是否在房间内。我也可以使用蓝牙RSSI。
如何使用RSSI计算距离?
这是一个未解决的问题。基本上,在理想状态下根据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(10d, ((double) txPower - RSSI - PL0) / (10 * 2));
}