Skip to content

Instantly share code, notes, and snippets.

@cryptolok
Last active August 19, 2023 12:29
Show Gist options
  • Save cryptolok/516471ce35a9851197b204853c6de080 to your computer and use it in GitHub Desktop.
Save cryptolok/516471ce35a9851197b204853c6de080 to your computer and use it in GitHub Desktop.
convert WiFi signal strength (dBm) to distance (meters)
#!/usr/bin/env python2
# a simple script for one of my articles - https://cryptolok.blogspot.com/2017/08/practical-wifi-hosts-triangulation-with.html
from math import log10
MHz=raw_input('MHz FREQUENCY (2417, 5200, ...) : ')
MHz=int(MHz)
dBm=raw_input('dBm TRANSMITTER POWER (23, 63, ...) : ')
dBm=int(dBm)
FSPL = 27.55
# Free-Space Path Loss adapted avarage constant for home WiFI routers and following units
m = 10 ** (( FSPL - (20 * log10(MHz)) + dBm ) / 20 )
m=round(m,2)
print 'DISTANCE : ',m,'m'
@cboychinedu
Copy link

Which language did you use

The python programming language was used for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment