user image

Shilpa
Published in : 2022-02-26

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 Date : 2022-02-26

Best answers

34

Best answers

34

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

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How to call event handler onload for Angular application?
Publish date: 2022-03-02 | Comments: 2

Tag: Angular

How to bind Weekends off to my kendo calendar in Angular?
Publish date: 2022-03-11 | Comments: 2

Tag: Angular

Adding country flags is really struggling thing?
Publish date: 2022-02-25 | Comments: 6

Tag: Angular

Angular - PrimeNG charts adding colors for each legends dynamically
Publish date: 2022-02-27 | Comments: 1

Tag: Angular