-
-
Save pwittchen/ab6d2a64b2f73a12b4efd47dfcd86b0c to your computer and use it in GitHub Desktop.
RSSI to Distance Conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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