Skip to content

Instantly share code, notes, and snippets.

@JT5D
Forked from eklimcz-zz/gist:446b56c0cb9cfe61d575
Last active August 29, 2015 14:27
Show Gist options
  • Save JT5D/6b8ea36530563d502bd3 to your computer and use it in GitHub Desktop.
Save JT5D/6b8ea36530563d502bd3 to your computer and use it in GitHub Desktop.
RSSI to Distance Conversion
function calculateDistance(rssi) {
var txPower = -59 //hard coded power value. Usually ranges between -59 to -65
if (rssi == 0) {
return -1.0;
}
var ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
return Math.pow(ratio,10);
}
else {
var distance = (0.89976)*Math.pow(ratio,7.7095) + 0.111;
return distance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment