title: Distance calculation from RSSI BLE android
body: <p>I know there is lot of question on stackoverflow related to my question, but I would like to know if there is any way to get the exact distance from RSSI.</p>
  
  <p>I have followed <a href="https://stackoverflow.com/questions/22784516/estimating-beacon-proximity-distance-based-on-rssi-bluetooth-le">this link</a> and some other <a href="http://altbeacon.github.io/android-beacon-library/" rel="noreferrer">git library methods for distance calculation</a> as well as this <a href="http://developer.radiusnetworks.com/2014/12/04/fundamentals-of-beacon-ranging.html" rel="noreferrer">tutorial</a>. But I can't get the correct solution.</p>
  
  <p>This is what I'm using to measure the distance: </p>
  
  <pre><code>protected double calculateDistance(float txPower, double rssi) {
  
      if (rssi == 0) {
          return -1.0; // if we cannot determine distance, return -1.
      }
  
      double ratio = rssi * 1.0 / txPower;
  
      if (ratio &lt; 1.0) {
          return Math.pow(ratio, 10);
      } else {
          double accuracy = (0.89976) * Math.pow(ratio, 7.7095) + 0.111;
          return accuracy;
      }
  }
  </code></pre>
  
  <p>When I call this method I pass the <a href="https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.tx_power.xml" rel="noreferrer">standard</a> and rssi what i'm get from my mLeScanCallBack()</p>
  
  <pre><code>private BluetoothAdapter.LeScanCallback mLeScanCallback =
          new BluetoothAdapter.LeScanCallback() {
  
              @Override
              public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
                  runOnUiThread(new Runnable() {
  
                      @Override
                      public void run() {
  
                          BluetoothDeviceModel bluetoothDeviceModel = new BluetoothDeviceModel(device, rssi);
  
                          mLeDeviceListAdapter.addDevice(bluetoothDeviceModel, rssi, bluetoothDeviceModel.device.getAddress());
                          mLeDeviceListAdapter.notifyDataSetChanged();
  
                          if (mapBluetooth != null) {
                              mapBluetooth.put(bluetoothDeviceModel.getDevice().getAddress(), bluetoothDeviceModel);
                              mLeDeviceListAdapter.refresh(mapBluetooth);
                          }
                      }
                  });
              }
          };
  </code></pre>
  
  <blockquote>
    <p>What Problem i'm facing?</p>
  </blockquote>
  
  <p>There is nothing wrong with the code above. It gives me the distance but i'm not satisfied with that because it's not the correct distance. So can anyone tell me if it is possible to get the exact distance with the above method or if there is any other way?</p>