Define multi beacons in latest version of Android-Proximity-SDK

Hi I am a newer for estimote beacons and recently I tried to use the Android-Proximity-SDK I saw the latest version is 1.0.3. I saw one possible to define multi beacons

  • proximityObservationHandler=proximityObserver.startObserving(pinkBeacon, yellowBeacon)
    and then stop scan by

  • override fun onDestroy() {
    super.onDestroy()
    proximityObservationHandler?.stop()
    }
    When I tested it on Android phone I can’t detect the 2 beacons correctly (one of 2) and also when I use another beacon (purple) and change tag I can’t detect it at all. Can someone give me some advice? Thanks in advance.

Can you share more of your code? Especially the part where you’re setting up the pinkBeacon and yellowBeacon proximity zones.

Tags in your app/proximity zones need to match tags assigned to beacon in Estimote Cloud, so make sure things are in sync (:

EDIT: nevermind, just saw your other post. I’ll merge it into this one.

Hi
I am a newer for estimote beacons and recently I tried to use the Android-Proximity-SDK to detect 3 beacons but now I face some problems.

  1. When the smartphone moves close or far away the beacons I will get wrong information sometimes. For example I am moving from pink beacon to yellow one and I get ‘Previous you were near the pink beacon’ and then I get ‘Previous you were near the purple beacon’ which is totally wrong

    I don’t know it’s due to the smartphones receiving capability or there are some bug in the code. I changed the working range in the code to make sure there is no overlapping of different range but I still get confusion information. One thing is the yellow beacon seems has stronger signal strength even I out of the range I can detect it. Also I saw some suggestions from forum and decreased the advertising interval from 1000ms to 200ms but the result didn’t change.

  2. Could you please tell me the difference between using estimote API and Eddystone ?

  3. Now the application is running in foreground how can I change it to background?

This is the main part of my code. Can someone answer my questions? Thank you in advance.

Blockquote
class MainActivity : AppCompatActivity() {

/** Fields in this class */

// Related to proximity methods
private lateinit var proximityObserver: ProximityObserver
private var proximityObservationHandler: ProximityObserver.Handler? = null
//private lateinit var proximityObservationHandler: ProximityObserver.Handler


// Could credentials found from https://cloud.estimote.com/
private val cloudCredentials = EstimoteCloudCredentials("laboratorium-dibris-gmail--kfg", "90e1b9d8344624e9c2cd42b9f5fd6392")

// Lambda functions for displaying errors when checking requirements
private val displayToastAboutMissingRequirements: (List<Requirement>) -> Unit = { Toast.makeText(this, "Unable to start proximity observation. Requirements not fulfilled: ${it.size}", Toast.LENGTH_SHORT).show() }
private val displayToastAboutError: (Throwable) -> Unit = { Toast.makeText(this, "Error while trying to start proximity observation: ${it.message}", Toast.LENGTH_SHORT).show() }


/** Methods in this class */

// onCreate method runs first (when an application is launched)
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    // Requirements check
    RequirementsWizardFactory.createEstimoteRequirementsWizard().fulfillRequirements(
            this,
            onRequirementsFulfilled = { startProximityObservation() },
            onRequirementsMissing = displayToastAboutMissingRequirements,
            onError = displayToastAboutError
    )
}


// The method where you implement the logic for your application
private fun startProximityObservation() {

    proximityObserver = ProximityObserverBuilder(applicationContext,cloudCredentials)
            .onError(displayToastAboutError)
            .withTelemetryReportingDisabled() //Added this to reduce the bluetooth call back traffic which was giving an error " Closed Bluetooth Low Energy scan failed with error code: 2"
            .withAnalyticsReportingDisabled() //Similarly this
            .withEstimoteSecureMonitoringDisabled() //Similarly this
            .withBalancedPowerMode()
            .build()

   val pinkBeacon = ProximityZoneBuilder()
            .forTag("pink1")
            .inCustomRange(1.0)
            .onEnter{
                Log.d("Debug.. ", "Currently near the pink beacon")
                textView.text = "Currently near pink beacon"
            }
            .onExit{
                Log.d("Debug.. ", "Previously you were near the pink beacon")
                textView.text = "Previously you were near pink beacon"
            }
            .build()

     val purpleBeacon = ProximityZoneBuilder()
            .forTag("purple2")
            .inCustomRange(1.0)
            .onEnter{
                Log.d("Debug.. ", "Currently near the purple beacon")
                textView.text = "Currently near purple beacon"
            }
            .onExit{
                Log.d("Debug.. ", "Previously you were near the purple beacon")
                textView.text = "Previously you were near purple beacon"
            }
            .build()

    val yellowBeacon = ProximityZoneBuilder()
            .forTag("yellow1")
            .inCustomRange(2.0)
            .onEnter{
                Log.d("Debug.. ", "Currently near the yellow beacon")
                textView.text = "Currently near yellow beacon"
            }
            .onExit{
                Log.d("Debug.. ", "Previously you were near the yellow beacon")
                textView.text = "Previously you were near yellow beacon"
            }
            .build()


    proximityObservationHandler = proximityObserver.startObserving(pinkBeacon, purpleBeacon, yellowBeacon)

}
// onDestroy method runs last (when an application is closed)
// IMPORTANT (This applies for mobile app):
// If you don't stop the scan here, the foreground service will remain active EVEN if the user kills your APP.
// You can use it to retain scanning when app is killed, but you will need to handle actions properly.
override fun onDestroy() {
    proximityObservationHandler?.stop()
    super.onDestroy()
}

}

Piotr thanks for your reply , I checked the tags they are correct more codes are added in my new questions which is under your reply now.

Your code looks good to me.

For example I am moving from pink beacon to yellow one and I get ‘Previous you were near the pink beacon’ and then I get ‘Previous you were near the purple beacon’ which is totally wrong

Assuming you have your beacons tagged correctly, this could indeed mean signal overlap between the pink and the purple beacon. You can try spreading them further apart.

Could you please tell me the difference between using estimote API and Eddystone ?

This might help: Intro to Eddystone - Estimote Developer

Now the application is running in foreground how can I change it to background?

This should make sure your enter/exit events continue even if the user left the app:

GitHub - Estimote/Android-Proximity-SDK: Estimote Proximity SDK for Android

Thanks for your answer. I set the working range as 1m is it normal that the actual working range is 2m? If it’s normal then how to improve the precise? Another question are there some method to get the bluetooth signal strength?

Yes, that sounds about right. Bluetooth-based proximity is more of a rough-grained tool.

The ProximityObserver doesn’t provide signal strength, but you can use our lower-level scanning APIs for that. These aren’t documented too well, but this might get you started:

https://github.com/Estimote/Android-Proximity-SDK#scanning-for-estimote-telemetry

This shows how to use our BluetoothScanner to discover individual telemetry packets, and each packet has an rssi property which is the received signal strength that’s already been pre-processed by our smoothing algorithms. If you need absolute raw signal strength, you’d need to drop down to Android’s native BluetoothLeScanner.

Hi Piotr your reply helps me a lot. I know the proximity is like a geo-fences but since I will work on a project with service robots so I need a more precise result.

  • Could you please tell me more details about the amoothing algorithms? The rssi is inversely proportional to distance or they are expressed in a more complex way?

  • Could you please tell me if there are some methods to make the proximity more reliable? Now I face a problem that in certain moment I will see a wrong message about entering one area although it’s quiet short but I want to avoid it. I don’t know it’s due to the beacons(I changed the batteries) or the code. Did you meet this problem when you test proximity? I am thinking using the time duration now if you have better suggestions I am happy to learn.

  • At the same time I tested the location method I am using the beacon with firmware 4.13.2. I can see the avatar can reach the position more or less but the responsing time is a little long and sometimes it will keep moving. In this situation how can I reduce error and get a more precise position?
    Thank you very much.

RSSI is inverse-square proportional to the distance, but it’s also affected by attenuation and multi-path propagation, so it’s tricky to work with. We don’t generally reveal much about how our own SDKs deal with that.

If you need something more precise, we have Indoor Location. It uses signal from multiple beacons, and it uses a map to know where the beacons are, for more precise results. Comes in two variants: Bluetooth-based, so that it works with smartphones, and also UWB-based for when you can stick a UWB beacon on the object being located (a robot, a vehicle, etc.). See “Indoor Location” and “Robotics” on https://developer.estimote.com for more details.

I heard about the UWB beacon my work is indoor so for now I think location beacon is enough maybe later I will need it. Can you give me some advice about how to improve the accuracy and stablity of location in Android ?

You can experiment with the placement of the beacons, and with the range numbers. Accuracy is usually better closer to the beacons, so it’s best to put the beacon as close to the point of interest as possible. Maybe use two or more beacons per zone, with shorter zone range, rather than one beacon per zone with bigger range. Clear line of sight also helps, so it’s usually better no to hide the beacons behind things.