Skip to content

Instantly share code, notes, and snippets.

@etem
Forked from cryptolok/dbm2m.py
Created November 4, 2019 13:06
Show Gist options
  • Select an option

  • Save etem/9dec6ed39ccdabb6435c0322762e5a0d to your computer and use it in GitHub Desktop.

Select an option

Save etem/9dec6ed39ccdabb6435c0322762e5a0d 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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment