timer 3 minutes read

Being a software development agency, we get a lot of opportunities to work in cutting edge technologies.

Recently we received an inquiry from one of the leading Electronic companies of the city, working in the domain of embedded software. They have a proven track record in designing wearables for fitness tracking and payments. Now their aim is to become the next generation IoT company.

They wanted us to solve the following problem using iBeacon.

Build a mobile app that can receive signals from iBeacon and calculate the distance between an iBeacon and itself with an error margin of 10 to 15 meters.

Instead of reinventing the wheel, we searched for existing alternatives (preferably open source) and found one on GitHub.

We used AltBeacon to establish signal transmission between iBeacon and mobile device. But the accuracy was not satisfactory.

Finding accurate distance was the biggest challenge after establishing the initial signal transmission and we tried the native Android Bluetooth API for that.

The results were promising. It gave us more realistic distance but still, there were anomalies and outliers.

We applied the following two methods on the sample data we received from iBeacon to identify the distance between iBeacon and a receiver.

Method 1 — Averaged consecutive samples over 5 seconds.

Method 2 — Took Weighted Average of consecutive samples over 5 Seconds.

Applying the above two methods did not give expected results and thus we thought to make the data more accurate by applying two different filters on samples received by the following two techniques.

1. Removed samples with +/- 2 of the weighted average.

For e.g. If sample data looks like -54, -56, -58, -52, -54, -56, its weighted avg. is -54 and we add +2 and -2 and consider only those data for measuring the distance.

2. Removed outliers considering most no. of occurrences of the same sample value.

For e.g. If sample data looks like -54, -56, -58, -52, -54, -54, -56, -54 and most no. occurrence is -54 plus +/- 2 of -54 are considered to bring better accuracy.

Applying these techniques gave us accuracy up to 6 to 7 meters and we had the challenge to bring the accuracy of more than 10+ meters. After doing a lot of brainstorming we figured that enriching sample values themselves were the key to reach the anticipated accuracy.

For e.g. If actual sample values from iBeacon are : -52, -50, -54, -56, -64, -54, e enrich the samples by considering “Average of two consecutive samples”, which is : -51, -52, -55, -60, -59

Now we used the enriched samples in the first two methods and it gave us the accuracy of 10+ meters.

Architecture

iBeacon - Android Bluetooth API Architecture

Results

  1. Results

    Achieved signal transmission and accurate distance calculation in the range of 10 to 15 meters using native Android SDK.

    Future Prospect

    In the future, the client wants to enhance signal transmission by repeaters and apply the solution to find out vacant spaces in limited areas.

    Possible Use Case

    • Locate available car parking space for driver.
    • Navigate the driver to that empty space.
    • Take parking fee payments if any.
    • Call vehicle owners for an emergency.

    We have made the code open source for developers in case they want to use it and bring more accurate results or use for any specific application.

    Sample

    https://github.com/kevindigi/android-iot-samples/blob/dev/app/src/main/java/com/digicorp/androidiotsamples/ble_distance/BLEDistanceActivity.java

    Helper Classes

    1) Beacon Identifier

    https://github.com/kevindigi/android-iot-samples/blob/dev/app/src/main/java/com/digicorp/helper/BeaconIdentifier.java

    2) Distance Manager

    https://github.com/kevindigi/android-iot-samples/blob/dev/app/src/main/java/com/digicorp/helper/DistanceManager.java

    This technical write up was not possible without Vivek NavadiaEngineering Manager and Kevin AdesaraAll rounder Code Engineer at Digicorp. They are the one who did the entire prototype and satisfied the need of a customer.

Nachiket
  • Posted on March 20, 2019

Leave a Reply

Your email address will not be published. Required fields are marked *

10 − one =

Related Blogs

Stay in touch.!

Get our case studies, infographics directly into your inbox

Let Us Build Great Products Together

Let's Connect!

Contact

USA

1411 Zinnia RD
Missouri City, TX 77489, USA
+1 (832) 947-3143
sales@digi-corp.com

India

Digicorp House,
Ambawadi,
Ahmedabad 380015
+91 79 26304681
sales@digi-corp.com