user

Shilpa

26 Feb 2022

How to calculate distance between two Bluetooth devices?

Angular

Hi guys,

I am working on one client's requirement, they want to find the distance between two persons when they came up nearby to each other their mobile should alert them.

After doing some research, we found using Bluetooth is possible. We want to target Bluetooth in mobile or Bluetooth in wearables (smartwatches, fit-bit watches, etc.) I am using Angular, Cordova, and Nodejs for the backend. If required, I can change the technology to React js or Vue js if there is some way to achieve my requirement.

So is there any way to get the distance between two Bluetooth devices? Any suggestions.

Any prototype or code snippets will be helpful for me, thank you.

Comments

Rakshit

26 Feb 2022

Best Answer

best answer

Yes, it is possible to do at some points, definitely, it has some limitations.

You are using Cordova, I am assuming your requirement is for Android and iOS devices.

In Bluetooth devices, the RSSI value will bring you approximated but with a high accuracy distance, it works up to 9-12 Feet.

There is one formula to convert RSSI values in the feet or meters, Bluetooth plugins for Cordova are also providing hooks where you can add some alert or beep logic.

Distance = 10 ^ ((Measured Power -RSSI)/(10 * N))

Where 

  • BLE uses Measured Power is also known as the 1 Meter RSSI. So consider the value of Measured Power = -69
  • RSSI = Obtained RSSI value from the devices (For example, you obtained -80)
  • N = 2 (Consider Low strength)

Put the values into the above formula to calculate the distance:

Distance for RSSI -80 = 10 ^ ((-69 -(-80))/(10 * 2)) = 3.54 meters

Distance for RSSI -75 = 10 ^ ((-69 -(-75))/(10 * 2)) = 1.995 meters ≅ 2 meters

While the covid pandemic time I made some research on it and I was working on an application to manage a safe 1.5 Meter distance.

You can find the project made using Vue js and Cordova plugins. 

Github

Convert RSSI values to Meters Formula

--

Limitations:

  1. For iPhone, security matters the most. You can keep Bluetooth on until you are accessing the phone, after a few minutes it will kill the process on its own.
  2. Wearable Devices might be found, might not. Because of the used middleware in the watches, it may ask to connect first - otherwise, it may/or may not give the permissions.

Sources: GITHUB & Medium

© 2024 Copyrights reserved for web-brackets.com