1

It is possible to find actual ble

txPower

of android device. So that, I can use it below Beacon builder object instead of -59 as txPower.

Beacon beacon = new Beacon.Builder()
    .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
    .setId2("1")
    .setId3("2")
    .setManufacturer(0x0118)
    .setTxPower(-59)
    .setDataFields(Arrays.asList(new Long[] {0l}))
    .build();

The use case what I have is, to read distance between two android ble device.

Shanmugapriyan
  • 953
  • 1
  • 10
  • 28

1 Answers1

4

The txPower field is supposed to be the expected signal strength in dBm at 1 meter. Every Android phone model has a slightly different BLE transmitter output power, typically measuring from -50 dBm to -70 dBm at 1 meter.

Unfortunately there is no good way to get the proper value to use for a specific Android device model unless you measure this yourself. Android has no built-in APIs to get this, and I have never seen any published specs from phone manufacturers.

There has been renewed interest in this subject as teams develop contact tracing apps. I actually went out in a field last weekend to measure the transmitter output power of a number of devices I had handy. The Google Pixel 3a, for example, I measured -60 dBm.

If you want to take your own measurements to help in this effort, I suggest this procedure:

  1. Go to an open area several meters away from any obstructions, particularly metal ones.
  2. Elevate the phone transmitter on a non-metal object at least one meter off the ground. The phone should be placed on end so the screen is perpindicular to the ground. (I used a camera tripod.)
  3. Run an app that transmits a beacon at full power on the phone on the tripod.
  4. Hold a reference phone (preferably an iPhone SE 1st Generation or old iPhone 4-5s) on meter away so that both screens are facing the same direction.
  5. Do a "calibration" in a beacon app like Locate Beacon to get the average RSSI over ~30 seconds.
  6. If the phone used to do the measurement is not one of the above reference models, you will need to adjust for that phone's receiver sensitivity. The spreadsheet I shared has an example of how to do that for the Pixel 3a measuring the iPhone SE. This part can be tricky as you need one other phone with a known sensitivity or transmitter power output.

Here's my spreadsheet with the calculations: https://docs.google.com/spreadsheets/d/1-voNJAeHz78AarZmfds8WiplNhUDzeYrsW0YzKfrExU/edit?usp=sharing

I also wrote a blog post that touches on the problem of the lack of a good data set, and tells you more than you ever wanted to know about beacon ranging.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • read the blogpost and it is a very usefull article! Thanks for sharing| – guyprovost Jun 02 '20 at 13:13
  • Also see here (official Android API): https://developer.android.com/reference/android/bluetooth/le/ScanResult#getTxPower(). Can be gotten when using BLE, and only from Oreo onwards. – Edw590 Jul 26 '21 at 01:17
  • 1
    The txPower field in Android API simply returns a value from the scanned advertisement from another device. It’s value is only as accurate as whoever set it on the other side. In my experience that value is very rarely set properly. – davidgyoung Jul 27 '21 at 02:38